// 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); JLabel label = new JLabel("Hello World"); getContentPane().add(label); 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 MyMenuBar { public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { MyGui myGUI = new MyGui(); myGUI.createGUI(); } }); } }