sergAccount

Untitled

Sep 18th, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.13 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package app2;
  7.  
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10. import javax.swing.*;
  11.  
  12. /**
  13.  *
  14.  * @author Student1
  15.  */
  16. public class App2 {    
  17.     //
  18.     public static JPanel createPanel(){
  19.         //
  20.         AppActionListener listener = new AppActionListener();        
  21.         JPanel p = new JPanel();        
  22.         JButton button1 = new JButton("Кнопка1");
  23.         button1.setActionCommand("BUTTON1_COMMAND");        
  24.         button1.addActionListener(listener);      
  25.         p.add(button1);
  26.        
  27.         JButton button2 = new JButton("Кнопка2");
  28.         button2.setActionCommand("BUTTON2_COMMAND");
  29.         button2.addActionListener(listener);
  30.         p.add(button2);
  31.         //
  32.         JLabel label = new JLabel("Текст:");
  33.         p.add(label);
  34.        
  35.         JTextArea tx = new JTextArea(5, 20);              
  36.         p.add(tx);
  37.         return p;
  38.     }    
  39.     /**
  40.      * @param args the command line arguments
  41.      */
  42.     public static void main(String[] args) {
  43.         // TODO code application logic here        
  44.         /*
  45.         JFrame frame = new JFrame("HelloWorldApp");
  46.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  47.         frame.getContentPane().add(createPanel());
  48.         frame.setBounds(0, 0, 800, 600);
  49.         frame.setVisible(true);            
  50.         */
  51.         //
  52.         Okno frame = new Okno();
  53.     }    
  54. }
  55.  
  56.  
  57.   /*
  58.         button1.addActionListener(new ActionListener(){
  59.             @Override
  60.             public void actionPerformed(ActionEvent ae) {
  61.                 //
  62.                 Object obj = ae.getSource();
  63.                 System.out.println("source.class=" + obj.getClass());
  64.                 String actionCommand = ae.getActionCommand();
  65.                 //
  66.                 System.out.println("actionCommand=" + actionCommand);
  67.                 System.out.println("Событие!!!");
  68.             }
  69.         });*/
Add Comment
Please, Sign In to add comment