JMenu Adding Menu To Window In Java
Chapter:
Swing
Last Updated:
23-07-2016 06:22:09 UTC
Program:
/* ............... START ............... */
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
public class JavaMenuToWindow extends JFrame {
private JMenuBar menuBar = new JMenuBar();
public JavaMenuToWindow(String title) {
setTitle(title);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setJMenuBar(menuBar);
JMenu fileMenu = new JMenu("File");
JMenu editMenu = new JMenu("Edit");
menuBar.add(fileMenu);
menuBar.add(editMenu);
}
public static void main(String[] args) {
JavaMenuToWindow window = new JavaMenuToWindow("Sketcher");
window.setBounds(30, 30, 300, 300);
window.setVisible(true);
}
}
/* ............... END ............... */
Output
Tags
JMenu Adding Menu To Window, Java, Swing