Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package HW;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class GUI2 {
- public class GUI2 extends JFrame implements ActionListener {
- FlowLayout flow = new FlowLayout();
- JButton b1 = new JButton("Abraham Lincoln");
- JButton b2 = new JButton("Ronald Regan");
- JButton b3 = new JButton("Jimmy Carter");
- JButton b4 = new JButton("George Bush");
- JButton b5 = new JButton("Bill Clinton");
- public GUI2() {
- Container con = getContentPane();
- con.setLayout(new BorderLayout());
- con.add(b1, BorderLayout.NORTH);
- con.add(b2, BorderLayout.CENTER);
- con.add(b3, BorderLayout.WEST);
- con.add(b4, BorderLayout.EAST);
- con.add(b5, BorderLayout.SOUTH);
- b1.addActionListener(new ActionListener());
- b2.addActionListener(new ActionListener());
- b3.addActionListener(new ActionListener());
- b4.addActionListener(new ActionListener());
- b5.addActionListener(new ActionListener());
- }
- public static void main(String[] args) {// main method
- GUI2 temp = new GUI2();
- temp.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// close on x
- temp.setSize(600, 300);// frame size
- temp.setVisible(true);// make GUI visible
- }
- public void actionPerformed(ActionEvent e) {
- System.exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement