/** * Aware-P Epanet application entry point * * @param args * @throws UnsupportedLookAndFeelException */ public static void main(String[] args) throws UnsupportedLookAndFeelException { if (Utilities.isMac()) { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Aware-P Epanet"); Application app = Application.getApplication(); app.setDockIconImage( Toolkit.getDefaultToolkit().getImage(EpanetUI.class.getResource("/uiresources/ae.png"))); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); openAction = new JMenuItem("Open"); saveAction = new JMenuItem("Save"); runAction = new JMenuItem("Run"); fileMenu.add(openAction); fileMenu.add(saveAction); fileMenu.add(runAction); app.setDefaultMenuBar(menuBar); } UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); new EpanetUI(); }
static JComponent createMenuComponent(JComponent menu, ActionMap actionMap, List actions) { MenuAdapter menuAdapter = new MenuAdapter(menu); for (Object menuElement : actions) { if (MenuFactory.SEPARATOR.equals(menuElement)) { menuAdapter.addSeparator(); } else if (menuElement instanceof Object[]) { Object[] items = (Object[]) menuElement; if (items.length > 1) { JMenu subMenu = new JMenu(items[0].toString()); List<Object> keys = Arrays.asList(items).subList(1, items.length); createMenuComponent(subMenu, actionMap, keys); if (subMenu.getMenuComponents().length > 0) { menuAdapter.addSubMenu(subMenu); } } } else if (menuElement instanceof List) { List items = (List) menuElement; if (items.size() > 1) { JMenu subMenu = new JMenu(items.get(0).toString()); List<List> keys = Arrays.asList(items).subList(1, items.size()); createMenuComponent(subMenu, actionMap, keys); if (subMenu.getMenuComponents().length > 0) { menuAdapter.addSubMenu(subMenu); } } } else { Action action = actionMap.get(menuElement); if (action != null) { menuAdapter.add(action); } } } return trim(menuAdapter); }
protected JMenu buildFileMenu() { JMenu file = new JMenu("File"); JMenuItem newWin = new JMenuItem("New"); JMenuItem open = new JMenuItem("Open"); JMenuItem quit = new JMenuItem("Quit"); newWin.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { newDocument(); } }); open.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { openDocument(); } }); quit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { quit(); } }); file.add(newWin); file.add(open); file.addSeparator(); file.add(quit); return file; }
/* constructor * Create a frame with JTextArea and a menubar * with a "File" dropdown menu. * * @param title: the title for the frame * @param whichFile: to indicate which load or save buuton */ public OpenFileDir(String title, String whichFile) { super(title); fileNo = whichFile; Container content_pane = getContentPane(); // Create a user interface. content_pane.setLayout(new BorderLayout()); // Use the helper method makeMenuItem // for making the menu items and registering // their listener. JMenu m = new JMenu("File"); // Modify task names to something relevant to // the particular program. m.add(fMenuLoad = makeMenuItem("Load")); m.add(fMenuSave = makeMenuItem("Save")); m.add(fMenuClose = makeMenuItem("Quit")); JMenuBar mb = new JMenuBar(); mb.add(m); setJMenuBar(mb); setSize(400, 200); } /* end of the constructor */
private void buildMenu() { fooMenu = new JMenu("File"); fooMenu.setMnemonic('F'); JMenuItem aboutItem = new JMenuItem("About..."); aboutItem.setMnemonic('A'); aboutItem.setEnabled(true); aboutItem.setIcon(new ImageIcon(this.getClass().getResource("/comment.png"))); aboutItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JLabel imageLabel = new JLabel(new ImageIcon(this.getClass().getResource("/solve_all_problems.gif"))); JOptionPane.showMessageDialog(null, imageLabel, "About", JOptionPane.PLAIN_MESSAGE); } }); JMenuItem exitItem = new JMenuItem("Exit"); exitItem.setMnemonic('x'); exitItem.setEnabled(true); exitItem.setIcon(new ImageIcon(this.getClass().getResource("/delete.png"))); exitItem.addActionListener(this); fooMenu.add(aboutItem); fooMenu.addSeparator(); fooMenu.add(exitItem); JMenuBar menuBar = new JMenuBar(); menuBar.add(fooMenu); setJMenuBar(menuBar); }
private void addToRecent(String s) { for (int i = 0; i < iMaxRecent; i++) { if (s.equals(sRecent[i])) { return; } } if (sRecent[iRecent] != null) { mRecent.remove(iRecent); } sRecent[iRecent] = s; if (s.length() > 43) { s = s.substring(0, 40) + "..."; } JMenuItem item = new JMenuItem(s); item.setActionCommand("#" + iRecent); item.addActionListener(this); mRecent.insert(item, iRecent); iRecent = (iRecent + 1) % iMaxRecent; }
private void addMenuItems(JMenu f, String m[]) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); for (int i = 0; i < m.length; i++) { if (m[i].equals("--")) { f.addSeparator(); } else if (m[i].equals("---")) { // (ulrivo): full size on screen with less than 640 width if (d.width >= 640) { f.addSeparator(); } else { return; } } else { JMenuItem item = new JMenuItem(m[i].substring(1)); char c = m[i].charAt(0); if (c != '-') { item.setMnemonic(c); } item.addActionListener(this); f.add(item); } } }
public MainUI() { super("Neato Burrito"); dLog.trace("In MainUI: " + MainUI.class.getCanonicalName()); this.setBounds(0, 0, 500, 500); Container container = getContentPane(); container.add(theDesktop); setJMenuBar(menubar); JMenu fileMenu = new JMenu("File"); JMenuItem exitItem = new JMenuItem("Exit"); exitItem.setMnemonic('X'); exitItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); fileMenu.add(exitItem); menubar.add(fileMenu); StatusUI statUI = new StatusUI(); statUI.setVisible(true); theDesktop.add(statUI); setDefaultCloseOperation(EXIT_ON_CLOSE); pack(); setVisible(true); }
/** * initialize the symbols menu * * @param m menu */ public void initSymbolsMenu(JMenu m) { m.removeAll(); for (int i = 0; i < glyphs.size(); i++) { final MetSymbol metSymbol = (MetSymbol) glyphs.get(i); JMenuItem mi = GuiUtils.makeMenuItem(metSymbol.getLabel(), this, "showProperties", metSymbol); mi.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { highlightedMetSymbol = null; StationModelCanvas.this.repaint(); } public void mouseReleased(MouseEvent e) { highlightedMetSymbol = null; StationModelCanvas.this.repaint(); } public void mouseEntered(MouseEvent e) { highlightedMetSymbol = metSymbol; StationModelCanvas.this.repaint(); } public void mouseExited(MouseEvent e) { highlightedMetSymbol = null; StationModelCanvas.this.repaint(); } }); m.add(mi); } }
/* * The following method creates the font menu * postcondition: returns the JMenu for the font menu. */ public JMenu createFontMenu() { JMenu menu = new JMenu(new String("Font")); menu.add(createFontNameMenu()); menu.add(createFontSizeMenu()); menu.add(createFontStyleMenu()); return menu; } // end createFontMenu method
/** * Add a menu item to a named menu * * @param topMenu the name of the menu to add to * @param menuItem the entry text for the item itself * @param action the action associated with the menu item * @param accelerator the keystroke accelerator to associate with the item */ protected void addMenuItemToMenu( String topMenu, String menuItem, final Action action, KeyStroke accelerator) { JMenuItem newItem = m_menuItemMap.get(menuItem); if (newItem != null) { throw new IllegalArgumentException("The menu item '" + menuItem + "' already exists!"); } newItem = new JMenuItem(menuItem); if (accelerator != null) { newItem.setAccelerator(accelerator); } newItem.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { action.actionPerformed(e); } }); JMenu topJ = m_menuMap.get(topMenu); if (topJ == null) { topJ = new JMenu(); topJ.setText(topMenu); m_menuMap.put(topMenu, topJ); } topJ.add(newItem); m_menuItemMap.put(menuItem, newItem); }
public static JMenu getMenu(String title) { JMenu component = new JMenu(title); component.setBackground(BACKGROUND_COLOR_MENU); component.setFont(FONT_TYPE_TXTA); return component; }
/** Return a menu for DesktopWindow and add a special listener. */ public static JMenu getCurrencyMenu(ActionListener listener) { JRadioButtonMenuItem menuItem; String defaultCurrency = Money.getCurrencyFor(Money.getDefaultCurrency()); JMenu menu = new JMenu("Währung"); ButtonGroup group = new ButtonGroup(); JMenu europeanMenu = new JMenu("Europa"); String europeanCurrencies[] = Money.getEuropeanCurrencyList(); for (int i = 0; i < europeanCurrencies.length; i++) { menuItem = new RadioCurrencyMenuItem(europeanCurrencies[i]); menuItem.addActionListener(listener); europeanMenu.add(menuItem); group.add(menuItem); if (europeanCurrencies[i].startsWith(defaultCurrency)) { menuItem.setSelected(true); } if (i == 0) { europeanMenu.addSeparator(); } } menu.add(europeanMenu); return menu; }
private void enableAnalysis() { setAllEnabled(false); analysisMenu.setEnabled(true); // get info on state of analysis String scriptFile; Libgist.getAnalysisInfo(analysisInfo); // newAnalysisItem not enabled: can't create new profile, we just closed the index newAnalysisItem.setEnabled(false); openAnalysisItem.setEnabled(true); completeAnalysisItem.setEnabled(true); wkldStatsItem.setEnabled(analysisInfo.actualHasWkldStats); splitStatsItem.setEnabled(analysisInfo.actualHasSplitStats); penaltyStatsItem.setEnabled(analysisInfo.actualHasPenaltyStats); // general tree statistics are okay treeStatsMenu.setEnabled(true); utilItem.setEnabled(true); predSzItem.setEnabled(true); slotCntItem.setEnabled(true); // can always select another index or exit fileMenu.setEnabled(true); newItem.setEnabled(true); openItem.setEnabled(true); exitItem.setEnabled(true); }
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); }
@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 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()); } }); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddTopProject = new ActionAddTopProject(); if (container instanceof ICFInternetDomainBaseObj) { menuItem = new JMenuItem(actionAddTopProject); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionTopProject(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionTopProject(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionTopProject(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
/** * Creates the theme menu * * @return the theme menu */ private JMenu createThemeMenu() { JMenu themeMenu = new JMenu("Theme"); ButtonGroup buttonGroup = new ButtonGroup(); // Create a menu item for all themes for (int i = 0; i < themes.length; i++) { JMenuItem themeItem = new JRadioButtonMenuItem(themes[i].getName()); buttonGroup.add(themeItem); final int k = i; themeItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // Apply the selected theme applyTheme(themes[k]); } }); themeMenu.add(themeItem); // Set the first item (default theme) to be selected themeItem.setSelected(i == 0); } return themeMenu; }
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); } } } } }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddSecGroupMember = new ActionAddSecGroupMember(); if (container instanceof ICFSecuritySecGroupObj) { menuItem = new JMenuItem(actionAddSecGroupMember); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
/** * Make the edit menu * * @param editMenu edit menu * @return edit menu */ public JMenu makeEditMenu(JMenu editMenu) { editMenu.add(GuiUtils.makeDynamicMenu("Symbols", this, "initSymbolsMenu")); editMenu.add( GuiUtils.makeMenuItem("Set properties on selected", this, "setPropertiesOnSelected")); editMenu.addSeparator(); return super.makeEditMenu(editMenu); }
void initControls() { JMenuItem jmi; jmi = new JMenuItem("JImage Menu"); jmi.setEnabled(false); popupMenu.add(jmi); jmi = new JMenuItem("Fit"); jmi.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fit = true; repaint(); } }); popupMenu.add(jmi); JMenu scaleMenu = new JMenu("Set Scale"); popupMenu.add(scaleMenu); int scales[] = new int[] {25, 50, 100, 200, 400, 800}; for (int i = 0; i < scales.length; i++) { jmi = new JMenuItem(scales[i] + " %"); jmi.addActionListener(new ScaleAction(scales[i])); scaleMenu.add(jmi); } MyListener l = new MyListener(); addMouseMotionListener(l); addMouseListener(l); addMouseWheelListener(l); addKeyListener(l); }
/** Create menus */ private JMenuBar createMenus() { JMenuItem mi; // ***** create the menubar **** menuBar = new JMenuBar(); // ***** create File menu fileMenu = (JMenu) menuBar.add(new JMenu("File")); fileMenu.setMnemonic('F'); createMenuItem(fileMenu, "Print", 'P', "", new PrintAction(this)); createMenuItem(fileMenu, "Close", 'C', "", new CloseAction(this)); fileMenu.add(new JSeparator()); createMenuItem(fileMenu, "Exit", 'E', "", new ExitAction()); // ***** create laf switcher menu lafMenu = (JMenu) menuBar.add(new JMenu("Look & Feel")); lafMenu.setMnemonic('L'); mi = createLafMenuItem(lafMenu, "Java Look & Feel", 'J', "", metal); mi.setSelected(true); // this is the default l&f metalMenuItem = mi; createLafMenuItem(lafMenu, "Macintosh Look & Feel", 'M', "", mac); createLafMenuItem(lafMenu, "Motif Look & Feel", 'F', "", motif); createLafMenuItem(lafMenu, "Windows Look & Feel", 'W', "", windows); // ***** create themes menu themesMenu = (JMenu) menuBar.add(new JMenu("Themes")); themesMenu.setMnemonic('T'); mi = createThemesMenuItem(themesMenu, "Default", 'D', "", new DefaultMetalTheme()); mi.setSelected(true); // This is the default theme createThemesMenuItem(themesMenu, "Aqua", 'A', "", new AquaTheme()); createThemesMenuItem(themesMenu, "Charcoal", 'C', "", new CharcoalTheme()); createThemesMenuItem(themesMenu, "High Contrast", 'H', "", new ContrastTheme()); createThemesMenuItem(themesMenu, "Emerald", 'E', "", new EmeraldTheme()); createThemesMenuItem(themesMenu, "Ruby", 'R', "", new RubyTheme()); createThemesMenuItem(themesMenu, "Presentation", 'P', "", new DemoMetalTheme()); createThemesMenuItem(themesMenu, "Sandstone", 'S', "", new KhakiMetalTheme()); createThemesMenuItem(themesMenu, "Big High Contrast", 'I', "", new BigContrastMetalTheme()); createThemesMenuItem(themesMenu, "Blue", 'B', "", new BlueTheme()); createThemesMenuItem(themesMenu, "Cougaar", 'O', "", new CougaarTheme()); createThemesMenuItem( themesMenu, "Cougaar Presentation", 'O', "", new CougaarPresentationTheme()); return menuBar; }
/** Initializes the core phone objects. */ private void initializePhone() { // Load Preferences loadPreferences(); if (preferences == null) { return; } guiManager = new GuiManager(); guiManager.addUserActionListener(this); logManager = new LogManagerImpl(this); this.getLogManager().setRemoteLogging(true); try { EventQueue.invokeAndWait( new Runnable() { @Override public void run() { registerMenu = new JCheckBoxMenuItem(PhoneRes.getIString("phone.enabled")); } }); } catch (Exception e) { Log.error(e); } registerMenu.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { if (getStatus() == SipRegisterStatus.Unregistered || getStatus() == SipRegisterStatus.RegistrationFailed) { register(); } else { handleUnregisterRequest(); } } }); SIPConfig.setPreferredNetworkAddress(preferences.getPreferredAddress()); NetworkAddressManager.start(); try { EventQueue.invokeAndWait( new Runnable() { @Override public void run() { // Initialize Missed calls missedCalls = new MissedCalls(); } }); } catch (Exception e) { Log.error(e); } final JMenu actionsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.actions")); actionsMenu.add(registerMenu); }
/* * Frame Constructor */ public EvalGUI() { // map image Image img = null; try { img = ImageIO.read(new File("map2.png")); } catch (IOException e) { } img = img.getScaledInstance(300, 300, Image.SCALE_SMOOTH); JLabel small_img = new JLabel(new ImageIcon(img)); getContentPane().setLayout(new BorderLayout()); Right_Panel.add(Statistics_Panel, BorderLayout.CENTER); Statistics_Panel.add(dist_title); Statistics_Panel.add(totaldistance); Statistics_Panel.add(dist_curr_obj); Statistics_Panel.add(dist_charge); Statistics_Panel.add(clean_title); Statistics_Panel.add(space_covered); Statistics_Panel.add(room_covered); Statistics_Panel.add(charge_visits); Statistics_Panel.add(battery_title); Statistics_Panel.add(batt_remaining); Statistics_Panel.add(coverage_title); Statistics_Panel.add(nr_coverage_divisions); Statistics_Panel.add(vert_hor_div); Statistics_Panel.add(rob_coord); Statistics_Panel.add(time_elapsed); Statistics_Panel.add(time_completion); Right_Panel.add(small_img, BorderLayout.SOUTH); add(Right_Panel, BorderLayout.EAST); add(Map_Panel, BorderLayout.WEST); // menu items menubar.add(file); menubar.add(options); menubar.add(exit); file.add(newmap); options.add(measure); options.add(speed); exit.add(exit_); setJMenuBar(menubar); // frame operations setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(860, 650); setTitle("EvaluationGUI"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // pack(); }
/* * The following method creates the submenu to choose a font style * postcondition: returns the JMenu for the font style submenu. */ public JMenu createFontStyleMenu() { JMenu menu = new JMenu(new String("Style")); menu.add(createFontStyleItem(new String("Plain"))); menu.add(createFontStyleItem(new String("Italic"))); menu.add(createFontStyleItem(new String("Bold"))); menu.add(createFontStyleItem(new String("Bold Italic"))); return menu; } // end createFontStyleMenu method
private JMenu addMenu( JMenuBar menuBar, String label, int mnemonic, String accessibleDescription) { JMenu menu = new JMenu(label); menu.setMnemonic(mnemonic); menu.getAccessibleContext().setAccessibleDescription(accessibleDescription); menuBar.add(menu); return menu; }
/** * _more_ * * @param symbols _more_ * @param listener _more_ * @param smm _more_ * @return _more_ */ public static List makeStationModelMenuItems( List symbols, final ObjectListener listener, StationModelManager smm) { List items = new ArrayList(); List subMenus = new ArrayList(); Hashtable categories = new Hashtable(); for (int i = 0; i < symbols.size(); i++) { StationModel sm = (StationModel) symbols.get(i); boolean isUsers = smm.isUsers(sm); String name = sm.getName(); if (name.equals("")) continue; List toks = StringUtil.split(name, ">", true, true); if (toks.size() > 0) { name = (String) toks.get(toks.size() - 1); } JMenuItem item = new JMenuItem(GuiUtils.getLocalName(name, isUsers)); item.addActionListener( new ObjectListener(sm) { public void actionPerformed(ActionEvent ae) { listener.setObject(this.theObject); listener.actionPerformed(ae); } }); toks.remove(toks.size() - 1); if (toks.size() == 0) { items.add(item); continue; } JMenu categoryMenu = null; String catSoFar = ""; String menuCategory = ""; for (int catIdx = 0; catIdx < toks.size(); catIdx++) { String subCat = (String) toks.get(catIdx); catSoFar = catSoFar + "/" + subCat; JMenu m = (JMenu) categories.get(catSoFar); if (m == null) { m = new JMenu(subCat); menuCategory = catSoFar; categories.put(catSoFar, m); if (categoryMenu != null) { categoryMenu.add(m, 0); } else { subMenus.add(m); } } categoryMenu = m; } if (categoryMenu == null) { categoryMenu = new JMenu(""); categories.put(toks.toString(), categoryMenu); subMenus.add(categoryMenu); menuCategory = toks.toString(); } categoryMenu.add(item); } items.addAll(subMenus); return items; }
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); }