Tuesday, November 21, 2006


import javax.swing.*;

// In this example, no layout is specified
// BorderLayout applies becos JFrame uses BorderLayout
// by default
// Therefore, components must all have
// a direction specified

public class MyThirdGUI extends JFrame{

// Step 1: Declare the components
private JButton tongjin;
private JTextField ivan;

public MyThirdGUI(){
// Step 2: Create the component
tongjin = new JButton("Click me");
ivan = new JTextField(10);

// Step 3: Add the component to the container
getContentPane().add(tongjin,"South");
getContentPane().add(ivan);
}



public static void main(String args[]){
MyThirdGUI barnet = new MyThirdGUI();

barnet.setSize(100,200);
barnet.setVisible(true);

} //end main

}//end class


No comments: