/* 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 */
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddTextCol = new ActionAddTextCol(); if (container instanceof ICFDbTestTableObj) { menuItem = new JMenuItem(actionAddTextCol); menuAdd.add(menuItem); } actionAddTextType = new ActionAddTextType(); if (container instanceof ICFDbTestSchemaDefObj) { menuItem = new JMenuItem(actionAddTextType); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionTextDef(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionTextDef(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionTextDef(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddMajorVersion = new ActionAddMajorVersion(); if (container instanceof ICFInternetRealProjectObj) { menuItem = new JMenuItem(actionAddMajorVersion); menuAdd.add(menuItem); } actionAddMinorVersion = new ActionAddMinorVersion(); if (container instanceof ICFInternetMajorVersionObj) { menuItem = new JMenuItem(actionAddMinorVersion); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionVersion(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionVersion(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionVersion(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
protected JMenu makeFileMenu() { JMenu fileMenu = new JMenu("File"); fileMenu.add( new AbstractAction("Open/Count") { public void actionPerformed(ActionEvent ev) { doRead(); } }); fileMenu.add( new AbstractAction("Compress") { public void actionPerformed(ActionEvent ev) { doSave(); } }); fileMenu.add( new AbstractAction("Uncompress") { public void actionPerformed(ActionEvent ev) { doDecode(); } }); fileMenu.add( new AbstractAction("Quit") { public void actionPerformed(ActionEvent ev) { System.exit(0); } }); return fileMenu; }
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 void initPopupMenu() { super.initPopupMenu(); if (getPopupMenu() != null) { JMenu otherDataSourcesMenu = new JMenu("Other Data Sources"); getPopupMenu().add(otherDataSourcesMenu); JMenuItem mi; mi = new JMenuItem("Show Level Lists"); ShowLevelListAction showLevelList = new ShowLevelListAction("Show Level List"); mi.setAction(showLevelList); getPopupMenu().add(mi); mi = new JMenuItem("Add Level Lists"); AddLevelListAction addLevelList = new AddLevelListAction("Add Level List"); mi.setAction(addLevelList); getPopupMenu().add(mi); mi = new JMenuItem("OMIM"); mi.setActionCommand("goto OMIM"); otherDataSourcesMenu.add(mi); mi = new JMenuItem("PubMed"); mi.setActionCommand("goto PubMed"); otherDataSourcesMenu.add(mi); mi = new JMenuItem("NCI Thesaurus"); mi.setActionCommand("goto NCI Thesaurus Advice"); otherDataSourcesMenu.add(mi); otherDataSourcesMenu.setOpaque(true); getPopupMenu().setOpaque(true); getPopupMenu().setLightWeightPopupEnabled(true); } }
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 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); }
void makeMenu() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu(strings.getString("menu.file")); menuBar.add(fileMenu); JMenuItem menuItem; menuItem = new JMenuItem(strings.getString("menu.file.new")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { onNewFileClicked(); } }); fileMenu.add(menuItem); menuItem = new JMenuItem(strings.getString("menu.file.open")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { onOpenFileClicked(); } }); fileMenu.add(menuItem); menuItem = new JMenuItem(strings.getString("menu.file.save")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { onSaveFileClicked(); } }); fileMenu.add(menuItem); menuItem = new JMenuItem(strings.getString("menu.file.save_as")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { onSaveAsFileClicked(); } }); fileMenu.add(menuItem); menuItem = new JMenuItem(strings.getString("menu.file.exit")); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { closeWindow(); } }); fileMenu.add(menuItem); setJMenuBar(menuBar); }
/** * This method initializes gameMenu * * @return JMenu */ private JMenu getGameMenu() { if (gameMenu == null) { gameMenu = new JMenu(); gameMenu.add(getJMenuItem()); gameMenu.add(getJMenuItem3()); gameMenu.add(getJMenuItem2()); gameMenu.add(getJMenuItem1()); gameMenu.setText("Game"); gameMenu.setMnemonic(java.awt.event.KeyEvent.VK_G); } return gameMenu; }
/** * This method initializes jMenu * * @return JMenu */ private JMenu getJMenu() { if (jMenu == null) { jMenu = new JMenu(); jMenu.add(getJRadioButtonMenuItem()); jMenu.add(getJRadioButtonMenuItem1()); jMenu.setText("Theme"); jMenu.setMnemonic(java.awt.event.KeyEvent.VK_T); ButtonGroup bg = new ButtonGroup(); bg.add(getJRadioButtonMenuItem()); bg.add(getJRadioButtonMenuItem1()); } return jMenu; }
/* * 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; }
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 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 addMenuItem( JMenu menu, String label, int mnemonic, String accessibleDescription, String actionCallbackName) throws NoSuchMethodException { JMenuItem menuItem = new JMenuItem(label, mnemonic); menuItem .getAccessibleContext() .setAccessibleDescription((accessibleDescription != null) ? accessibleDescription : label); final Method callback = getClass().getMethod(actionCallbackName, new Class[] {ActionEvent.class}); menuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { callback.invoke(WordListScreen.this, new Object[] {e}); } catch (InvocationTargetException ex) { handleException(ex.getTargetException()); } catch (IllegalAccessException ex) { handleException(ex); } } }); menu.add(menuItem); }
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); } }
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); }
@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; }
/** 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; }
public SwingWorkerFrame() { chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(".")); textArea = new JTextArea(TEXT_ROWS, TEXT_COLUMNS); add(new JScrollPane(textArea)); statusLine = new JLabel(" "); add(statusLine, BorderLayout.SOUTH); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu menu = new JMenu("File"); menuBar.add(menu); openItem = new JMenuItem("Open"); menu.add(openItem); openItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { // show file chooser dialog int result = chooser.showOpenDialog(null); // if file selected, set it as icon of the label if (result == JFileChooser.APPROVE_OPTION) { textArea.setText(""); openItem.setEnabled(false); textReader = new TextReader(chooser.getSelectedFile()); textReader.execute(); cancelItem.setEnabled(true); } } }); cancelItem = new JMenuItem("Cancel"); menu.add(cancelItem); cancelItem.setEnabled(false); cancelItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { textReader.cancel(true); } }); pack(); }
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); }
public PhoneBookGUI(PhoneBook pb) { super("PhoneBook"); phoneBook = pb; setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); Locale.setDefault(new Locale("en")); /* To avoid hardcoded Swedish text on OptionPane dialogs */ UIManager.put("OptionPane.cancelButtonText", "Cancel"); setLayout(new BorderLayout()); JMenuBar menubar = new JMenuBar(); setJMenuBar(menubar); JMenu editMenu = new JMenu("Edit"); menubar.add(editMenu); editMenu.add(new AddMenu(phoneBook, this)); editMenu.add(new RemoveMenu(phoneBook, this)); JMenu findMenu = new JMenu("Find"); menubar.add(findMenu); findMenu.add(new FindNumbersMenu(phoneBook, this)); findMenu.add(new FindNamesMenu(phoneBook, this)); JMenu viewMenu = new JMenu("View"); menubar.add(viewMenu); viewMenu.add(new ShowAllMenu(phoneBook, this)); JPanel southPanel = new JPanel(); messageArea = new JTextArea(4, 25); messageArea.setEditable(false); southPanel.add(new JScrollPane(messageArea)); southPanel.add(new QuitButton(phoneBook)); add(southPanel, BorderLayout.CENTER); pack(); setVisible(true); String fileName = JOptionPane.showInputDialog("Enter file name"); if (fileName != null) { try { phoneBook.readFromFile(fileName); } catch (Exception e) { setText("No such file was found"); } } }
public static JMenu getJMenu() { JMenu menu = new JMenu("copy to DeploymentDiagram as ComponentInstance"); Project p = ProjectBrowser.TheInstance.getProject(); for (Iterator it = p.getDiagrams().iterator(); it.hasNext(); ) { Object d = it.next(); if (d instanceof UMLDeploymentDiagram) menu.add(new CopyAction((UMLDeploymentDiagram) d)); } return menu; }
public ShowComp() throws InterruptedException, IOException { super("CONNECTED COMPUTERS"); int x = 0, d = 20; mb = new JMenuBar(); File = new JMenu("File"); mb.add(File); exit = new JMenuItem("Exit"); exit.addActionListener(this); File.add(exit); ta = new JTextArea(); ta.setBounds(20, 30, 315, 470); ta.setEditable(false); add(ta); setJMenuBar(mb); sel = new JLabel("The connected computers are.."); sel.setBounds(15, 5, 300, 30); add(sel); b1 = new JButton("<< BACK"); b1.setBounds(140, 510, 100, 30); b1.setToolTipText("Back to main page"); b1.addActionListener(this); add(b1); setLayout(null); while (x < 360) { x = x + d; setBounds(675, 50, x, 600); this.show(); } // setVisible(true); String s = "192.168.0.", temp = null; Printer printer = new Printer(); printer.start(); Connector connector = new Connector(printer); connector.start(); LinkedList targets = new LinkedList(); for (int i = 1; i <= 255; i++) { temp = s + Integer.toString(i); Target t = new Target(temp); targets.add(t); connector.add(t); } Thread.sleep(2000); connector.shutdown(); connector.join(); for (Iterator i = targets.iterator(); i.hasNext(); ) { Target t = (Target) i.next(); if (!t.shown) t.show(); } setDefaultCloseOperation(DISPOSE_ON_CLOSE); }
/** Create the menu bar for the GUI */ private void createMenu() { // Create menu bar menuBar = new JMenuBar(); clientFrame.setJMenuBar(menuBar); // Create menus fileMenu = new JMenu("File"); helpMenu = new JMenu("Help"); // Add menus to bar menuBar.add(fileMenu); menuBar.add(helpMenu); // Create File Menu Items hostItem = new JCheckBoxMenuItem("Allow Uploads", true); portItem = new JCheckBoxMenuItem("Use Passive Mode", true); exitItem = new JMenuItem("Exit"); // Add Items to File Menu fileMenu.add(hostItem); fileMenu.add(portItem); fileMenu.addSeparator(); fileMenu.add(exitItem); // Create Help Menu Items helpItem = new JMenuItem("Help"); aboutItem = new JMenuItem("About LeetFTP"); // Add Items to Help Menu helpMenu.add(helpItem); helpMenu.addSeparator(); helpMenu.add(aboutItem); // Create menu action handler and set it active MenuHandler menuHandler = new MenuHandler(); hostItem.addActionListener(menuHandler); portItem.addActionListener(menuHandler); exitItem.addActionListener(menuHandler); helpItem.addActionListener(menuHandler); aboutItem.addActionListener(menuHandler); }
/** Creates a JRadioButtonMenuItem for the Look and Feel menu */ private JMenuItem createLafMenuItem( JMenu menu, String label, char mnemonic, String accessibleDescription, String laf) { JMenuItem mi = (JRadioButtonMenuItem) menu.add(new JRadioButtonMenuItem(label)); lafMenuGroup.add(mi); mi.setMnemonic(mnemonic); mi.getAccessibleContext().setAccessibleDescription(accessibleDescription); mi.addActionListener(new ChangeLookAndFeelAction(this, laf)); mi.setEnabled(isAvailableLookAndFeel(laf)); return mi; }
private void resetMarks() { interpToMark.removeAll(); shiftToMark.removeAll(); Iterator marks = mediator.getMarkerModel().getLabels().iterator(); boolean hasMark = false; while (marks.hasNext()) { String mark = (String) marks.next(); if (!ChronicleViewer.CURR_FRAME_LABEL.equals(mark)) { JMenuItem mi = new JMenuItem(mark); mi.addActionListener(itmAction); interpToMark.add(mi); mi = new JMenuItem(mark); mi.addActionListener(stmAction); shiftToMark.add(mi); hasMark = true; } } shiftToMark.setEnabled(hasMark); interpToMark.setEnabled(hasMark); }
private void createDebugMenu() { debugMenu = new JMenu("Debug"); menuBar.add(debugMenu); debugMenu.add(stepAction); debugMenu.add(nextAction); debugMenu.add(contAction); debugMenu.add(stopAction); traceAllItem = new JCheckBoxMenuItem("Trace All"); debugMenu.add(traceAllItem); debugMenu.addSeparator(); breakpointsItem = new JMenuItem("Breakpoints..."); debugMenu.add(breakpointsItem); breakpointsItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { Breakpoints.edit(); } }); Breakpoints.setParent(this); }
public void go() { // build gui frame = new JFrame("Quiz Card Buider"); JPanel mainPanel = new JPanel(); Font bigFont = new Font("sanserif", Font.BOLD, 24); question = new JTextArea(6, 20); question.setLineWrap(true); question.setWrapStyleWord(true); question.setFont(bigFont); JScrollPane qScroller = new JScrollPane(question); qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); answer = new JTextArea(6, 20); answer.setLineWrap(true); answer.setWrapStyleWord(true); answer.setFont(bigFont); JScrollPane aScroller = new JScrollPane(question); aScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); aScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JButton nextButton = new JButton("Next Card"); cardList = new ArrayList<QuizCard>(); JLabel qLabel = new JLabel("Question"); JLabel aLabel = new JLabel("Answer"); mainPanel.add(qLabel); mainPanel.add(qScroller); mainPanel.add(aLabel); mainPanel.add(aScroller); mainPanel.add(nextButton); nextButton.addActionListener(new NextCardListener()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem newMenuItem = new JMenuItem("New"); JMenuItem saveMenuItem = new JMenuItem("Save"); newMenuItem.addActionListener(new NewMenuListener()); saveMenuItem.addActionListener(new SaveMenuListener()); fileMenu.add(newMenuItem); fileMenu.add(saveMenuItem); menuBar.add(fileMenu); frame.setJMenuBar(menuBar); frame.getContentPane().add(BorderLayout.CENTER, mainPanel); frame.setSize(500, 600); frame.setVisible(true); // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
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); }