Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JFrame frame = new JFrame();
- JPanel panel = new JPanel();
- JButton button = new JButton("Button");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- button.addActionListener(new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent arg0) {
- //Code which will be executed when the button is pressed
- System.out.println("You pressed the button!");
- }
- });
- frame.add(panel);
- panel.add(new JButton("Button 1"));
- frame.pack();
- frame.setVisible(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement