mirror of
https://gitlab.com/tutorial-java-rafa-munoz/tutorial-java-2024-25/tutorialjava2024-25.git
synced 2025-11-09 18:03:09 +01:00
feat(ch 9): ex 2 added menu
This commit is contained in:
@@ -10,6 +10,9 @@ import javax.swing.JToolBar;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JTabbedPane;
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
|
||||||
public class VentanaPrincipal extends JFrame {
|
public class VentanaPrincipal extends JFrame {
|
||||||
|
|
||||||
@@ -38,6 +41,15 @@ public class VentanaPrincipal extends JFrame {
|
|||||||
public VentanaPrincipal() {
|
public VentanaPrincipal() {
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setBounds(100, 100, 450, 300);
|
setBounds(100, 100, 450, 300);
|
||||||
|
|
||||||
|
JMenuBar menuBar = new JMenuBar();
|
||||||
|
setJMenuBar(menuBar);
|
||||||
|
|
||||||
|
JMenu mnNewMenu = new JMenu("New menu");
|
||||||
|
menuBar.add(mnNewMenu);
|
||||||
|
|
||||||
|
JMenuItem mntmNewMenuItem = new JMenuItem("New menu item");
|
||||||
|
mnNewMenu.add(mntmNewMenuItem);
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user