/** * Handles the <tt>ActionEvent</tt> when one of the menu items is selected. * * @param e the <tt>ActionEvent</tt> that notified us */ public void actionPerformed(ActionEvent e) { JMenuItem menuItem = (JMenuItem) e.getSource(); String itemText = menuItem.getName(); if (itemText.equalsIgnoreCase("myChatRooms")) { ChatRoomTableDialog.showChatRoomTableDialog(); } else if (itemText.equals("history")) { HistoryWindow history; HistoryWindowManager historyWindowManager = GuiActivator.getUIService().getHistoryWindowManager(); ChatPanel chatPanel = this.parentWindow.getCurrentChatPanel(); ChatSession chatSession = chatPanel.getChatSession(); if (historyWindowManager.containsHistoryWindowForContact(chatSession.getDescriptor())) { history = historyWindowManager.getHistoryWindowForContact(chatSession.getDescriptor()); if (history.getState() == JFrame.ICONIFIED) history.setState(JFrame.NORMAL); history.toFront(); } else { history = new HistoryWindow(chatPanel.getChatSession().getDescriptor()); history.setVisible(true); historyWindowManager.addHistoryWindowForContact(chatSession.getDescriptor(), history); } } else if (itemText.equalsIgnoreCase("close")) { this.parentWindow.setVisible(false); this.parentWindow.dispose(); } }
protected JMenu buildEditMenu() { JMenu edit = new JMenu("Edit"); JMenuItem undo = new JMenuItem("Undo"); JMenuItem copy = new JMenuItem("Copy"); JMenuItem cut = new JMenuItem("Cut"); JMenuItem paste = new JMenuItem("Paste"); JMenuItem prefs = new JMenuItem("Preferences..."); undo.setEnabled(false); copy.setEnabled(false); cut.setEnabled(false); paste.setEnabled(false); prefs.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { openPrefsWindow(); } }); edit.add(undo); edit.addSeparator(); edit.add(cut); edit.add(copy); edit.add(paste); edit.addSeparator(); edit.add(prefs); return edit; }
/** Shows popup with forward history entries */ private void showForwardHistory(MouseEvent e) { JPopupMenu forwardMenu = new JPopupMenu("Forward History"); if (historyModel == null) { return; } Locale locale = ((JHelp) getControl()).getModel().getHelpSet().getLocale(); Enumeration items = historyModel.getForwardHistory().elements(); JMenuItem mi = null; int index = historyModel.getIndex() + 1; // while(items.hasMoreElements()){ for (int i = 0; items.hasMoreElements(); i++) { HelpModelEvent item = (HelpModelEvent) items.nextElement(); if (item != null) { String title = item.getHistoryName(); if (title == null) { title = HelpUtilities.getString(locale, "history.unknownTitle"); } mi = new JMenuItem(title); // mi.setToolTipText(item.getURL().getPath()); mi.addActionListener(new HistoryActionListener(i + index)); forwardMenu.add(mi); } } // if(e.isPopupTrigger()) forwardMenu.show(e.getComponent(), e.getX(), e.getY()); }
protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) { JMenuItem b = (JMenuItem) c; ButtonModel model = b.getModel(); if (c.getParent() instanceof JMenuBar) { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor()); g.fillRect(x, y, w, h); } } else { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor()); g.fillRect(x, y, w, h); } else if (!AbstractLookAndFeel.getTheme().isMenuOpaque()) { Graphics2D g2D = (Graphics2D) g; Composite composite = g2D.getComposite(); AlphaComposite alpha = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha()); g2D.setComposite(alpha); g.setColor(AbstractLookAndFeel.getMenuBackgroundColor()); g.fillRect(x, y, w, h); g2D.setComposite(composite); } else { g.setColor(AbstractLookAndFeel.getMenuBackgroundColor()); g.fillRect(x, y, w, h); } } if (menuItem.isSelected() && menuItem.isArmed()) { g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor()); } else { g.setColor(AbstractLookAndFeel.getMenuForegroundColor()); } }
public void adjustListMenuBar() { JMenuItem menuItem; Action act; String itemLabel; boolean enableState; boolean inEditState; boolean allowAdds; ICFInternetTopProjectObj selectedObj = getSwingFocusAsTopProject(); CFJPanel.PanelMode mode = getPanelMode(); if (mode == CFJPanel.PanelMode.Edit) { inEditState = true; if (getSwingContainer() != null) { allowAdds = true; } else { allowAdds = false; } } else { inEditState = false; allowAdds = false; } if (selectedObj == null) { enableState = false; } else { enableState = true; } if (actionViewSelected != null) { actionViewSelected.setEnabled(enableState); } if (actionEditSelected != null) { actionEditSelected.setEnabled(inEditState && enableState); } if (actionDeleteSelected != null) { actionDeleteSelected.setEnabled(inEditState && enableState); } if (actionAddTopProject != null) { actionAddTopProject.setEnabled(allowAdds); } if (menuAdd != null) { menuAdd.setEnabled(allowAdds); } if (menuSelected != null) { menuSelected.setEnabled(enableState); int itemCount = menuSelected.getItemCount(); for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) { menuItem = menuSelected.getItem(itemIdx); act = menuItem.getAction(); if (act != null) { if (act == actionViewSelected) { menuItem.setEnabled(enableState); } else if (act == actionEditSelected) { menuItem.setEnabled(inEditState && enableState); } else if (act == actionDeleteSelected) { menuItem.setEnabled(inEditState && enableState); } } } } }
/* * The following method creates the font menu item to choose a font * size. * postcondition: returns the JMenuItem for the font menu item for * the font size. */ public JMenuItem createFontSizeItem(String size) { JMenuItem item = new JMenuItem(size); // This class is used to create a special ActionListener for this menu item class MenuItemListener implements ActionListener { private String size; public MenuItemListener(String s) { size = s; } public void actionPerformed(ActionEvent event) { // Set the size of the font // if(size.equals("Small")) // fontSize = SMALL; // else if(size.equals("Medium")) // fontSize = MEDIUM; // else if(size.equals("Large")) // fontSize = LARGE; fontSize = Integer.parseInt(size); sampleField.setFont(new Font(fontName, fontStyle, fontSize)); sampleField.repaint(); pack(); } } ActionListener listener = new MenuItemListener(size); item.addActionListener(listener); return item; } // end createFontSizeItem method
/** * Uses the main help menu, and adds a few extra options. If/when there's Android-specific * documentation, we'll switch to that. */ public JMenu buildHelpMenu() { JMenu menu = super.buildHelpMenu(); JMenuItem item; menu.addSeparator(); item = new JMenuItem("Processing for Android Wiki"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Platform.openURL("http://wiki.processing.org/w/Android"); } }); menu.add(item); item = new JMenuItem("Android Developer Site"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Platform.openURL("http://developer.android.com/"); } }); menu.add(item); return menu; }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { JMenuItem b = (JMenuItem) c; ButtonModel model = b.getModel(); g.translate(x, y); if (c.getParent() instanceof JMenuBar) { if (model.isArmed() || model.isSelected()) { g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawLine(0, 0, w - 2, 0); g.drawLine(0, 0, 0, h - 1); g.drawLine(w - 2, 2, w - 2, h - 1); g.setColor(MetalLookAndFeel.getPrimaryControlHighlight()); g.drawLine(w - 1, 1, w - 1, h - 1); g.setColor(MetalLookAndFeel.getMenuBackground()); g.drawLine(w - 1, 0, w - 1, 0); } } else { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); g.drawLine(0, 0, w - 1, 0); g.setColor(MetalLookAndFeel.getPrimaryControlHighlight()); g.drawLine(0, h - 1, w - 1, h - 1); } else { g.setColor(MetalLookAndFeel.getPrimaryControlHighlight()); g.drawLine(0, 0, 0, h - 1); } } g.translate(-x, -y); }
public static JMenuItem getMenuItem(String title) { JMenuItem component = new JMenuItem(title); component.setFont(FONT_TYPE_TXTA); return component; }
private static void constructMenu() { final JFrame lFrame = (JFrame) viewModel.get("window.frame"); final JMenuBar lMenuBar = new JMenuBar(); lFrame.setJMenuBar(lMenuBar); viewModel.put("menu", lMenuBar); final JMenu lFileMenu = new JMenu("File"); lFileMenu.setMnemonic(KeyEvent.VK_F); viewModel.put("menu.file", lFileMenu); lMenuBar.add(lFileMenu); final JMenuItem lExitItem = new JMenuItem((Action) viewModel.get("action.exit")); viewModel.put("menu.file.exit", lExitItem); lFileMenu.add(lExitItem); final JMenuItem lHelpMenu = new JMenu("Help"); lHelpMenu.setMnemonic(KeyEvent.VK_H); viewModel.put("menu.help", lHelpMenu); lMenuBar.add(lHelpMenu); final JMenuItem lHelpTopicsItem = new JMenuItem((Action) viewModel.get("action.help")); viewModel.put("menu.help.topics", lHelpTopicsItem); lHelpMenu.add(lHelpTopicsItem); final JMenuItem lAboutItem = new JMenuItem((Action) viewModel.get("action.about")); viewModel.put("menu.help.about", lAboutItem); lHelpMenu.add(lAboutItem); }
private void AddMenuItem(JMenu menu, ActionListener listener, String menutext, int commandID) { JMenuItem menuitem; menuitem = new MyMenuItem(menutext, commandID); menuitem.addActionListener(listener); menu.add(menuitem); }
private void createTreeStatsMenu() { treeStatsMenu = new JMenu("Tree Stats"); menuBar.add(treeStatsMenu); utilItem = new JMenuItem("Utilization"); treeStatsMenu.add(utilItem); utilItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Libgist.getWkldNodeStats(Libgist.NODEUTIL, 0, false); treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, utilItem.getText()); } }); slotCntItem = new JMenuItem("Slot Count"); treeStatsMenu.add(slotCntItem); slotCntItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Libgist.getWkldNodeStats(Libgist.SLOTCNT, 0, false); treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, slotCntItem.getText()); } }); predSzItem = new JMenuItem("Predicate Size"); treeStatsMenu.add(predSzItem); predSzItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Libgist.getWkldNodeStats(Libgist.PREDSIZE, 0, false); treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, predSzItem.getText()); } }); }
@Override public JPopupMenu getComponentPopupMenu() { if (popupMenu == null) { popupMenu = new JPopupMenu(Messages.CHART_COLON); timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU); timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU)); popupMenu.add(timeRangeMenu); menuRBs = new JRadioButtonMenuItem[rangeNames.length]; ButtonGroup rbGroup = new ButtonGroup(); for (int i = 0; i < rangeNames.length; i++) { menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]); rbGroup.add(menuRBs[i]); menuRBs[i].addActionListener(this); if (viewRange == rangeValues[i]) { menuRBs[i].setSelected(true); } timeRangeMenu.add(menuRBs[i]); } popupMenu.addSeparator(); saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM); saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM)); saveAsMI.addActionListener(this); popupMenu.add(saveAsMI); } return popupMenu; }
private void lisaaMenuItemLataa(JMenu menu) { JMenuItem lataa = new JMenuItem("Lataa"); LataaKuuntelija laKuuntelija = new LataaKuuntelija(frame, logiikka, kysymysKentta, infolaatikko); lataa.addActionListener(laKuuntelija); menu.add(lataa); }
public void actionPerformed(ActionEvent event) { JMenuItem source = (JMenuItem) (event.getSource()); for (GraphView v : gp.getGraphViewList()) { if (v.getMenuText().equals(source.getText())) { v.view(); repaint(); return; } } for (GraphDrawer d : gp.getGraphDrawerList()) { if (d.getMenuText().equals(source.getText())) { d.layout(); repaint(); return; } } for (GraphUtility u : gp.getGraphUtilityList()) { if (u.getMenuText().equals(source.getText())) { u.apply(); repaint(); return; } } for (GraphExperiment ge : gp.getGraphExperimentList()) { if (ge.getMenuText().equals(source.getText())) { ge.experiment(); repaint(); return; } } }
private JPanel createContentPane() { JPanel panel = new JPanel(); combo1 = new JComboBox<>(numData); panel.add(combo1); combo2 = new JComboBox<>(dayData); combo2.setEditable(true); panel.add(combo2); panel.setSize(300, 200); popupMenu = new JPopupMenu(); JMenuItem item; for (int i = 0; i < dayData.length; i++) { item = popupMenu.add(new JMenuItem(dayData[i], mnDayData[i])); item.addActionListener(this); } panel.addMouseListener(new PopupListener(popupMenu)); JTextField field = new JTextField("CTRL+down for Popup"); // CTRL-down will show the popup. field .getInputMap() .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP"); field.getActionMap().put("OPEN_POPUP", new PopupHandler()); panel.add(field); return panel; }
/** * Adds a Display menu to the menu bar. Overrides OSPFrame method. * * @return the display menu */ protected JMenu loadDisplayMenu() { JMenuBar menuBar = getJMenuBar(); if (menuBar == null) { return null; } JMenu menu = super.loadDisplayMenu(); translateItem = new JMenuItem(); translateItem.setText(ControlsRes.getString("OSPControl.Translate")); // $NON-NLS-1$ // changed by D Brown 2007-10-17 if (OSPRuntime.translator != null) { translateItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { OSPRuntime.translator.showProperties(model.getClass()); if (OSPRuntime.translator instanceof Hidable) ((Hidable) OSPRuntime.translator).setKeepHidden(false); OSPRuntime.translator.setVisible(true); } }); translateItem.setEnabled(OSPRuntime.isAuthorMode()); languageMenu.add(translateItem, 0); } // changed by D Brown 2006-09-10 if (languageMenu.getItemCount() > 1) languageMenu.insertSeparator(1); return menu; }
public void notifyGenomeServerReachable(boolean reachable) { if (loadFromServerMenuItem != null) { loadFromServerMenuItem.setEnabled(reachable); String tooltip = reachable ? LOAD_GENOME_SERVER_TOOLTIP : CANNOT_LOAD_GENOME_SERVER_TOOLTIP; loadFromServerMenuItem.setToolTipText(tooltip); } }
/* * The following method creates the font menu item to choose a font * style. * postcondition: returns the JMenuItem for the font menu item for * the font style. */ public JMenuItem createFontStyleItem(String style) { JMenuItem item = new JMenuItem(style); // This class is used to create a special ActionListener for this menu item class MenuItemListener implements ActionListener { private String style; public MenuItemListener(String s) { style = s; } public void actionPerformed(ActionEvent event) { // Set the size of the font if (style.equals("Plain")) fontStyle = Font.PLAIN; else if (style.equals("Italic")) fontStyle = Font.ITALIC; else if (style.equals("Bold")) fontStyle = Font.BOLD; else if (style.equals("Bold Italic")) fontStyle = Font.ITALIC | Font.BOLD; sampleField.setFont(new Font(fontName, fontStyle, fontSize)); sampleField.repaint(); pack(); } } ActionListener listener = new MenuItemListener(style); item.addActionListener(listener); return item; } // end createFontStyleItem method
/** * This function is called when an observable notify the AppFrame * * @param o an observable * @param arg the arg of the observable */ @Override public void update(Observable o, Object arg) { this.toolsMenuItems.clear(); this.tools.removeAll(); /* TODO: En 2 observers 1 pour ajouter 1 pour supprimer */ for (File f : this.pluginFinder.getFoundFiles()) { final Plugin plugin = this.createPlugin(f); JMenuItem toolsMenuItem = new JMenuItem(); toolsMenuItem.setText(plugin.getDescription()); toolsMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textArea.setText(plugin.doAction(textArea.getText())); } }); this.toolsMenuItems.add(toolsMenuItem); this.tools.add(toolsMenuItem); } }
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { if (menuItem.isOpaque()) { int w = menuItem.getWidth(); int h = menuItem.getHeight(); paintBackground(g, menuItem, 0, 0, w, h); } }
private void addProfiles(JMenu menu, String[] profileNames, ActionListener listener) { for (int i = 0; i < profileNames.length; i++) { JMenuItem item = new JMenuItem(profileNames[i]); item.addActionListener(listener); menu.add(item); } }
private void initializeGUI() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenuGroup = new JMenu("File"); JMenuItem fileExit = new JMenuItem("Exit"); fileExit.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { fileExit(); } }); setLayout( new FormLayout( "5px, 1px:grow, 1px:grow, 1px:grow, 1px:grow, 1px:grow, 5px", "25px, 1px:grow, 1px:grow, 5px")); fileMenuGroup.add(fileExit); menuBar.add(fileMenuGroup); add(menuBar, CC.xywh(2, 1, 5, 1)); pack(); Dimension size = new Dimension( VisualizationBase.WINDOW_SIZE.width + 17, VisualizationBase.WINDOW_SIZE.height + 94); setSize(size); }
public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JMenuItem) { JMenuItem item = (JMenuItem) e.getSource(); String name = item.getText(); profiles.delete(name); } }
private void initUI() { JMenuBar menubar = new JMenuBar(); ImageIcon icon = new ImageIcon("exit.png"); JMenu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); JMenuItem eMenuItem = new JMenuItem("Exit", icon); eMenuItem.setMnemonic(KeyEvent.VK_E); eMenuItem.setToolTipText("Exit application"); eMenuItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { System.exit(0); } }); file.add(eMenuItem); menubar.add(file); setJMenuBar(menubar); setTitle("Simple menu"); setSize(300, 200); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); }
void windowMenu_menuSelected(MenuEvent e) { // <<TODO:MAINTAINABILITY>> This algorithm is not robust. It assumes // the Window // menu has exactly one "regular" menu item (newWindowMenuItem). [Jon // Aquino] if (windowMenu.getItemCount() > 0 && windowMenu.getItem(0) != null && windowMenu .getItem(0) .getText() .equals(AbstractPlugIn.createName(CloneWindowPlugIn.class))) { JMenuItem newWindowMenuItem = windowMenu.getItem(0); windowMenu.removeAll(); windowMenu.add(newWindowMenuItem); windowMenu.addSeparator(); } else { // ezLink doesn't have a Clone Window menu [Jon Aquino] windowMenu.removeAll(); } // final TaskComponent[] frames = (TaskComponent[]) desktopPane.getAllFrames(); final JInternalFrame[] frames = desktopPane.getAllFrames(); for (int i = 0; i < frames.length; i++) { JMenuItem menuItem = new JMenuItem(); // Increase truncation threshold from 20 to 40, for eziLink [Jon // Aquino] menuItem.setText(GUIUtil.truncateString(frames[i].getTitle(), 40)); associate(menuItem, frames[i]); windowMenu.add(menuItem); } if (windowMenu.getItemCount() == 0) { // For ezLink [Jon Aquino] windowMenu.add(new JMenuItem("(No Windows)")); } }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { JMenuItem b = (JMenuItem) c; ButtonModel model = b.getModel(); Color borderColorLo = AbstractLookAndFeel.getFrameColor(); Color borderColorHi = ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40); if (c.getParent() instanceof JMenuBar) { if (model.isArmed() || model.isSelected()) { g.setColor(borderColorLo); g.drawLine(x, y, x + w - 1, y); g.drawLine(x, y, x, y + h - 1); g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1); g.setColor(borderColorHi); g.drawLine(x + 1, y + 1, x + w - 2, y + 1); g.drawLine(x + 1, y + 1, x + 1, y + h - 1); } } else { if (model.isArmed() || (c instanceof JMenu && model.isSelected())) { g.setColor(borderColorLo); g.drawLine(x, y, x + w - 1, y); g.drawLine(x, y + h - 1, x + w - 1, y + h - 1); g.setColor(borderColorHi); g.drawLine(x, y + 1, x + w - 2, y + 1); } } }
public ViewPanel(Node node, int renderType) { // Create render render = AppletModelManager.getInstance().createRender(node, renderType); Canvas canvas = render.getCanvas(); render.setName(name); canvas.setPreferredSize(new Dimension(300, 300)); canvas.setMinimumSize(new Dimension(100, 100)); this.add(canvas, BorderLayout.CENTER); // Create render properties dialog renderDialog = new RenderProperties(render); renderDialog.setVisible(false); // Create pop-up menu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Properties"); menuItem.addActionListener(this); popup.add(menuItem); // Add listener to components that can bring up popup menus. MouseListener popupListener = new PopupListener(); canvas.addMouseListener(popupListener); this.setMinimumSize(new Dimension(100, 100)); this.setPreferredSize(new Dimension(200, 200)); SparkApplet.getViewPanel().add(this); }
// todo: i hate the force enable, it destroys all the design... private static void registerPMenu( JPopupMenu mnu, final String id, final int index, final graphtea.platform.core.AbstractAction n, final boolean forceEnable) { JMenuItem item = new JMenuItem(id); mnu.add(item, index); mnu.validate(); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (forceEnable) { // Configuration conf = // n.getBlackBoard().getData(UIEventHandler.CONF); // conf.enableAction(n); if (n.isEnable()) { n.performAction("popup menu: " + id, null); } } else { n.performAction("popup menu: " + id, null); } } }); }
public void go() { frame = new JFrame("Quiz Card Player"); JPanel mainPanel = new JPanel(); Font bigFont = new Font("sanserif", Font.BOLD, 24); display = new JTextArea(10, 20); display.setFont(bigFont); display.setLineWrap(true); display.setEditable(false); JScrollPane qScroller = new JScrollPane(display); qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); nextButton = new JButton("Show Questions"); nextButton.addActionListener(new NextCardListener()); mainPanel.add(qScroller); mainPanel.add(nextButton); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem loadMenuItem = new JMenuItem("Load Card Set"); loadMenuItem.addActionListener(new OpenMenuListener()); fileMenu.add(loadMenuItem); menuBar.add(fileMenu); frame.setJMenuBar(menuBar); frame.getContentPane().add(BorderLayout.CENTER, mainPanel); frame.setSize(640, 500); frame.setVisible(true); }