/** * 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); } }
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; }
@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; }
/** * 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); }
/* * 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
/* * 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
/** * _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; }
/* * The following method creates the submenu to choose a font size * postcondition: returns the JMenu for the font size submenu. */ public JMenu createFontSizeMenu() { JMenu menu = new JMenu(new String("Size")); menu.add(createFontSizeItem(SMALLEST)); menu.add(createFontSizeItem(SMALL)); menu.add(createFontSizeItem(SMALL_MEDIUM)); menu.add(createFontSizeItem(MEDIUM)); menu.add(createFontSizeItem(MEDIUM_LARGE)); menu.add(createFontSizeItem(LARGE)); menu.add(createFontSizeItem(LARGEST)); menu.add(createFontSizeItem(HUGE)); menu.add(createFontSizeItem(WOW)); return menu; } // end createFontSizeMenu method
/* * Creates the JMenuBar for the GUI. */ private JMenuBar menuBar() { menuBar = new JMenuBar(); menu = new JMenu("Menu"); load = new JMenuItem("Load..."); saveAs = new JMenuItem("Save As..."); load.addActionListener(new ActionListenerLoad()); saveAs.addActionListener(new ActionListenerSave()); // responseArea.addActionListener(new ActionListenerArea()); menu.add(load); menu.add(saveAs); menuBar.add(menu); return menuBar; }
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; }
/** * Create a menu for the app. By default this pulls the definition of the menu from the associated * resource file. */ protected JMenu createMenu(String key) { String[] itemKeys = SCSUtility.tokenize(getResourceString(key)); JMenu menu = new JMenu(getResourceString(key + "Label")); for (int i = 0; i < itemKeys.length; i++) { if (itemKeys[i].equals("-")) { menu.addSeparator(); } else { // System.out.println("Debug:TextViewer:itemkey: "+itemKeys[i]); JMenuItem mi = createMenuItem(itemKeys[i]); menu.add(mi); } } return menu; }
public void populateMenu(JMenu menu, int flags) { if (flags == (Plugin.MENU_TOOLS | Plugin.MENU_MID)) { Sketch sketch = editor.getSketch(); JMenuItem item = new JMenu("Program Bootloader"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { run(); } }); menu.add(item); PropertyFile props = sketch.mergeAllProperties(); String blProgs = props.get("bootloader.upload"); if (blProgs == null) { JMenuItem sub = new JMenuItem("No bootloader programmer defined!"); item.add(sub); return; } String[] progs = blProgs.split("::"); for (String prog : progs) { JMenuItem sub = new JMenuItem(sketch.parseString(props.get("upload." + prog + ".name"))); sub.setActionCommand(prog); sub.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { doProgram(e.getActionCommand()); } }); item.add(sub); } } }
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); } }
protected JMenu buildSpeedMenu() { JMenu speed = new JMenu("Drag"); JRadioButtonMenuItem live = new JRadioButtonMenuItem("Live"); JRadioButtonMenuItem outline = new JRadioButtonMenuItem("Outline"); JRadioButtonMenuItem slow = new JRadioButtonMenuItem("Old and Slow"); ButtonGroup group = new ButtonGroup(); group.add(live); group.add(outline); group.add(slow); live.setSelected(true); slow.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // for right now I'm saying if you set the mode // to something other than a specified mode // it will revert to the old way // This is mostly for comparison's sake desktop.setDragMode(-1); } }); live.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { desktop.setDragMode(JDesktopPane.LIVE_DRAG_MODE); } }); outline.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); } }); speed.add(live); speed.add(outline); speed.add(slow); return speed; }
/** * Make the view menu * * @param viewMenu view menu * @return The view menu */ public JMenu makeViewMenu(JMenu viewMenu) { showAlignmentPointsMI = new JCheckBoxMenuItem("Show Alignment Points", true); viewMenu.add(showAlignmentPointsMI); showAlignmentPointsMI.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { repaint(); } }); viewMenu.addSeparator(); super.makeViewMenu(viewMenu); viewMenu.addSeparator(); viewMenu.add(makeMenuItem("Black background", CMD_BLACKBG)); viewMenu.add(makeMenuItem("White background", CMD_WHITEBG)); return viewMenu; }
private void buildMenu() { jMenuBar = new javax.swing.JMenuBar(); mainMenu = new javax.swing.JMenu(); mainMenu.setText("Main"); loginMenuItem = new JMenuItem("Login..."); loginMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { headerPanel.handleLoginLogout(); } }); mainMenu.add(loginMenuItem); exitMenuItem = new JMenuItem("Exit"); exitMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { if (qsadminMain.isConnected() == true) { headerPanel.handleLoginLogout(); } System.exit(0); } }); mainMenu.add(exitMenuItem); helpMenu = new javax.swing.JMenu(); helpMenu.setText("Help"); aboutMenuItem = new JMenuItem("About..."); aboutMenuItem.setEnabled(true); aboutMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { about(); } }); helpMenu.add(aboutMenuItem); jMenuBar.add(mainMenu); jMenuBar.add(helpMenu); parentFrame.setJMenuBar(jMenuBar); }
/** Method to create the menu bar, menus, and menu items */ private void setUpMenuBar() { // create menu menuBar = new JMenuBar(); zoomMenu = new JMenu("Zoom"); twentyFive = new JMenuItem("25%"); fifty = new JMenuItem("50%"); seventyFive = new JMenuItem("75%"); hundred = new JMenuItem("100%"); hundred.setEnabled(false); hundredFifty = new JMenuItem("150%"); twoHundred = new JMenuItem("200%"); fiveHundred = new JMenuItem("500%"); // add the action listeners twentyFive.addActionListener(this); fifty.addActionListener(this); seventyFive.addActionListener(this); hundred.addActionListener(this); hundredFifty.addActionListener(this); twoHundred.addActionListener(this); fiveHundred.addActionListener(this); // add the menu items to the menus zoomMenu.add(twentyFive); zoomMenu.add(fifty); zoomMenu.add(seventyFive); zoomMenu.add(hundred); zoomMenu.add(hundredFifty); zoomMenu.add(twoHundred); zoomMenu.add(fiveHundred); menuBar.add(zoomMenu); // set the menu bar to this menu pictureFrame.setJMenuBar(menuBar); }
protected JMenu buildViewsMenu() { JMenu views = new JMenu("Views"); JMenuItem inBox = new JMenuItem("Open In-Box"); JMenuItem outBox = new JMenuItem("Open Out-Box"); outBox.setEnabled(false); inBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { openInBox(); } }); views.add(inBox); views.add(outBox); return views; }
public void actionPerformed(ActionEvent ev) { JComponent src = (JComponent) ev.getSource(); if (src == saveAsMI) { saveAs(); } else { int index = timeRangeMenu.getPopupMenu().getComponentIndex(src); setViewRange(rangeValues[index]); } }
/** * Add the menus into the menu bar * * @param menuBar The menu bar */ public void initMenuBar(JMenuBar menuBar) { stationModelMenu = new JMenu("Layout Models"); stationModelMenu.addMenuListener( new MenuListener() { public void menuCanceled(MenuEvent e) {} public void menuDeselected(MenuEvent e) {} public void menuSelected(MenuEvent e) { makeStationModelMenu(); } }); fileMenu = new JMenu("File"); fileMenu.addMenuListener( new MenuListener() { public void menuCanceled(MenuEvent e) {} public void menuDeselected(MenuEvent e) {} public void menuSelected(MenuEvent e) { makeFileMenu(); } }); menuBar.add(fileMenu); super.initMenuBar(menuBar); menuBar.add(stationModelMenu); JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Layout Models"); helpMenu.add(helpMenuItem); helpMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { showHelp(); } }); menuBar.add(helpMenu); }
protected JMenu buildHelpMenu() { JMenu help = new JMenu("Help"); JMenuItem about = new JMenuItem("About Metalworks..."); JMenuItem openHelp = new JMenuItem("Open Help Window"); about.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { showAboutBox(); } }); openHelp.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { openHelpWindow(); } }); help.add(about); help.add(openHelp); return help; }
/** Make the view menu */ private void makeStationModelMenu() { stationModelMenu.removeAll(); List symbols = smm.getResources(); List items = new ArrayList(); ObjectListener listener = new ObjectListener(null) { public void actionPerformed(ActionEvent ae) { if (!okToChange()) { return; } setStationModel((StationModel) theObject, true); } }; GuiUtils.makeMenu(stationModelMenu, makeStationModelMenuItems(symbols, listener, smm)); }
public void addPictureGenerator(JMenu menu, final PictureGenerator gen) { JMenuItem item = new JMenuItem(gen.getMenuName()); menu.add(item); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { pic2 = gen.picture(); pic1 = new Picture(pic2.width(), pic2.height()); lab.setIcon(pic2.getJLabel().getIcon()); sliderPanel.setVisible(false); pack(); repaint(); } }); }
public void addFilter(JMenu menu, final ImageFilter f) { JMenuItem item = new JMenuItem(f.getMenuName()); menu.add(item); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { swapImages(); f.apply(pic1, pic2); lab.setIcon(pic2.getJLabel().getIcon()); sliderPanel.setVisible(false); pack(); repaint(); } }); }
public void addScalableFilter(JMenu menu, final ScalableFilter f) { JMenuItem item = new JMenuItem(f.getMenuName()); menu.add(item); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { swapImages(); currentFilter = f; slider.setValue(50); sliderPanel.setVisible(true); border.setTitle(f.getMenuName()); pack(); repaint(); } }); }
public Popup() { super(); String[] profileNames = profiles.getNames(); JMenuItem item; // Make the load menu JMenu loadMenu = new JMenu("Load profile"); loadMenu.setEnabled(profiles.size() > 0); addProfiles(loadMenu, profileNames, profileLoader); this.add(loadMenu); this.addSeparator(); // put in a dummy item item = new JMenuItem(); item.setEnabled(false); this.add(item); this.addSeparator(); // Make the save menu JMenu saveMenu = new JMenu("Save profile"); item = new JMenuItem("New..."); item.addActionListener(profileSaver); saveMenu.add(item); saveMenu.addSeparator(); addProfiles(saveMenu, profileNames, profileSaver); this.add(saveMenu); this.addSeparator(); // put in a dummy item item = new JMenuItem(); item.setEnabled(false); this.add(item); this.addSeparator(); // Make the delete menu JMenu deleteMenu = new JMenu("Delete profile"); deleteMenu.setEnabled(profiles.size() > 0); addProfiles(deleteMenu, profileNames, profileDeleter); this.add(deleteMenu); }
private JMenuBar buildMenuBar() { // This function builds the menu bar JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(makeMenuItem("New")); fileMenu.add(makeMenuItem("Open")); fileMenu.addSeparator(); fileMenu.add(makeMenuItem("Save")); fileMenu.add(makeMenuItem("Save As")); fileMenu.addSeparator(); fileMenu.add(makeMenuItem("Exit")); menuBar.add(fileMenu); // edit menu JMenu editMenu = new JMenu("Edit"); editMenu.add(makeMenuItem(cutAction)); editMenu.add(makeMenuItem(copyAction)); editMenu.add(makeMenuItem(pasteAction)); menuBar.add(editMenu); return menuBar; }
public LibGui() { // menu bar and menu item initialization menu = new JMenuBar(); m1 = new JMenu("Options"); m2 = new JMenu("Programs"); m3 = new JMenu("Help"); AddNew = new JMenuItem("AddNew"); Search = new JMenuItem("Search"); Display = new JMenuItem("Display"); Delete = new JMenuItem("Delete"); Modify = new JMenuItem("Modify"); Exit = new JMenuItem("Exit"); Help = new JMenuItem("Help"); // text area initialization tac = new JTextArea(2, 3); tac.setText("For: Birgang Institute of Technology" + " " + "Birganj,Parsa "); tac.setForeground(Color.red); tac.setEditable(false); // button intialization btnAddNew = new JButton("ADDNEW"); btnAddNew.setToolTipText("Add new Details"); btnSearch = new JButton("SEARCH"); btnSearch.setToolTipText("Search particular student"); btnDelete = new JButton("DELETE"); btnDelete.setToolTipText("Delete particular student"); btnDisplay = new JButton("DISPLAY"); btnDisplay.setToolTipText("Display particular student"); btnModify = new JButton("MODIFY"); btnModify.setToolTipText("Modifies particular student"); btnExit = new JButton("EXIT"); btnExit.setToolTipText("Out of Program"); // initialization panel pMain = new JPanel(); pNorth = new JPanel(); pSouth = new JPanel(); pCenter = new JPanel(); lbllogo = new JLabel(new ImageIcon("//G:/MFCfinish.gif"), JLabel.CENTER); // add menuitem to menu m1.add(AddNew); m1.add(Search); m1.add(Display); m1.add(Delete); m1.add(Modify); m2.add(Exit); m3.add(Help); menu.add(m1); menu.add(m2); menu.add(m3); pMain.add(btnAddNew); pMain.add(btnSearch); pMain.add(btnDelete); pMain.add(btnDisplay); pMain.add(btnModify); pMain.add(btnExit); pMain.setLayout(new BoxLayout(pMain, BoxLayout.Y_AXIS)); pMain.setBorder(BorderFactory.createTitledBorder("OPTIONS")); pMain.setLayout(new GridLayout(6, 1)); pMain.setBackground(Color.white); pCenter.setBackground(Color.red); pCenter.setLayout(new BoxLayout(pMain, BoxLayout.Y_AXIS)); pCenter.setLayout(new GridLayout(2, 1)); pCenter.add(lbllogo); pCenter.add(tac); pNorth.setBackground(Color.white); pNorth.add(menu); this.getContentPane().add(pMain, "West"); this.getContentPane().add(pCenter, "Center"); this.getContentPane().add(pNorth, "North"); this.setSize(400, 300); this.setResizable(false); this.setLocation(150, 150); this.setTitle("MENU"); this.show(); }
/** Creates the GUI. */ public void majorLayout() { // // Setup Menu // JMenuBar menuBar = new JMenuBar(); JMenu file = new JMenu(ResourceHandler.getMessage("menu.file")); file.setMnemonic(ResourceHandler.getAcceleratorKey("menu.file")); file.add(exitMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.exit"))); exitMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.exit")); exitMenuItem.addActionListener(this); menuBar.add(file); JMenu edit = new JMenu(ResourceHandler.getMessage("menu.edit")); edit.setMnemonic(ResourceHandler.getAcceleratorKey("menu.edit")); edit.add(optionMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.option"))); optionMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.option")); optionMenuItem.addActionListener(this); menuBar.add(edit); JMenu help = new JMenu(ResourceHandler.getMessage("menu.help")); help.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help")); help.add(helpMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.help"))); helpMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help")); help.add(new JSeparator()); help.add(aboutMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.about"))); aboutMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.about")); helpMenuItem.addActionListener(this); aboutMenuItem.addActionListener(this); menuBar.add(help); setJMenuBar(menuBar); // // Setup main GUI // dirLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel0")); dirTF = new JTextField(); dirBttn = new JButton(ResourceHandler.getMessage("button.browse.dir")); dirBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.dir")); matchingLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel1")); matchingTF = new JTextField(ResourceHandler.getMessage("converter_gui.lablel2")); recursiveCheckBox = new JCheckBox(ResourceHandler.getMessage("converter_gui.lablel3")); recursiveCheckBox.setMnemonic(ResourceHandler.getAcceleratorKey("converter_gui.lablel3")); backupLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel5")); backupTF = new JTextField(); backupBttn = new JButton(ResourceHandler.getMessage("button.browse.backup")); backupBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.backup")); templateLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel7")); templateCh = new TemplateFileChoice(); staticVersioningLabel = new JLabel(ResourceHandler.getMessage("static.versioning.label")); String version = System.getProperty("java.version"); if (version.indexOf("-") > 0) { version = version.substring(0, version.indexOf("-")); } int dotIndex = version.indexOf("."); dotIndex = version.indexOf(".", dotIndex + 1); String familyVersion = version.substring(0, dotIndex); MessageFormat formatter = new MessageFormat(ResourceHandler.getMessage("static.versioning.radio.button")); staticVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {version})); staticVersioningRadioButton.setMnemonic( ResourceHandler.getAcceleratorKey("static.versioning.radio.button")); formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.radio.button")); dynamicVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {familyVersion})); dynamicVersioningRadioButton.setMnemonic( ResourceHandler.getAcceleratorKey("dynamic.versioning.radio.button")); staticVersioningTextArea = new JTextArea(ResourceHandler.getMessage("static.versioning.text")); formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.text")); dynamicVersioningTextArea = new JTextArea(formatter.format(new Object[] {familyVersion})); ButtonGroup versioningButtonGroup = new ButtonGroup(); versioningButtonGroup.add(staticVersioningRadioButton); versioningButtonGroup.add(dynamicVersioningRadioButton); runBttn = new JButton(ResourceHandler.getMessage("button.convert")); runBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.convert")); recursiveCheckBox.setOpaque(false); staticVersioningRadioButton.setOpaque(false); dynamicVersioningRadioButton.setOpaque(false); staticVersioningTextArea.setEditable(false); staticVersioningTextArea.setLineWrap(true); staticVersioningTextArea.setWrapStyleWord(true); dynamicVersioningTextArea.setEditable(false); dynamicVersioningTextArea.setLineWrap(true); dynamicVersioningTextArea.setWrapStyleWord(true); staticVersioningPanel.setLayout(new BorderLayout()); staticVersioningPanel.add(staticVersioningTextArea, "Center"); staticVersioningPanel.setBorder(new LineBorder(Color.black)); dynamicVersioningPanel.setLayout(new BorderLayout()); dynamicVersioningPanel.add(dynamicVersioningTextArea, "Center"); dynamicVersioningPanel.setBorder(new LineBorder(Color.black)); if (converter.isStaticVersioning()) { staticVersioningRadioButton.setSelected(true); } else { dynamicVersioningRadioButton.setSelected(true); } addListeners(); final int buf = 10, // Buffer (between components and form) sp = 10, // Space between components vsp = 5, // Vertical space indent = 20; // Indent between form (left edge) and component GridBagConstraints gbc = new GridBagConstraints(); GridBagLayout gbl = new GridBagLayout(); getContentPane().setLayout(gbl); // // Setup top panel // GridBagLayout topLayout = new GridBagLayout(); JPanel topPanel = new JPanel(); topPanel.setOpaque(false); topPanel.setLayout(topLayout); topLayout.setConstraints( dirLabel, new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( dirTF, new GridBagConstraints( 1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( dirBttn, new GridBagConstraints( 2, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, sp, 0, 0), 0, 0)); topLayout.setConstraints( matchingLabel, new GridBagConstraints( 0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( matchingTF, new GridBagConstraints( 1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( recursiveCheckBox, new GridBagConstraints( 2, 1, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(vsp, 10, 0, 0), 0, 0)); topLayout.setConstraints( backupLabel, new GridBagConstraints( 0, 3, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( backupTF, new GridBagConstraints( 1, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( backupBttn, new GridBagConstraints( 2, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, sp, 0, 0), 0, 0)); topLayout.setConstraints( templateLabel, new GridBagConstraints( 0, 4, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( templateCh, new GridBagConstraints( 1, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( sep1, new GridBagConstraints( 0, 5, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0)); topLayout.setConstraints( staticVersioningLabel, new GridBagConstraints( 0, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( staticVersioningRadioButton, new GridBagConstraints( 0, 7, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(vsp, 10, 0, 0), 0, 0)); topLayout.setConstraints( staticVersioningPanel, new GridBagConstraints( 0, 8, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(vsp, 25, 10, 0), 0, 0)); topLayout.setConstraints( dynamicVersioningRadioButton, new GridBagConstraints( 0, 9, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(vsp, 10, 0, 0), 0, 0)); topLayout.setConstraints( dynamicVersioningPanel, new GridBagConstraints( 0, 10, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(vsp, 25, 0, 0), 0, 0)); topLayout.setConstraints( sep2, new GridBagConstraints( 0, 11, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 0, 10), 0, 0)); invisibleBttn = new JButton(); invisibleBttn.setVisible(false); topLayout.setConstraints( invisibleBttn, new GridBagConstraints( 2, 6, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, new Insets(indent, sp, 0, 0), 0, 0)); topPanel.add(dirLabel); topPanel.add(dirTF); topPanel.add(dirBttn); topPanel.add(matchingLabel); topPanel.add(matchingTF); topPanel.add(recursiveCheckBox); topPanel.add(backupLabel); topPanel.add(backupTF); topPanel.add(backupBttn); topPanel.add(templateLabel); topPanel.add(templateCh); topPanel.add(sep1); topPanel.add(staticVersioningLabel); topPanel.add(staticVersioningRadioButton); topPanel.add(staticVersioningPanel); topPanel.add(dynamicVersioningRadioButton); topPanel.add(dynamicVersioningPanel); topPanel.add(sep2); topPanel.add(invisibleBttn); // // Setup bottom panel // GridBagLayout buttomLayout = new GridBagLayout(); JPanel buttomPanel = new JPanel(); buttomPanel.setOpaque(false); buttomPanel.setLayout(buttomLayout); buttomLayout.setConstraints( runBttn, new GridBagConstraints( 3, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(sp, 0, 0, 0), 0, 0)); buttomPanel.add(runBttn); // // Setup main panel // GridBagLayout mainLayout = new GridBagLayout(); JPanel mainPanel = new JPanel(); mainPanel.setOpaque(false); mainPanel.setLayout(mainLayout); mainLayout.setConstraints( topPanel, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(buf, buf, 0, buf), 0, 0)); mainLayout.setConstraints( buttomPanel, new GridBagConstraints( 0, 1, 1, 1, 1, 1, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(0, buf, buf, buf), 0, 0)); mainPanel.add(topPanel); mainPanel.add(buttomPanel); Border border = BorderFactory.createEtchedBorder(); mainPanel.setBorder(border); GridBagLayout layout = new GridBagLayout(); getContentPane().setLayout(layout); layout.setConstraints( mainPanel, new GridBagConstraints( 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); getContentPane().add(mainPanel); pack(); setResizable(false); }
/* * The following method creates the submenu to choose a font name * postcondition: returns the JMenu for the font name submenu. */ public JMenu createFontNameMenu() { // YOU MUST ALTER THESE BASED ON YOUR SYSTEM JMenu menu = new JMenu(new String("Name")); menu.add(createFontNameItem(new String("Serif"))); menu.add(createFontNameItem(new String("Times"))); menu.add(createFontNameItem(new String("Agent Orange"))); menu.add(createFontNameItem(new String("Aldo's Nova"))); menu.add(createFontNameItem(new String("American Typewriter"))); menu.add(createFontNameItem(new String("American Typewriter Condensed"))); menu.add(createFontNameItem(new String("American Typewriter Light"))); menu.add(createFontNameItem(new String("Andale Mono"))); menu.add(createFontNameItem(new String("AntsyPants"))); menu.add(createFontNameItem(new String("Apple Chancery"))); menu.add(createFontNameItem(new String("Arial"))); menu.add(createFontNameItem(new String("Arial Black"))); menu.add(createFontNameItem(new String("Arial Narrow"))); menu.add(createFontNameItem(new String("Aristocrat LET"))); menu.add(createFontNameItem(new String("AstigamaTizm"))); menu.add(createFontNameItem(new String("BASEHEAD"))); menu.add(createFontNameItem(new String("Baskerville"))); menu.add(createFontNameItem(new String("BellBottom"))); menu.add(createFontNameItem(new String("Bertram LET"))); menu.add(createFontNameItem(new String("BiauKai"))); menu.add(createFontNameItem(new String("Bickley Script LET"))); menu.add(createFontNameItem(new String("Bite me"))); menu.add(createFontNameItem(new String("Bizarro"))); menu.add(createFontNameItem(new String("Bodoni Ornaments ITC TT"))); menu.add(createFontNameItem(new String("Calaveras"))); menu.add(createFontNameItem(new String("Capitals"))); menu.add(createFontNameItem(new String("Century Gothic"))); menu.add(createFontNameItem(new String("Chalkboard"))); menu.add(createFontNameItem(new String("Charcoal"))); menu.add(createFontNameItem(new String("Chicago"))); menu.add(createFontNameItem(new String("Cochin"))); menu.add(createFontNameItem(new String("Comic Sans MS"))); menu.add(createFontNameItem(new String("Copperplate"))); menu.add(createFontNameItem(new String("Courier"))); menu.add(createFontNameItem(new String("Courier New"))); menu.add(createFontNameItem(new String("Curlz MT"))); menu.add(createFontNameItem(new String("Didot"))); menu.add(createFontNameItem(new String("Edwardian Script ITC"))); menu.add(createFontNameItem(new String("Fang Song"))); menu.add(createFontNameItem(new String("Fortuna Dot"))); menu.add(createFontNameItem(new String("Futura"))); menu.add(createFontNameItem(new String("Gadget"))); menu.add(createFontNameItem(new String("Geeza Pro"))); menu.add(createFontNameItem(new String("Geneva"))); menu.add(createFontNameItem(new String("Georgia"))); menu.add(createFontNameItem(new String("Gill Sans"))); menu.add(createFontNameItem(new String("Gringo Nights"))); menu.add(createFontNameItem(new String("Hei"))); menu.add(createFontNameItem(new String("Helvetica"))); menu.add(createFontNameItem(new String("Herculanum"))); menu.add(createFontNameItem(new String("Hypmotizin"))); menu.add(createFontNameItem(new String("Impact"))); menu.add(createFontNameItem(new String("Jokerman LET"))); menu.add(createFontNameItem(new String("MadisonSquare"))); menu.add(createFontNameItem(new String("MammaGamma"))); menu.add(createFontNameItem(new String("Mathmos Original"))); menu.add(createFontNameItem(new String("MammaGamma"))); menu.add(createFontNameItem(new String("Marker Felt"))); menu.add(createFontNameItem(new String("MassiveHeadache3"))); menu.add(createFontNameItem(new String("Parry Hotter"))); return menu; } // end createFontNameMenu method