Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package app2;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.*;
- /**
- *
- * @author Student1
- */
- public class App2 {
- //
- public static JPanel createPanel(){
- //
- AppActionListener listener = new AppActionListener();
- JPanel p = new JPanel();
- JButton button1 = new JButton("Кнопка1");
- button1.setActionCommand("BUTTON1_COMMAND");
- button1.addActionListener(listener);
- p.add(button1);
- JButton button2 = new JButton("Кнопка2");
- button2.setActionCommand("BUTTON2_COMMAND");
- button2.addActionListener(listener);
- p.add(button2);
- //
- JLabel label = new JLabel("Текст:");
- p.add(label);
- JTextArea tx = new JTextArea(5, 20);
- p.add(tx);
- return p;
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- /*
- JFrame frame = new JFrame("HelloWorldApp");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().add(createPanel());
- frame.setBounds(0, 0, 800, 600);
- frame.setVisible(true);
- */
- //
- Okno frame = new Okno();
- }
- }
- /*
- button1.addActionListener(new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent ae) {
- //
- Object obj = ae.getSource();
- System.out.println("source.class=" + obj.getClass());
- String actionCommand = ae.getActionCommand();
- //
- System.out.println("actionCommand=" + actionCommand);
- System.out.println("Событие!!!");
- }
- });*/
Add Comment
Please, Sign In to add comment