List of usage examples for javax.swing JCheckBoxMenuItem JCheckBoxMenuItem
public JCheckBoxMenuItem(Action a)
From source file:misc.ActionDemo.java
protected JMenu createAbleMenu() { JMenu ableMenu = new JMenu("Action State"); cbmi = new JCheckBoxMenuItem[3]; cbmi[0] = new JCheckBoxMenuItem("First action enabled"); cbmi[1] = new JCheckBoxMenuItem("Second action enabled"); cbmi[2] = new JCheckBoxMenuItem("Third action enabled"); for (int i = 0; i < cbmi.length; i++) { cbmi[i].setSelected(true);//from w w w. jav a2 s . com cbmi[i].addItemListener(this); ableMenu.add(cbmi[i]); } return ableMenu; }
From source file:MainFrame.MainFrame.java
public MainFrame() { //Create menu this.menuBar = new JMenuBar(); this.menuProxy = new JMenu("Proxy"); this.menuBar.add(menuProxy); this.cbMenuItem = new JCheckBoxMenuItem("? proxy"); this.cbMenuItem.setMnemonic(KeyEvent.VK_C); ActionListener aListener = new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); if (selected) { SingleDataHolder.getInstance().isProxyActivated = true; SingleDataHolder.getInstance().proxyIpAdress = MainFrame.this.proxyIpAdress.getText(); SingleDataHolder.getInstance().proxyPort = Integer.parseInt(MainFrame.this.proxyPort.getText()); SingleDataHolder.getInstance().proxyLogin = MainFrame.this.proxyLogin.getText(); SingleDataHolder.getInstance().proxyPassword = String .valueOf(MainFrame.this.proxyPassword.getPassword()); } else { SingleDataHolder.getInstance().isProxyActivated = false; }//from ww w . j a v a 2 s . c o m } }; this.cbMenuItem.addActionListener(aListener); this.proxyIpAdress = new JTextField(); this.proxyPort = new JTextField(); this.proxyLogin = new JTextField(); ; this.proxyPassword = new JPasswordField(); this.menuProxy.add(this.cbMenuItem); this.menuProxy.add(new JLabel("IP ?")); this.menuProxy.add(this.proxyIpAdress); this.menuProxy.add(new JLabel("? ")); this.menuProxy.add(this.proxyPort); this.menuProxy.add(new JLabel("")); this.menuProxy.add(this.proxyLogin); this.menuProxy.add(new JLabel("")); this.menuProxy.add(this.proxyPassword); this.setJMenuBar(this.menuBar); communicator = new HttpCommunicator(); myActionListener = new mainFrameActionListener(); mainPanel = new JPanel(new BorderLayout()); this.setContentPane(mainPanel); JPanel P = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 5)); mainPanel.add(P, BorderLayout.NORTH); //Create Group label labelGroup = new JLabel(""); P.add(labelGroup); //Create Group combo comboGroup = new JComboBox(); comboGroup.addItem("?"); comboGroup.addActionListener(myActionListener); P.add(comboGroup); //Create Date label labelDate = new JLabel(""); P.add(labelDate); //Create Date combo comboDate = new JComboBox(); comboDate.addItem("?"); comboDate.addActionListener(myActionListener); P.add(comboDate); //Create Delete button buttonDelete = new JButton(""); buttonDelete.setEnabled(false); buttonDelete.addActionListener(myActionListener); P.add(buttonDelete); //this.checkConnection = new CheckConnection(buttonDelete); buttonPasswordsManager = new JButton(" "); buttonPasswordsManager.addActionListener(myActionListener); P.add(buttonPasswordsManager); try { Image img = ImageIO.read(getClass().getResource("resources/table_refresh.png")); this.buttonRefresh = new JButton(new ImageIcon(img)); this.buttonRefresh.addActionListener(myActionListener); this.buttonRefresh.setToolTipText(" "); P.add(buttonRefresh); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } //CreateLessonTableModel lessonTableModel = new LessonTableModel(); try { communicator.setCombos(comboGroup, comboDate, lessonTableModel); } catch (IOException ex) { JOptionPane.showMessageDialog(null, " ? ? ."); Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } //CreateTable table = new JTable(lessonTableModel); table.setFillsViewportHeight(true); table.setAutoCreateRowSorter(true); JScrollPane scrollP = new JScrollPane(table); mainPanel.add(scrollP, BorderLayout.CENTER); //Create Table sorter sorter = new TableRowSorter<LessonTableModel>(lessonTableModel); table.setRowSorter(sorter); table.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int column = e.getColumn(); TableModel model = (TableModel) e.getSource(); for (int i = 0; i < model.getRowCount(); i++) { if ((boolean) model.getValueAt(i, 2) == true) { buttonDelete.setEnabled(true); return; } } buttonDelete.setEnabled(false); } }); //Standart block this.setSize(700, 400); this.setTitle(" "); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { System.exit(0); } }); try { Image img = ImageIO.read(getClass().getResource("resources/appIcon.png")); this.setIconImage(img); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } this.setVisible(true); }
From source file:com.mirth.connect.client.ui.components.MirthTable.java
private JPopupMenu getColumnMenu() { JPopupMenu columnMenu = new JPopupMenu(); DefaultTableModel model = (DefaultTableModel) getModel(); for (int i = 0; i < model.getColumnCount(); i++) { final String columnName = model.getColumnName(i); // Get the column object by name. Using an index may not return the column object if the column is hidden TableColumnExt column = getColumnExt(columnName); // Create the menu item final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(columnName); // Show or hide the checkbox menuItem.setSelected(column.isVisible()); menuItem.addActionListener(new ActionListener() { @Override//from ww w.j ava 2 s .c om public void actionPerformed(ActionEvent evt) { TableColumnExt column = getColumnExt(menuItem.getText()); // Determine whether to show or hide the selected column boolean enable = !column.isVisible(); // Do not hide a column if it is the last remaining visible column if (enable || getColumnCount() > 1) { column.setVisible(enable); saveColumnOrder(); } } }); columnMenu.add(menuItem); } columnMenu.addSeparator(); JMenuItem menuItem = new JMenuItem("Restore Default"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { restoreDefaultColumnPreferences(); } }); columnMenu.add(menuItem); return columnMenu; }
From source file:FillViewportHeightDemo.java
public FillViewportHeightDemo() { super("Empty Table DnD Demo"); tableModel = getDefaultTableModel(); table = new JTable(tableModel); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setDropMode(DropMode.INSERT_ROWS); table.setTransferHandler(new TransferHandler() { public boolean canImport(TransferSupport support) { // for the demo, we'll only support drops (not clipboard paste) if (!support.isDrop()) { return false; }// w w w. j a va 2s. c o m // we only import Strings if (!support.isDataFlavorSupported(DataFlavor.stringFlavor)) { return false; } return true; } public boolean importData(TransferSupport support) { // if we can't handle the import, say so if (!canImport(support)) { return false; } // fetch the drop location JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation(); int row = dl.getRow(); // fetch the data and bail if this fails String data; try { data = (String) support.getTransferable().getTransferData(DataFlavor.stringFlavor); } catch (UnsupportedFlavorException e) { return false; } catch (IOException e) { return false; } String[] rowData = data.split(","); tableModel.insertRow(row, rowData); Rectangle rect = table.getCellRect(row, 0, false); if (rect != null) { table.scrollRectToVisible(rect); } // demo stuff - remove for blog model.removeAllElements(); model.insertElementAt(getNextString(count++), 0); // end demo stuff return true; } }); JList dragFrom = new JList(model); dragFrom.setFocusable(false); dragFrom.setPrototypeCellValue(getNextString(100)); model.insertElementAt(getNextString(count++), 0); dragFrom.setDragEnabled(true); dragFrom.setBorder(BorderFactory.createLoweredBevelBorder()); dragFrom.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { if (SwingUtilities.isLeftMouseButton(me) && me.getClickCount() % 2 == 0) { String text = (String) model.getElementAt(0); String[] rowData = text.split(","); tableModel.insertRow(table.getRowCount(), rowData); model.removeAllElements(); model.insertElementAt(getNextString(count++), 0); } } }); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); JPanel wrap = new JPanel(); wrap.add(new JLabel("Drag from here:")); wrap.add(dragFrom); p.add(Box.createHorizontalStrut(4)); p.add(Box.createGlue()); p.add(wrap); p.add(Box.createGlue()); p.add(Box.createHorizontalStrut(4)); getContentPane().add(p, BorderLayout.NORTH); JScrollPane sp = new JScrollPane(table); getContentPane().add(sp, BorderLayout.CENTER); fillBox = new JCheckBoxMenuItem("Fill Viewport Height"); fillBox.addActionListener(this); JMenuBar mb = new JMenuBar(); JMenu options = new JMenu("Options"); mb.add(options); setJMenuBar(mb); JMenuItem clear = new JMenuItem("Reset"); clear.addActionListener(this); options.add(clear); options.add(fillBox); getContentPane().setPreferredSize(new Dimension(260, 180)); }
From source file:net.chaosserver.timelord.swingui.TimelordMenu.java
/** * Creates the view menu.//ww w . java 2 s. co m * * @return the new view menu */ protected JMenu createViewMenu() { JMenuItem menuItem; JMenu viewMenu = new JMenu("View"); viewMenu.setMnemonic(KeyEvent.VK_V); JMenu annoyanceModeMenu = new JMenu("Annoyance Mode"); annoyanceJordanCheckbox = new JCheckBoxMenuItem("Jordan Mode"); annoyanceJordanCheckbox.setToolTipText("For Cool People"); annoyanceJordanCheckbox.setActionCommand(ACTION_ANNOY_JORDAN); annoyanceJordanCheckbox.addActionListener(this); annoyanceModeMenu.add(annoyanceJordanCheckbox); annoyanceDougCheckbox = new JCheckBoxMenuItem("Doug Mode"); annoyanceDougCheckbox.setToolTipText("For Losers"); annoyanceJordanCheckbox.setActionCommand(ACTION_ANNOY_DOUG); annoyanceDougCheckbox.addActionListener(this); annoyanceModeMenu.add(annoyanceDougCheckbox); annoyanceNoneCheckbox = new JCheckBoxMenuItem("None"); annoyanceJordanCheckbox.setActionCommand(ACTION_ANNOY_NONE); annoyanceNoneCheckbox.addActionListener(this); annoyanceModeMenu.add(annoyanceNoneCheckbox); updateAnnoyanceButtons(); viewMenu.add(annoyanceModeMenu); menuItem = new JMenuItem("Refresh View", KeyEvent.VK_R); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem.setActionCommand(ACTION_REFRESH_VIEW); menuItem.addActionListener(this); viewMenu.add(menuItem); viewMenu.addSeparator(); menuItem = new JMenuItem("Change Start Time"); menuItem.setActionCommand(ACTION_CHANGE_START); menuItem.addActionListener(this); viewMenu.add(menuItem); menuItem = new JMenuItem("Change Annoy Time"); // currently disabled experimental functionality menuItem.setEnabled(false); menuItem.setActionCommand(ACTION_CHANGE_ANNOY); menuItem.addActionListener(this); viewMenu.add(menuItem); viewMenu.addSeparator(); menuItem = new JMenuItem("Select Previous Tab", KeyEvent.VK_BRACELEFT); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BRACELEFT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem.setActionCommand(ACTION_PREVIOUS_TAB); menuItem.addActionListener(this); viewMenu.add(menuItem); menuItem = new JMenuItem("Select Next Tab", KeyEvent.VK_BRACERIGHT); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BRACERIGHT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem.setActionCommand(ACTION_NEXT_TAB); menuItem.addActionListener(this); viewMenu.add(menuItem); return viewMenu; }
From source file:com.prodigy4440.view.MainJFrame.java
public final void initComponents() { List<Image> icons = new LinkedList<>(); icons.add(new ImageIcon(getClass().getResource("/com/prodigy4440/ited16x16.png")).getImage()); icons.add(new ImageIcon(getClass().getResource("/com/prodigy4440/ited32x32.png")).getImage()); icons.add(new ImageIcon(getClass().getResource("/com/prodigy4440/ited48x48.png")).getImage()); icons.add(new ImageIcon(getClass().getResource("/com/prodigy4440/ited72x72.png")).getImage()); this.setIconImages(icons); ActionHandler actionHandler = new ActionHandler(this); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(620, 520); this.setLocationRelativeTo(null); this.setTitle("Untitled Document- IgboTextEditor"); southJPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); SoftBevelBorder sbb = new SoftBevelBorder(SoftBevelBorder.LOWERED); southJPanel.setBorder(sbb);//ww w. j a va2 s . c o m menuBar = new JMenuBar(); fileJMenu = new JMenu("File"); fileJMenu.setMnemonic('F'); editJMenu = new JMenu("Edit"); editJMenu.setMnemonic('E'); formatJMenu = new JMenu("Format"); formatJMenu.setMnemonic('A'); viewJMenu = new JMenu("View"); viewJMenu.setMnemonic('V'); helpJMenu = new JMenu("Help"); helpJMenu.setMnemonic('H'); newDocumentJMenuItem = new JMenuItem("New"); newDocumentJMenuItem.addActionListener(actionHandler); newDocumentJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK)); openJMenuItem = new JMenuItem("Open"); openJMenuItem.addActionListener(actionHandler); openJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK)); saveJMenuItem = new JMenuItem("Save"); saveJMenuItem.addActionListener(actionHandler); saveJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)); printJMenuItem = new JMenuItem("Print"); printJMenuItem.addActionListener(actionHandler); printJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK)); exitJMenuItem = new JMenuItem("Exit"); exitJMenuItem.addActionListener(actionHandler); undoJMenuItem = new JMenuItem("Undo"); undoJMenuItem.addActionListener(actionHandler); undoJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK)); redoJMenuItem = new JMenuItem("Redo"); redoJMenuItem.addActionListener(actionHandler); redoJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, Event.CTRL_MASK)); copyJMenuItem = new JMenuItem("Copy"); copyJMenuItem.addActionListener(actionHandler); copyJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); cutJMenuItem = new JMenuItem("Cut"); cutJMenuItem.addActionListener(actionHandler); cutJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK)); pasteJMenuItem = new JMenuItem("Paste"); pasteJMenuItem.addActionListener(actionHandler); pasteJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK)); deleteJMenuItem = new JMenuItem("Delete"); deleteJMenuItem.addActionListener(actionHandler); deleteJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK)); selectAllJMenuItem = new JMenuItem("Select All"); selectAllJMenuItem.addActionListener(actionHandler); selectAllJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)); findJMenuItem = new JMenuItem("Find"); findJMenuItem.addActionListener(actionHandler); findJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK)); replaceJMenuItem = new JMenuItem("Replace"); replaceJMenuItem.addActionListener(actionHandler); replaceJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK)); wordWrapJCheckBoxMenuItem = new JCheckBoxMenuItem("Word Wrap"); wordWrapJCheckBoxMenuItem.addActionListener(actionHandler); wordWrapJCheckBoxMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, Event.CTRL_MASK)); fontJMenuItem = new JMenuItem("Font"); fontJMenuItem.addActionListener(actionHandler); colorJMenuItem = new JMenuItem("Color"); colorJMenuItem.addActionListener(actionHandler); statusBarJCheckBoxMenuItem = new JCheckBoxMenuItem("Status Bar"); statusBarJCheckBoxMenuItem.addActionListener(actionHandler); statusBarJCheckBoxMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.ALT_MASK)); helpJMenuItem = new JMenuItem("Help"); helpJMenuItem.addActionListener(actionHandler); helpJMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, Event.CTRL_MASK)); aboutJMenuItem = new JMenuItem("About"); aboutJMenuItem.addActionListener(actionHandler); statusJLabel = new JLabel("Status:"); //Main text area setup textArea = new JTextArea(); undoManager = new UndoManager(); wordSearcher = new WordSearcher(textArea); textArea.setBorder(BorderFactory.createMatteBorder(4, 4, 4, 4, Color.WHITE)); document = textArea.getDocument(); document.addUndoableEditListener(new UndoableEditListener() { @Override public void undoableEditHappened(UndoableEditEvent e) { undoManager.addEdit(e.getEdit()); } }); font = new Font("Tahoma", Font.PLAIN, 16); textArea.setFont(font); color = Color.BLUE; textArea.setForeground(color); undoManager = new UndoManager(); fileJMenu.add(newDocumentJMenuItem); fileJMenu.addSeparator(); fileJMenu.add(openJMenuItem); fileJMenu.add(saveJMenuItem); fileJMenu.addSeparator(); fileJMenu.add(printJMenuItem); fileJMenu.addSeparator(); fileJMenu.add(exitJMenuItem); editJMenu.add(undoJMenuItem); editJMenu.add(redoJMenuItem); editJMenu.addSeparator(); editJMenu.add(copyJMenuItem); editJMenu.add(cutJMenuItem); editJMenu.add(pasteJMenuItem); editJMenu.addSeparator(); editJMenu.add(deleteJMenuItem); editJMenu.add(selectAllJMenuItem); editJMenu.addSeparator(); editJMenu.add(findJMenuItem); editJMenu.add(replaceJMenuItem); formatJMenu.add(wordWrapJCheckBoxMenuItem); formatJMenu.add(fontJMenuItem); formatJMenu.add(colorJMenuItem); viewJMenu.add(statusBarJCheckBoxMenuItem); helpJMenu.add(helpJMenuItem); helpJMenu.add(aboutJMenuItem); menuBar.add(fileJMenu); menuBar.add(editJMenu); menuBar.add(formatJMenu); menuBar.add(viewJMenu); menuBar.add(helpJMenu); southJPanel.setVisible(false); southJPanel.add(statusJLabel); //JScrollPane setup JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); //setting uo the Jframe this.setJMenuBar(menuBar); this.add(scrollPane, BorderLayout.CENTER); this.add(southJPanel, BorderLayout.SOUTH); textArea.addMouseListener(new MouseInputListener() { @Override public void mouseClicked(MouseEvent e) { Highlighter h = textArea.getHighlighter(); h.removeAllHighlights(); } @Override public void mousePressed(MouseEvent e) { Highlighter h = textArea.getHighlighter(); h.removeAllHighlights(); } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mouseDragged(MouseEvent e) { } @Override public void mouseMoved(MouseEvent e) { } }); textArea.addKeyListener(new IgboKeyListener(textArea)); }
From source file:com.mightypocket.ashot.Mediator.java
private JMenuBar createMenuBar() { BindingGroup menuBinding = new BindingGroup(); ResourceMap resourceMap = application.getContext().getResourceMap(Mediator.class); ApplicationActionMap actionMap = getActionMap(); JMenuBar bar = new JMenuBar(); // Menu File//from w ww . jav a 2 s. co m JMenu menuFile = new JMenu(resourceMap.getString("menu.file")); menuFileDevices = new JMenu(resourceMap.getString("menu.file.devices.text")); menuFileDevices.setIcon(resourceMap.getIcon("menu.file.devices.icon")); menuFile.add(menuFileDevices); menuBinding.addBinding(bindRead(this, PROP_DEVICES, menuFileDevices, "enabled")); menuFile.addSeparator(); menuFile.add(new JMenuItem(actionMap.get(ACTION_SAVE_SCREENSHOT))); menuFile.add(new JCheckBoxMenuItem(actionMap.get(ACTION_RECORDING))); menuFile.add(new JMenuItem(actionMap.get(ACTION_OPEN_DESTINATION_FOLDER))); menuFile.addSeparator(); menuFile.add(new JMenuItem(actionMap.get(ACTION_CHANGE_DEFAULT_FOLDER))); menuFile.add(new JMenuItem(actionMap.get(ACTION_CHANGE_SDK_FOLDER))); menuFile.addSeparator(); menuFile.add(new JMenuItem(actionMap.get("quit"))); // Menu Edit JMenu menuEdit = new JMenu(resourceMap.getString("menu.edit")); menuEdit.add(new JMenuItem(actionMap.get(ACTION_COPY_TO_CLIPBOARD))); // Menu View JMenu menuView = new JMenu(resourceMap.getString("menu.view")); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_SHOW_TOOLBAR_LABELS))); menuView.addSeparator(); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_LANDSCAPE))); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_LANDSCAPE_CW))); menuView.addSeparator(); menuView.add(new JMenuItem(actionMap.get(ACTION_ZOOM_IN))); menuView.add(new JMenuItem(actionMap.get(ACTION_ZOOM_OUT))); menuView.add(new JMenuItem(actionMap.get(ACTION_SIZE_ORIGINAL))); menuView.add(new JMenuItem(actionMap.get(ACTION_SIZE_SMALL))); menuView.add(new JMenuItem(actionMap.get(ACTION_SIZE_LARGE))); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_SIZE_FIT))); menuView.addSeparator(); menuView.add(new JMenuItem(actionMap.get(ACTION_FULL_SCREEN))); // Menu Tools JMenu toolsView = new JMenu(resourceMap.getString("menu.tools")); toolsView.add(new JMenuItem(actionMap.get(ACTION_INSTALL))); toolsView.addSeparator(); toolsView.add(new JMenuItem(actionMap.get(ACTION_OPTIONS))); // Menu Help JMenu menuHelp = new JMenu(resourceMap.getString("menu.help")); menuHelp.add(new JMenuItem(actionMap.get(ACTION_CHECK_UPDATES))); menuHelp.add(new JMenuItem(actionMap.get(ACTION_ABOUT))); bar.add(menuFile); bar.add(menuEdit); bar.add(menuView); bar.add(toolsView); bar.add(menuHelp); menuBinding.bind(); return bar; }
From source file:com.lfv.lanzius.server.LanziusServer.java
public void init() { log.info(Config.VERSION + "\n"); docVersion = 0;//from w w w . ja v a 2 s . co m frame = new JFrame(Config.TITLE + " - Server Control Panel"); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { actionPerformed(new ActionEvent(itemExit, 0, null)); } }); // Create graphical terminal view panel = new WorkspacePanel(this); frame.getContentPane().add(panel); // Create a menu bar JMenuBar menuBar = new JMenuBar(); // FILE JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); // Load configuration itemLoadConfig = new JMenuItem("Load configuration..."); itemLoadConfig.addActionListener(this); fileMenu.add(itemLoadConfig); // Load terminal setup itemLoadExercise = new JMenuItem("Load exercise..."); itemLoadExercise.addActionListener(this); fileMenu.add(itemLoadExercise); fileMenu.addSeparator(); // Exit itemExit = new JMenuItem("Exit"); itemExit.addActionListener(this); fileMenu.add(itemExit); menuBar.add(fileMenu); // SERVER JMenu serverMenu = new JMenu("Server"); serverMenu.setMnemonic(KeyEvent.VK_S); // Start itemServerStart = new JMenuItem("Start"); itemServerStart.addActionListener(this); serverMenu.add(itemServerStart); // Stop itemServerStop = new JMenuItem("Stop"); itemServerStop.addActionListener(this); serverMenu.add(itemServerStop); // Restart itemServerRestart = new JMenuItem("Restart"); itemServerRestart.addActionListener(this); itemServerRestart.setEnabled(false); serverMenu.add(itemServerRestart); // Monitor network connection itemServerMonitor = new JCheckBoxMenuItem("Monitor network"); itemServerMonitor.addActionListener(this); itemServerMonitor.setState(false); serverMenu.add(itemServerMonitor); menuBar.add(serverMenu); // TERMINAL JMenu terminalMenu = new JMenu("Terminal"); terminalMenu.setMnemonic(KeyEvent.VK_T); itemTerminalLink = new JMenuItem("Link..."); itemTerminalLink.addActionListener(this); terminalMenu.add(itemTerminalLink); itemTerminalUnlink = new JMenuItem("Unlink..."); itemTerminalUnlink.addActionListener(this); terminalMenu.add(itemTerminalUnlink); itemTerminalUnlinkAll = new JMenuItem("Unlink All"); itemTerminalUnlinkAll.addActionListener(this); terminalMenu.add(itemTerminalUnlinkAll); itemTerminalSwap = new JMenuItem("Swap..."); itemTerminalSwap.addActionListener(this); terminalMenu.add(itemTerminalSwap); menuBar.add(terminalMenu); // GROUP JMenu groupMenu = new JMenu("Group"); groupMenu.setMnemonic(KeyEvent.VK_G); itemGroupStart = new JMenuItem("Start..."); itemGroupStart.addActionListener(this); groupMenu.add(itemGroupStart); itemGroupPause = new JMenuItem("Pause..."); itemGroupPause.addActionListener(this); groupMenu.add(itemGroupPause); itemGroupStop = new JMenuItem("Stop..."); itemGroupStop.addActionListener(this); groupMenu.add(itemGroupStop); menuBar.add(groupMenu); frame.setJMenuBar(menuBar); GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle maximumWindowBounds = graphicsEnvironment.getMaximumWindowBounds(); if (Config.SERVER_SIZE_FULLSCREEN) { maximumWindowBounds.setLocation(0, 0); maximumWindowBounds.setSize(Toolkit.getDefaultToolkit().getScreenSize()); frame.setResizable(false); frame.setUndecorated(true); } else if (Config.SERVER_SIZE_100P_WINDOW) { // Fixes a bug in linux using gnome. With the line below the upper and // lower bars are respected maximumWindowBounds.height -= 1; } else if (Config.SERVER_SIZE_75P_WINDOW) { maximumWindowBounds.width *= 0.75; maximumWindowBounds.height *= 0.75; } else if (Config.SERVER_SIZE_50P_WINDOW) { maximumWindowBounds.width /= 2; maximumWindowBounds.height /= 2; } frame.setBounds(maximumWindowBounds); frame.setVisible(true); log.info("Starting control panel"); // Autostart for debugging if (Config.SERVER_AUTOLOAD_CONFIGURATION != null) actionPerformed(new ActionEvent(itemLoadConfig, 0, null)); if (Config.SERVER_AUTOSTART_SERVER) actionPerformed(new ActionEvent(itemServerStart, 0, null)); if (Config.SERVER_AUTOLOAD_EXERCISE != null) actionPerformed(new ActionEvent(itemLoadExercise, 0, null)); if (Config.SERVER_AUTOSTART_GROUP > 0) actionPerformed(new ActionEvent(itemGroupStart, 0, null)); try { // Read the property files serverProperties = new Properties(); serverProperties.loadFromXML(new FileInputStream("data/properties/serverproperties.xml")); int rcPort = Integer.parseInt(serverProperties.getProperty("RemoteControlPort", "0")); if (rcPort > 0) { groupRemoteControlListener(rcPort); } isaPeriod = Integer.parseInt(serverProperties.getProperty("ISAPeriod", "60")); isaNumChoices = Integer.parseInt(serverProperties.getProperty("ISANumChoices", "6")); for (int i = 0; i < 9; i++) { String tag = "ISAKeyText" + Integer.toString(i); String def_val = Integer.toString(i + 1); isakeytext[i] = serverProperties.getProperty(tag, def_val); } isaExtendedMode = serverProperties.getProperty("ISAExtendedMode", "false").equalsIgnoreCase("true"); } catch (Exception e) { log.error("Unable to start remote control listener"); log.error(e.getMessage()); } isaClients = new HashSet<Integer>(); }
From source file:TopLevelTransferHandlerDemo.java
private JMenuBar createDummyMenuBar() { JMenuBar mb = new JMenuBar(); mb.add(createDummyMenu("File")); mb.add(createDummyMenu("Edit")); mb.add(createDummyMenu("Search")); mb.add(createDummyMenu("View")); mb.add(createDummyMenu("Tools")); mb.add(createDummyMenu("Help")); JMenu demo = new JMenu("Demo"); demo.setMnemonic(KeyEvent.VK_D); mb.add(demo);/*from w w w . j av a 2 s . c o m*/ thItem = new JCheckBoxMenuItem("Use Top-Level TransferHandler"); thItem.setMnemonic(KeyEvent.VK_T); demo.add(thItem); nullItem = new JCheckBoxMenuItem("Remove TransferHandler from List and Text"); nullItem.setMnemonic(KeyEvent.VK_R); demo.add(nullItem); copyItem = new JCheckBoxMenuItem("Use COPY Action"); copyItem.setMnemonic(KeyEvent.VK_C); demo.add(copyItem); return mb; }
From source file:de.ailis.xadrian.frames.MainFrame.java
/** * Creates the menu.//w w w. ja v a 2 s. co m */ private void createMenuBar() { // Create the menu bar final JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); // Create the 'File' menu final JMenu fileMenu = I18N.createMenu(menuBar, "file"); fileMenu.add(this.newAction); fileMenu.add(this.openAction); fileMenu.addSeparator(); fileMenu.add(this.closeAction); fileMenu.add(this.closeAllAction); fileMenu.addSeparator(); fileMenu.add(this.saveAction); fileMenu.add(this.saveAsAction); fileMenu.add(this.saveAllAction); fileMenu.addSeparator(); fileMenu.add(this.printAction); fileMenu.addSeparator(); final JMenu exportMenu = I18N.createMenu(fileMenu, "export"); exportMenu.add(this.exportASCIIAction); exportMenu.add(this.exportTemplateCodeAction); final JMenu importMenu = I18N.createMenu(fileMenu, "import"); importMenu.add(this.importTemplateCodeAction); fileMenu.addSeparator(); fileMenu.add(this.exitAction); // Create the 'Edit' menu final JMenu editMenu = I18N.createMenu(menuBar, "edit"); editMenu.add(new CopyAction(this)); editMenu.add(this.selectAllAction); editMenu.addSeparator(); editMenu.add(this.preferencesAction); // Create the 'Complex' menu final JMenu complexMenu = I18N.createMenu(menuBar, "complex"); complexMenu.add(this.addFactoryAction); complexMenu.add(this.changeSectorAction); complexMenu.add(this.changeSunsAction); complexMenu.add(this.changePricesAction); complexMenu.add(new JCheckBoxMenuItem(this.toggleBaseComplexAction)); // Create the 'Help' menu final JMenu helpMenu = I18N.createMenu(menuBar, "help"); helpMenu.add(this.donateAction); helpMenu.addSeparator(); helpMenu.add(this.homepageAction); helpMenu.add(this.forumAction); helpMenu.add(this.twitterAction); helpMenu.add(this.googlePlusAction); helpMenu.add(this.githubAction); helpMenu.addSeparator(); helpMenu.add(this.aboutAction); installStatusHandler(menuBar); }