import javax.swing.*;
import java.awt.*;
public class GUITest
{
JFrame myFrame;
public void initGUI()
{
myFrame=new JFrame();
Container c=myFrame.getContentPane();
c.setLayout(new FlowLayout());
JTextField tf=new JTextField(10);
JButton b1=new JButton("My Button");
c.add(tf);
c.add(b1);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.setSize(300,300);
myFrame.setVisible(true);
}
public GUITest()
{
initGUI();
}
public static void main(String ar[])
{
GUITest gui=new GUITest();
}
}
Output: