// This code example is created for educational purpose // by Thorsten Thormaehlen (contact: www.thormae.de). // It is distributed without any warranty. import javax.swing.*; class MyGui extends JFrame{ public void createGUI() { setTitle("HelloGUI"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(320, 240); setLayout(null); JLabel label = new JLabel("Hello World"); label.setBounds(120, 0, 150, 30); getContentPane().add(label); JButton button = new JButton("Button Text"); button.setBounds(120, 30, 150, 30); getContentPane().add(button); JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("File"); menuBar.add(menu); JMenuItem item = new JMenuItem("Open"); menu.add(item); setJMenuBar(menuBar); setVisible(true); } } public class MyButton { public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { MyGui myGUI = new MyGui(); myGUI.createGUI(); } }); } }