MyGUI - import java.awt import java.awt.event.ActionEvent...

This preview shows page 1 - 3 out of 4 pages.

import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.*;public class MyGUI {public static void main(String[] args) {new SimpleFrame();}}class SimpleFrame extends JFrame {private static final long serialVersionUID = 1L;public SimpleFrame() {super("GUI Demo 1");setSize(800, 600);setVisible(true);}}// =================================================================class MyGUI2 {public static void main(String[] args) {new PanelFrame();}}class PanelFrame extends JFrame {JLabel label = new JLabel("Label1");JButton button = new JButton("Button1");private static final long serialVersionUID = 1L;public PanelFrame() {super("GUI Demo 2");JPanel panel = new JPanel();panel.setLayout(new GridLayout(2,1)); // Strategy Pattern!panel.add(label);panel.add(button);Container c = getContentPane();c.add(panel);setSize(800, 600);setVisible(true);}}// =================================================================class MyGUI3 {public static void main(String[] args) {new MultiPanelFrame();}}class MultiPanelFrame extends JFrame {private static final long serialVersionUID = 1L;
JButton button1 = new JButton("1");JButton button2 = new JButton("2");JButton button3 = new JButton("3");

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture