//////////////////////////////////////////////////MyDriver.java /** Drives a simple swing program */ public class MyDriver{ public static void main(String args[]) {

snottybugbearSoftware and s/w Development

Nov 3, 2013 (3 years and 9 months ago)

74 views



//////////////////////////////////////////////////MyDriver.java
/**
Drives a simple swing program
*/
public class MyDriver{
public static void main(String args[]) {
MyFrame app=new MyFrame();
}
}

//////////////////////////////////////////////////MyFrame.java
import javax.swing.*;
/**
very very simple swing GUI
*/
public class MyFrame extends JFrame{
private MyPanel panel;

public MyFrame() {
panel= new MyPanel();
add(panel);

setSize(200,200);
setLocation(200,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("demo swing");
setVisible(true);
}
}

//////////////////////////////////////////////////MyPanel.java
import javax.swing.*;
/**
the panel
*/
public class MyPanel extends JPanel{
private JButton button;

public MyPanel() {
button=new JButton("Hello");
add(button);
}
}
app

panel

: MyFrame

: MyPanel

button
: J
Button