List of usage examples for javax.swing JSeparator JSeparator
public JSeparator()
From source file:org.f2o.absurdum.puck.gui.PuckFrame.java
/** * Instances and shows Puck's main frame. */// ww w. ja va 2 s . com public PuckFrame() { super(); setLookAndFeel(PuckConfiguration.getInstance().getProperty("look")); /* LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); for ( int i = 0 ; i < lfs.length ; i++ ) { if ( lfs[i].getName().toLowerCase().contains("nimbus") ) { try { UIManager.setLookAndFeel(lfs[i].getClassName()); } catch (Exception e) //class not found, instantiation exception, etc. (shouldn't happen) { e.printStackTrace(); } } } */ setSize(PuckConfiguration.getInstance().getIntegerProperty("windowWidth"), PuckConfiguration.getInstance().getIntegerProperty("windowHeight")); setLocation(PuckConfiguration.getInstance().getIntegerProperty("windowLocationX"), PuckConfiguration.getInstance().getIntegerProperty("windowLocationY")); //setSize(600,600); if (PuckConfiguration.getInstance().getBooleanProperty("windowMaximized")) maximizeIfPossible(); //setTitle(Messages.getInstance().getMessage("frame.title")); refreshTitle(); left = new JPanel(); right = new JPanel(); JScrollPane rightScroll = new JScrollPane(right); rightScroll.getVerticalScrollBar().setUnitIncrement(16); //faster scrollbar (by default it was very slow, maybe because component inside is not text component!) split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, rightScroll) { //dynamic resizing of right panel /* public void setDividerLocation ( int pixels ) { if ( propPanel != null ) { double rightPartSize = getContentPane().getWidth() - pixels - 15; System.out.println("rps=" + rightPartSize); System.out.println("mnw=" + this.getMinimumSize().getWidth()); Dimension propPanSize = propPanel.getSize(); int propPanHeight = 0; if (propPanSize != null) propPanHeight = (int) propPanSize.getHeight(); //propPanel.revalidate(); System.out.println("h " + propPanHeight); //if ( rightPartSize >= propPanel.getMinimumSize().getWidth() ) propPanel.setPreferredSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setMinimumSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setMaximumSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setSize(new Dimension((int)rightPartSize,propPanHeight)); propPanel.revalidate(); } super.setDividerLocation(pixels); } */ }; split.setContinuousLayout(true); split.setResizeWeight(0.60); final int dividerLoc = PuckConfiguration.getInstance().getIntegerProperty("dividerLocation", 0); /* SwingUtilities.invokeLater(new Runnable(){ public void run() { */ /* } }); */ split.setOneTouchExpandable(true); getContentPane().add(split); System.out.println(Toolkit.getDefaultToolkit().getBestCursorSize(20, 20)); //it's 32x32. Will have to do it. //Image img = Toolkit.getDefaultToolkit().createImage( getClass().getResource("addCursor32.png") ); //Image img = Toolkit.getDefaultToolkit().createImage("addCursor32.png"); left.setLayout(new BorderLayout()); //right.setLayout(new BoxLayout(right,BoxLayout.LINE_AXIS)); if (PuckConfiguration.getInstance().getBooleanProperty("dynamicFormResizing")) right.setLayout(new BorderLayout()); else right.setLayout(new FlowLayout()); propPanel = new PropertiesPanel(); right.add(propPanel); graphPanel = new GraphEditingPanel(propPanel); graphPanel.setGrid(Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue()); graphPanel.setSnapToGrid( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue()); propPanel.setGraphEditingPanel(graphPanel); tools = new PuckToolBar(graphPanel, propPanel, this); left.add(tools, BorderLayout.WEST); left.add(graphPanel, BorderLayout.CENTER); /* Action testAction = new AbstractAction() { public void actionPerformed ( ActionEvent evt ) { System.out.println("Puck!"); } } ; testAction.putValue(Action.NAME,"Print Puck"); tools.add(testAction); */ /* public void saveChanges ( ) { if ( editingFileName == null ) { //save as... code } else { File f = new File(editingFileName); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } } */ JMenuBar mainMenuBar = new JMenuBar(); JMenu fileMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file")); fileMenu.setMnemonic(KeyEvent.VK_F); saveMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.save")); saveMenuItem.setMnemonic(KeyEvent.VK_S); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (editingFileName == null) JOptionPane.showMessageDialog(PuckFrame.this, "File has no name!", "Whoops!", JOptionPane.ERROR_MESSAGE); /* File f = new File(editingFileName); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } */ try { saveChangesInCurrentFile(); } catch (Exception e) { JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }); JMenu newMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.new")); JMenuItem newBlankMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.new.blank")); //newBlankMenuItem.setMnemonic(KeyEvent.VK_N); newBlankMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { GraphElementPanel.emptyQueue(); //stop deferred loads graphPanel.clear(); propPanel.clear(); JSyntaxBSHCodeFrame.closeAllInstances(); WorldPanel wp = new WorldPanel(graphPanel); WorldNode wn = new WorldNode(wp); graphPanel.setWorldNode(wn); propPanel.show(graphPanel.getWorldNode()); resetCurrentlyEditingFile(); refreshTitle(); //revalidate(); //only since java 1.7 //invalidate(); //validate(); split.revalidate(); //JComponents do have it before java 1.7 (not JFrame) } }); newMenu.add(newBlankMenuItem); JMenu templateMenus = new WorldTemplateMenuBuilder(this).getMenu(); if (templateMenus != null) { for (int i = 0; i < templateMenus.getItemCount(); i++) { if (i == 0) newMenu.add(new JSeparator()); newMenu.add(templateMenus.getItem(i)); } } JMenuItem saveAsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.saveas")); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { /* JFileChooser jfc = new JFileChooser("."); int opt = jfc.showSaveDialog(PuckFrame.this); if ( opt == JFileChooser.APPROVE_OPTION ) { File f = jfc.getSelectedFile(); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); saveMenuItem.setEnabled(true); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } */ try { saveAs(); saveMenuItem.setEnabled(true); } catch (Exception e) { JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } //saveAs(saveMenuItem); } }); JMenuItem openMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.open")); openMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //graphPanel.setVisible(false); //propPanel.setVisible(false); JFileChooser jfc = new JFileChooser("."); jfc.setFileFilter(new FiltroFicheroMundo()); int opt = jfc.showOpenDialog(PuckFrame.this); if (opt == JFileChooser.APPROVE_OPTION) { File f = jfc.getSelectedFile(); openFileOrShowError(f); } //graphPanel.setVisible(true); //propPanel.setVisible(true); } }); openRecentMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.recent")); JMenuItem exitMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.exit")); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { /* int opt = JOptionPane.showConfirmDialog(PuckFrame.this,Messages.getInstance().getMessage("exit.sure.text"),Messages.getInstance().getMessage("exit.sure.title"),JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); if ( opt == JOptionPane.YES_OPTION ) System.exit(0); */ userExit(); } }); JMenu exportMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.export")); JMenuItem exportAppletMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.file.export.applet")); exportAppletMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ExportAppletDialog dial = new ExportAppletDialog(PuckFrame.this); dial.setVisible(true); } }); exportMenu.add(exportAppletMenuItem); fileMenu.add(newMenu); fileMenu.add(openMenuItem); fileMenu.add(openRecentMenu); updateRecentMenu(); fileMenu.add(new JSeparator()); saveMenuItem.setEnabled(false); fileMenu.add(saveMenuItem); fileMenu.add(saveAsMenuItem); fileMenu.add(exportMenu); fileMenu.add(new JSeparator()); fileMenu.add(exitMenuItem); mainMenuBar.add(fileMenu); /** * Create an Edit menu to support cut/copy/paste. */ JMenu editMenu = new JMenu(UIMessages.getInstance().getMessage("menu.edit")); editMenu.setMnemonic(KeyEvent.VK_E); JMenuItem findMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.find.entity")); findMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showFindEntityDialog(); } }); editMenu.add(findMenuItem); editMenu.add(new JSeparator()); JMenuItem aMenuItem = new JMenuItem(new CutAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.cut")); aMenuItem.setMnemonic(KeyEvent.VK_T); editMenu.add(aMenuItem); aMenuItem = new JMenuItem(new CopyAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.copy")); aMenuItem.setMnemonic(KeyEvent.VK_C); editMenu.add(aMenuItem); aMenuItem = new JMenuItem(new PasteAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.paste")); aMenuItem.setMnemonic(KeyEvent.VK_P); editMenu.add(aMenuItem); mainMenuBar.add(editMenu); JMenu optionsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options")); JMenu gridMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.grid")); optionsMenu.add(gridMenu); final JCheckBoxMenuItem showGridItem = new JCheckBoxMenuItem( UIMessages.getInstance().getMessage("menu.options.grid.show")); showGridItem.setSelected( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue()); gridMenu.add(showGridItem); showGridItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { graphPanel.setGrid(true); PuckConfiguration.getInstance().setProperty("showGrid", "true"); } else if (e.getStateChange() == ItemEvent.DESELECTED) { graphPanel.setGrid(false); PuckConfiguration.getInstance().setProperty("showGrid", "false"); } graphPanel.repaint(); } }); final JCheckBoxMenuItem snapToGridItem = new JCheckBoxMenuItem( UIMessages.getInstance().getMessage("menu.options.grid.snap")); snapToGridItem.setSelected( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue()); gridMenu.add(snapToGridItem); snapToGridItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { graphPanel.setSnapToGrid(true); PuckConfiguration.getInstance().setProperty("snapToGrid", "true"); } else if (e.getStateChange() == ItemEvent.DESELECTED) { graphPanel.setSnapToGrid(false); PuckConfiguration.getInstance().setProperty("snapToGrid", "false"); } graphPanel.repaint(); } }); JMenuItem translationModeMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.translation")); ButtonGroup translationGroup = new ButtonGroup(); final JRadioButtonMenuItem holdMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.translation.hold")); final JRadioButtonMenuItem pushMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.translation.push")); pushMenuItem.setSelected("push".equals(PuckConfiguration.getInstance().getProperty("translateMode"))); if (!pushMenuItem.isSelected()) holdMenuItem.setSelected(true); translationGroup.add(holdMenuItem); translationGroup.add(pushMenuItem); holdMenuItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (holdMenuItem.isSelected()) PuckConfiguration.getInstance().setProperty("translateMode", "hold"); else PuckConfiguration.getInstance().setProperty("translateMode", "push"); } }); translationModeMenu.add(holdMenuItem); translationModeMenu.add(pushMenuItem); optionsMenu.add(translationModeMenu); JMenuItem toolSelectionModeMenu = new JMenu( UIMessages.getInstance().getMessage("menu.options.toolselection")); ButtonGroup toolSelectionGroup = new ButtonGroup(); final JRadioButtonMenuItem oneUseMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.toolselection.oneuse")); final JRadioButtonMenuItem multipleUseMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.toolselection.multipleuse")); multipleUseMenuItem.setSelected( "multipleUse".equalsIgnoreCase(PuckConfiguration.getInstance().getProperty("toolSelectionMode"))); if (!multipleUseMenuItem.isSelected()) oneUseMenuItem.setSelected(true); toolSelectionGroup.add(oneUseMenuItem); toolSelectionGroup.add(multipleUseMenuItem); oneUseMenuItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (oneUseMenuItem.isSelected()) PuckConfiguration.getInstance().setProperty("toolSelectionMode", "oneUse"); else PuckConfiguration.getInstance().setProperty("toolSelectionMode", "multipleUse"); } }); toolSelectionModeMenu.add(oneUseMenuItem); toolSelectionModeMenu.add(multipleUseMenuItem); optionsMenu.add(toolSelectionModeMenu); JMenuItem sizesMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.iconsizes")); sizesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { IconSizesDialog dial = new IconSizesDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(sizesMenuItem); JMenuItem showHideMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.showhide")); showHideMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ShowHideDialog dial = new ShowHideDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(showHideMenuItem); JMenuItem mapColorsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.mapcolors")); mapColorsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MapColorsDialog dial = new MapColorsDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(mapColorsMenuItem); String skinList = PuckConfiguration.getInstance().getProperty("availableSkins"); if (skinList != null && skinList.trim().length() > 0) { JMenu skinsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.skins")); StringTokenizer st = new StringTokenizer(skinList, ", "); ButtonGroup skinButtons = new ButtonGroup(); while (st.hasMoreTokens()) { final String nextSkin = st.nextToken(); final JRadioButtonMenuItem skinMenuItem = new JRadioButtonMenuItem(nextSkin); skinMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setSkin(nextSkin); skinMenuItem.setSelected(true); } }); if (nextSkin.equals(PuckConfiguration.getInstance().getProperty("skin"))) skinMenuItem.setSelected(true); skinsMenu.add(skinMenuItem); skinButtons.add(skinMenuItem); } optionsMenu.add(skinsMenu); } JMenu lookFeelMenu = new JMenu(UIMessages.getInstance().getMessage("menu.looks")); ButtonGroup lookButtons = new ButtonGroup(); final JRadioButtonMenuItem defaultLookMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.looks.default")); if ("default".equals(PuckConfiguration.getInstance().getProperty("look"))) { defaultLookMenuItem.setSelected(true); } lookFeelMenu.add(defaultLookMenuItem); lookButtons.add(defaultLookMenuItem); defaultLookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel("default"); defaultLookMenuItem.setSelected(true); } }); final JRadioButtonMenuItem systemLookMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.looks.system")); if ("system".equals(PuckConfiguration.getInstance().getProperty("look"))) { systemLookMenuItem.setSelected(true); } lookFeelMenu.add(systemLookMenuItem); lookButtons.add(systemLookMenuItem); systemLookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel("system"); systemLookMenuItem.setSelected(true); } }); String additionalLookList = PuckConfiguration.getInstance().getProperty("additionalLooks"); if (additionalLookList != null && additionalLookList.trim().length() > 0) { StringTokenizer st = new StringTokenizer(additionalLookList, ", "); while (st.hasMoreTokens()) { final String nextLook = st.nextToken(); final JRadioButtonMenuItem lookMenuItem = new JRadioButtonMenuItem(nextLook); lookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(nextLook); lookMenuItem.setSelected(true); } }); if (nextLook.equals(PuckConfiguration.getInstance().getProperty("look"))) { lookMenuItem.setSelected(true); } lookFeelMenu.add(lookMenuItem); lookButtons.add(lookMenuItem); } } optionsMenu.add(lookFeelMenu); optionsMenu.add(new UILanguageSelectionMenu(this)); mainMenuBar.add(optionsMenu); JMenu toolsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.tools")); final JMenuItem verbListMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.tools.verblist")); verbListMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { WorldPanel wp = (WorldPanel) graphPanel.getWorldNode().getAssociatedPanel(); VerbListFrame vlf = VerbListFrame.getInstance(wp.getSelectedLanguageCode()); vlf.setVisible(true); } }); toolsMenu.add(verbListMenuItem); final JMenuItem validateMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.tools.validatebsh")); validateMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { BeanShellCodeValidator bscv = new BeanShellCodeValidator(graphPanel); if (!bscv.validate()) { BeanShellErrorsDialog bsed = new BeanShellErrorsDialog(PuckFrame.this, bscv.getErrorText()); bsed.setVisible(true); //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText()); } else { JOptionPane.showMessageDialog(PuckFrame.this, UIMessages.getInstance().getMessage("bsh.code.ok"), "OK!", JOptionPane.INFORMATION_MESSAGE); //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText()); } } }); toolsMenu.add(validateMenuItem); mainMenuBar.add(toolsMenu); JMenu helpMenu = new JMenu(UIMessages.getInstance().getMessage("menu.help")); //JHelpAction.startHelpWorker("help/PUCKHelp.hs"); //JHelpAction helpTocAction = JHelpAction.getShowHelpInstance(Messages.getInstance().getMessage("menu.help.toc")); //JHelpAction helpContextSensitiveAction = JHelpAction.getTrackInstance(Messages.getInstance().getMessage("menu.help.context")); //final JMenuItem helpTocMenuItem = new JMenuItem(helpTocAction); //final JMenuItem helpContextSensitiveMenuItem = new JMenuItem(helpContextSensitiveAction); //helpMenu.add(helpTocMenuItem); //helpMenu.add(helpContextSensitiveMenuItem); final JMenuItem helpMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.help.toc")); helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DocumentationLinkDialog dial = new DocumentationLinkDialog(PuckFrame.this, true); dial.setVisible(true); } }); helpMenu.add(helpMenuItem); mainMenuBar.add(helpMenu); MenuMnemonicOnTheFly.setMnemonics(mainMenuBar); this.setJMenuBar(mainMenuBar); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { userExit(); } }); propPanel.show(graphPanel.getWorldNode()); setVisible(true); SwingUtilities.invokeLater(new Runnable() { public void run() { if (dividerLoc > 0) split.setDividerLocation(dividerLoc); else split.setDividerLocation(0.60); } }); }
From source file:org.gtdfree.GTDFree.java
/** * This method initializes jJMenuBar /*from w ww .j a v a2s . c o m*/ * * @return javax.swing.JMenuBar */ private JMenuBar getJMenuBar() { if (jJMenuBar == null) { jJMenuBar = new JMenuBar(); jJMenuBar.add(getFileMenu()); JMenu jm = new JMenu(Messages.getString("GTDFree.View")); //$NON-NLS-1$ jm.add(getShowAllActionsMenuItem()); jm.add(getShowClosedFoldersMenuItem()); jm.add(getShowEmptyFoldersMenuItem()); jm.add(new JSeparator()); jm.add(getShowOverviewTabMenuItem()); jm.add(getShowQuickCollectBarMenuItem()); jm.add(getShowTrayIconMenuItem()); jJMenuBar.add(jm); jm = new JMenu(Messages.getString("GTDFree.Go")); //$NON-NLS-1$ JMenuItem jmi = new JMenuItem(Messages.getString("GTDFree.Go.Past")); //$NON-NLS-1$ jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tabbedPane.setSelectedIndex(TAB_ORGANIZE); organizePane.openTicklerForPast(); } }); jm.add(jmi); jmi = new JMenuItem(Messages.getString("GTDFree.Go.Today")); //$NON-NLS-1$ jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { tabbedPane.setSelectedIndex(TAB_ORGANIZE); organizePane.openTicklerForToday(); } }); jm.add(jmi); jJMenuBar.add(jm); jm = new JMenu(Messages.getString("GTDFree.Tools")); //$NON-NLS-1$ jJMenuBar.add(jm); jmi = new JMenuItem(Messages.getString("GTDFree.Tools.DB")); //$NON-NLS-1$ jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getDatabaseInfoDialog().showDatabaseToolsDialog(getJFrame()); } }); jm.add(jmi); jJMenuBar.add(getHelpMenu()); } return jJMenuBar; }
From source file:org.gtdfree.GTDFree.java
/** * This method initializes jMenu /*from w w w . j a v a 2 s . c o m*/ * * @return javax.swing.JMenu */ private JMenu getFileMenu() { if (fileMenu == null) { fileMenu = new JMenu(); fileMenu.setText(Messages.getString("GTDFree.File")); //$NON-NLS-1$ fileMenu.add(getSaveMenuItem()); autoSaveMenuItem = new JCheckBoxMenuItem(); autoSaveMenuItem.setText(Messages.getString("GTDFree.File.ASave")); //$NON-NLS-1$ if (getEngine().getGTDModel().getDataRepository() instanceof GTDDataXML) { autoSaveMenuItem.setSelected( getEngine().getGlobalProperties().getBoolean(GlobalProperties.AUTO_SAVE, true)); } else { autoSaveMenuItem.setSelected(true); autoSaveMenuItem.setEnabled(false); } autoSaveMenuItem.setToolTipText(Messages.getString("GTDFree.File.ASave.desc")); //$NON-NLS-1$ autoSaveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getEngine().setAutoSave(autoSaveMenuItem.isSelected()); getEngine().getGlobalProperties().putProperty(GlobalProperties.AUTO_SAVE, autoSaveMenuItem.isSelected()); } }); fileMenu.add(autoSaveMenuItem); /*fileMenu.add(new JSeparator()); printCurrentMenuItem= new JMenuItem(); printCurrentMenuItem.setText("Print current view..."); printCurrentMenuItem.setEnabled(false); printCurrentMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { WorkflowPane p= getEngine().getActiveWorkflowPane(); if (p!=null) { try { p.printTable(); } catch (PrinterException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(getJFrame(), "Printing failed, error: "+e1.toString(), "Printing failed", JOptionPane.ERROR_MESSAGE); } } } }); getEngine().addPropertyChangeListener("activePane", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { printCurrentMenuItem.setEnabled(getEngine().getActiveWorkflowPane()!=null); } }); fileMenu.add(printCurrentMenuItem);*/ fileMenu.add(new JSeparator()); JMenuItem jmi = new JMenuItem(Messages.getString("GTDFree.File.Print")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_print)); jmi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getPrintDialog().setVisible(true); } }); fileMenu.add(jmi); fileMenu.add(new JSeparator()); jmi = new JMenuItem(Messages.getString("GTDFree.File.Import")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_import)); jmi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importFile(); } }); fileMenu.add(jmi); jmi = new JMenuItem(Messages.getString("GTDFree.File.Export")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_export)); jmi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getExportDialog().setVisible(true); } }); fileMenu.add(jmi); jmi = new JMenuItem(Messages.getString("GTDFree.File.All")); //$NON-NLS-1$ jmi.setToolTipText(Messages.getString("GTDFree.File.All.desc")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_export)); jmi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exportFile(); } }); fileMenu.add(jmi); fileMenu.add(new JSeparator()); fileMenu.add(getExitMenuItem()); } return fileMenu; }
From source file:org.gtdfree.GTDFree.java
/** * This method initializes jMenu //from w w w . ja v a 2 s .c om * * @return javax.swing.JMenu */ private JMenu getHelpMenu() { if (helpMenu == null) { helpMenu = new JMenu(); helpMenu.setText(Messages.getString("GTDFree.Help")); //$NON-NLS-1$ JMenuItem jmi = new JMenuItem(Messages.getString("GTDFree.Help.Home")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_browser)); jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { URI uri; try { uri = new URI(getEngine().getConfiguration().getProperty("home.url", //$NON-NLS-1$ "http://gtd-free.sourceforge.net")); //$NON-NLS-1$ Desktop.getDesktop().browse(uri); } catch (Exception e1) { Logger.getLogger(this.getClass()).error("URL load failed.", e1); //$NON-NLS-1$ } } }); helpMenu.add(jmi); jmi = new JMenuItem(Messages.getString("GTDFree.Help.Manuals")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_browser)); jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { URI uri; try { uri = new URI(getEngine().getConfiguration().getProperty("manuals.url", //$NON-NLS-1$ "http://gtd-free.sourceforge.net/manuals.html")); //$NON-NLS-1$ //$NON-NLS-3$ Desktop.getDesktop().browse(uri); } catch (Exception e1) { Logger.getLogger(this.getClass()).error("URL load failed.", e1); //$NON-NLS-1$ } } }); helpMenu.add(jmi); jmi = new JMenuItem(getActionMap().get("importDialog")); //$NON-NLS-1$ helpMenu.add(jmi); helpMenu.add(new JSeparator()); jmi = new JMenuItem(); jmi.setText(Messages.getString("GTDFree.Check")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_update)); jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new Thread() { @Override public void run() { checkForUpdates(true); } }.start(); } }); helpMenu.add(jmi); JCheckBoxMenuItem jcbmi = new JCheckBoxMenuItem(); jcbmi.setText(Messages.getString("GTDFree.CheckAtStartup")); //$NON-NLS-1$ try { getEngine().getGlobalProperties().connectBooleanProperty(GlobalProperties.CHECK_FOR_UPDATE_AT_START, jcbmi, "selected", "isSelected", "setSelected", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } catch (Exception e1) { logger.debug("Internal error.", e1); //$NON-NLS-1$ } helpMenu.add(jcbmi); helpMenu.add(new JSeparator()); jmi = new JMenuItem(); jmi.setText(Messages.getString("GTDFree.Help.Mon")); //$NON-NLS-1$ jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getMonitor().getDialog().setVisible(true); } }); helpMenu.add(jmi); helpMenu.add(new JSeparator()); helpMenu.add(getAboutMenuItem()); } return helpMenu; }
From source file:org.jets3t.apps.cockpitlite.CockpitLite.java
/** * Initialises the application's GUI elements. *///from w w w.ja va 2 s . c om private void initGui() { // Initialise skins factory. skinsFactory = SkinsFactory.getInstance(cockpitLiteProperties.getProperties()); // Set Skinned Look and Feel. LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel"); try { UIManager.setLookAndFeel(lookAndFeel); } catch (UnsupportedLookAndFeelException e) { log.error("Unable to set skinned LookAndFeel", e); } // Primary panel that contains all other items. JPanel primaryPanel = skinsFactory.createSkinnedJPanel("PrimaryPanel"); primaryPanel.setLayout(new GridBagLayout()); this.getContentPane().add(primaryPanel); // Setup the stack panel, which contains all other panels as a stack. stackPanel = skinsFactory.createSkinnedJPanel("StackPanel"); stackPanelCardLayout = new CardLayout(); stackPanel.setLayout(stackPanelCardLayout); primaryPanel.add(stackPanel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); // Progress notification panel progressNotificationPanel = skinsFactory.createSkinnedJPanel("ProgressNotificationPanel"); progressNotificationPanel.setLayout(new GridBagLayout()); primaryPanel.add(progressNotificationPanel, new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 5, 0), 0, 0)); int row = 0; // Login panel. row = 0; loginPanel = skinsFactory.createSkinnedJPanel("LoginPanel"); loginPanel.setLayout(new GridBagLayout()); userInputFields = new UserInputFields(insetsDefault, null, skinsFactory); userInputFields.buildFieldsPanel(loginPanel, cockpitLiteProperties); loginButton = skinsFactory.createSkinnedJButton("LoginButton"); loginButton.setText("Log me in"); loginButton.addActionListener(this); loginPanel.add(loginButton, new GridBagConstraints(0, loginPanel.getComponentCount(), 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, insetsDefault, 0, 0)); // Filter panel. filterObjectsPanel = skinsFactory.createSkinnedJPanel("FilterPanel"); filterObjectsPanel.setLayout(new GridBagLayout()); filterObjectsPrefix = skinsFactory.createSkinnedJTextField("FilterPrefix"); filterObjectsPrefix.setToolTipText("Only show files starting with this string"); filterObjectsPrefix.addActionListener(this); filterObjectsPrefix.setActionCommand("RefreshObjects"); JLabel filterPrefixLabel = skinsFactory.createSkinnedJHtmlLabel("FilterPrefixLable", this); filterPrefixLabel.setText("File name starts with: "); filterObjectsPanel.add(filterPrefixLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); filterObjectsPanel.add(filterObjectsPrefix, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); filterObjectsPanel.setVisible(false); // Objects panel. row = 0; JPanel objectsPanel = skinsFactory.createSkinnedJPanel("ObjectsPanel"); objectsPanel.setLayout(new GridBagLayout()); filterObjectsCheckBox = skinsFactory.createSkinnedJCheckBox("FilterCheckbox"); filterObjectsCheckBox.setText("Search files"); filterObjectsCheckBox.setEnabled(true); filterObjectsCheckBox.addActionListener(this); filterObjectsCheckBox.setToolTipText("Check this option to search your files"); objectsHeadingLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectsHeadingLabel", this); objectsHeadingLabel.setText("Not logged in"); objectsPanel.add(objectsHeadingLabel, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsPanel.add(filterObjectsCheckBox, new GridBagConstraints(1, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); JButton objectActionButton = skinsFactory.createSkinnedJButton("ObjectMenuButton"); objectActionButton.setToolTipText("File actions menu"); guiUtils.applyIcon(objectActionButton, "/images/nuvola/16x16/actions/misc.png"); objectActionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JButton sourceButton = (JButton) e.getSource(); objectActionMenu.show(sourceButton, 0, sourceButton.getHeight()); } }); objectsPanel.add(objectActionButton, new GridBagConstraints(2, row, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsPanel.add(filterObjectsPanel, new GridBagConstraints(0, ++row, 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsZero, 0, 0)); objectsTable = skinsFactory.createSkinnedJTable("ObjectsTable"); objectTableModel = new CLObjectTableModel(); objectTableModelSorter = new TableSorter(objectTableModel); objectTableModelSorter.setTableHeader(objectsTable.getTableHeader()); objectsTable.setModel(objectTableModelSorter); objectsTable.setDefaultRenderer(Long.class, new DefaultTableCellRenderer() { private static final long serialVersionUID = 7229656175879985698L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { String formattedSize = byteFormatter.formatByteSize(((Long) value).longValue()); return super.getTableCellRendererComponent(table, formattedSize, isSelected, hasFocus, row, column); } }); objectsTable.setDefaultRenderer(Date.class, new DefaultTableCellRenderer() { private static final long serialVersionUID = -4983176028291916397L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Date date = (Date) value; return super.getTableCellRendererComponent(table, yearAndTimeSDF.format(date), isSelected, hasFocus, row, column); } }); objectsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); objectsTable.getSelectionModel().addListSelectionListener(this); objectsTable.setShowHorizontalLines(true); objectsTable.setShowVerticalLines(true); objectsTable.addMouseListener(new ContextMenuListener()); objectsTableSP = skinsFactory.createSkinnedJScrollPane("ObjectsTableSP", objectsTable); objectsPanel.add(objectsTableSP, new GridBagConstraints(0, ++row, 3, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); objectsSummaryLabel = skinsFactory.createSkinnedJHtmlLabel("ObjectsSummary", this); objectsSummaryLabel.setHorizontalAlignment(JLabel.CENTER); objectsSummaryLabel.setFocusable(false); objectsPanel.add(objectsSummaryLabel, new GridBagConstraints(0, ++row, 3, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); // Object action menu. objectActionMenu = skinsFactory.createSkinnedJPopupMenu("ObjectPopupMenu"); refreshObjectMenuItem = skinsFactory.createSkinnedJMenuItem("RefreshMenuItem"); refreshObjectMenuItem.setText("Refresh file listing"); refreshObjectMenuItem.setActionCommand("RefreshObjects"); refreshObjectMenuItem.addActionListener(this); guiUtils.applyIcon(refreshObjectMenuItem, "/images/nuvola/16x16/actions/reload.png"); objectActionMenu.add(refreshObjectMenuItem); viewObjectPropertiesMenuItem = skinsFactory.createSkinnedJMenuItem("PropertiesMenuItem"); viewObjectPropertiesMenuItem.setText("View file properties..."); viewObjectPropertiesMenuItem.setActionCommand("ViewObjectProperties"); viewObjectPropertiesMenuItem.addActionListener(this); guiUtils.applyIcon(viewObjectPropertiesMenuItem, "/images/nuvola/16x16/actions/viewmag.png"); objectActionMenu.add(viewObjectPropertiesMenuItem); downloadObjectMenuItem = skinsFactory.createSkinnedJMenuItem("DownloadMenuItem"); downloadObjectMenuItem.setText("Download file(s)..."); downloadObjectMenuItem.setActionCommand("DownloadObjects"); downloadObjectMenuItem.addActionListener(this); guiUtils.applyIcon(downloadObjectMenuItem, "/images/nuvola/16x16/actions/1downarrow.png"); objectActionMenu.add(downloadObjectMenuItem); uploadFilesMenuItem = skinsFactory.createSkinnedJMenuItem("UploadMenuItem"); uploadFilesMenuItem.setText("Upload file(s)..."); uploadFilesMenuItem.setActionCommand("UploadFiles"); uploadFilesMenuItem.addActionListener(this); guiUtils.applyIcon(uploadFilesMenuItem, "/images/nuvola/16x16/actions/1uparrow.png"); objectActionMenu.add(uploadFilesMenuItem); objectActionMenu.add(new JSeparator()); togglePublicMenuItem = skinsFactory.createSkinnedJMenuItem("AclToggleMenuItem"); togglePublicMenuItem.setText("Change privacy setting..."); togglePublicMenuItem.setActionCommand("TogglePublicPrivate"); togglePublicMenuItem.addActionListener(this); guiUtils.applyIcon(togglePublicMenuItem, "/images/nuvola/16x16/actions/encrypted.png"); objectActionMenu.add(togglePublicMenuItem); generatePublicGetUrl = skinsFactory.createSkinnedJMenuItem("PublicUrlMenuItem"); generatePublicGetUrl.setText("Public web link..."); generatePublicGetUrl.setActionCommand("GeneratePublicGetURL"); generatePublicGetUrl.addActionListener(this); guiUtils.applyIcon(generatePublicGetUrl, "/images/nuvola/16x16/actions/wizard.png"); objectActionMenu.add(generatePublicGetUrl); objectActionMenu.add(new JSeparator()); deleteObjectMenuItem = skinsFactory.createSkinnedJMenuItem("DeleteMenuItem"); deleteObjectMenuItem.setText("Delete file(s)..."); deleteObjectMenuItem.setActionCommand("DeleteObjects"); deleteObjectMenuItem.addActionListener(this); guiUtils.applyIcon(deleteObjectMenuItem, "/images/nuvola/16x16/actions/cancel.png"); objectActionMenu.add(deleteObjectMenuItem); viewObjectPropertiesMenuItem.setEnabled(false); refreshObjectMenuItem.setEnabled(false); togglePublicMenuItem.setEnabled(false); downloadObjectMenuItem.setEnabled(false); generatePublicGetUrl.setEnabled(false); deleteObjectMenuItem.setEnabled(false); // Card layout in stack panel stackPanel.add(loginPanel, "LoginPanel"); stackPanel.add(objectsPanel, "ObjectsPanel"); // Set preferred sizes int preferredWidth = 800; int preferredHeight = 600; this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight))); // Initialize drop target. initDropTarget(new JComponent[] { objectsPanel }); objectsPanel.getDropTarget().setActive(true); }
From source file:org.kse.gui.crypto.DUpgradeCryptoStrength.java
private void initComponents() { jlUpgradeInstructions = new JLabel(res.getString("DUpgradeCryptoStrength.jlUpgradeInstructions.text")); jlDownloadPolicyInstructions = new JLabel( res.getString("DUpgradeCryptoStrength.jlDownloadPolicyInstructions.text")); jbDownloadPolicy = new JButton(res.getString("DUpgradeCryptoStrength.jbDownloadPolicy.text")); PlatformUtil.setMnemonic(jbDownloadPolicy, res.getString("DUpgradeCryptoStrength.jbDownloadPolicy.mnemonic").charAt(0)); jlDropPolicyInstructions = new JLabel( res.getString("DUpgradeCryptoStrength.jlDropPolicyInstructions.text")); policyZipDropTarget = new PolicyZipDropTarget(); jbBrowsePolicy = new JButton(res.getString("DUpgradeCryptoStrength.jbBrowsePolicy.text")); PlatformUtil.setMnemonic(jbBrowsePolicy, res.getString("DUpgradeCryptoStrength.jbBrowsePolicy.mnemonic").charAt(0)); jbUpgrade = new JButton(res.getString("DUpgradeCryptoStrength.jbUpgrade.text")); PlatformUtil.setMnemonic(jbUpgrade, res.getString("DUpgradeCryptoStrength.jbUpgrade.mnemonic").charAt(0)); jbUpgrade.setEnabled(false);/*from w ww. j a v a 2 s . c o m*/ jbCancel = new JButton(res.getString("DUpgradeCryptoStrength.jbCancel.text")); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jpButtons = PlatformUtil.createDialogButtonPanel(jbUpgrade, jbCancel); // layout Container pane = getContentPane(); pane.setLayout(new MigLayout("insets dialog, fill", "", "[]para[]")); pane.add(jlUpgradeInstructions, "wrap"); pane.add(jlDownloadPolicyInstructions, "wrap"); pane.add(jbDownloadPolicy, "wrap"); pane.add(jlDropPolicyInstructions, "split"); pane.add(policyZipDropTarget, "gap para, pad para, wrap"); pane.add(jbBrowsePolicy, "wrap"); pane.add(new JSeparator(), "spanx, growx, wrap para"); pane.add(jpButtons, "right, spanx"); // actions jbDownloadPolicy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DUpgradeCryptoStrength.this); downloadPolicyPressed(); } finally { CursorUtil.setCursorFree(DUpgradeCryptoStrength.this); } } }); jbUpgrade.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { upgradePressed(); } }); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbBrowsePolicy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DUpgradeCryptoStrength.this); browsePolicyPressed(); } finally { CursorUtil.setCursorFree(DUpgradeCryptoStrength.this); } } }); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); setResizable(false); getRootPane().setDefaultButton(jbUpgrade); pack(); }
From source file:org.kse.gui.dialogs.sign.DSignJar.java
private void initComponents(String signatureName) throws CryptoException { jlInputJar = new JLabel(res.getString("DSignJar.jlInputJar.text")); jtfInputJar = new JTextField(30); jtfInputJar.setCaretPosition(0);//from w w w. j a v a 2 s. c o m jtfInputJar.setToolTipText(res.getString("DSignJar.jtfInputJar.tooltip")); jbInputJarBrowse = new JButton(res.getString("DSignJar.jbInputJarBrowse.text")); PlatformUtil.setMnemonic(jbInputJarBrowse, res.getString("DSignJar.jbInputJarBrowse.mnemonic").charAt(0)); jbInputJarBrowse.setToolTipText(res.getString("DSignJar.jbInputJarBrowse.tooltip")); jlSignDirectly = new JLabel(res.getString("DSignJar.jlSignDirectly.text")); jcbSignDirectly = new JCheckBox(); jcbSignDirectly.setSelected(true); jcbSignDirectly.setToolTipText(res.getString("DSignJar.jcbSignDirectly.tooltip")); jlOutputJar = new JLabel(res.getString("DSignJar.jlOutputJar.text")); jtfOutputJar = new JTextField(30); jtfOutputJar.setEnabled(false); jtfOutputJar.setCaretPosition(0); jtfOutputJar.setToolTipText(res.getString("DSignJar.jtfOutputJar.tooltip")); jbOutputJarBrowse = new JButton(res.getString("DSignJar.jbOutputJarBrowse.text")); PlatformUtil.setMnemonic(jbOutputJarBrowse, res.getString("DSignJar.jbOutputJarBrowse.mnemonic").charAt(0)); jbOutputJarBrowse.setToolTipText(res.getString("DSignJar.jbOutputJarBrowse.tooltip")); jbOutputJarBrowse.setEnabled(false); jlSignatureName = new JLabel(res.getString("DSignJar.jlSignatureName.text")); jtfSignatureName = new JTextField(convertSignatureName(signatureName), 15); jtfSignatureName.setCaretPosition(0); jtfSignatureName.setToolTipText(res.getString("DSignJar.jtfSignatureName.tooltip")); jlSignatureAlgorithm = new JLabel(res.getString("DSignJar.jlSignatureAlgorithm.text")); jcbSignatureAlgorithm = new JComboBox<SignatureType>(); DialogHelper.populateSigAlgs(signKeyPairType, this.signPrivateKey, provider, jcbSignatureAlgorithm); jcbSignatureAlgorithm.setToolTipText(res.getString("DSignJar.jcbSignatureAlgorithm.tooltip")); jlDigestAlgorithm = new JLabel(res.getString("DSignJar.jlDigestAlgorithm.text")); jcbDigestAlgorithm = new JComboBox<DigestType>(); populateDigestAlgs(); jcbDigestAlgorithm.setToolTipText(res.getString("DSignJar.jcbDigestAlgorithm.tooltip")); jlAddTimestamp = new JLabel(res.getString("DSignJar.jlAddTimestamp.text")); jcbAddTimestamp = new JCheckBox(); jcbAddTimestamp.setSelected(false); jcbAddTimestamp.setToolTipText(res.getString("DSignJar.jcbAddTimestamp.tooltip")); jlTimestampServerUrl = new JLabel(res.getString("DSignJar.jlTimestampServerUrl.text")); jcbTimestampServerUrl = new JComboBox<String>(); jcbTimestampServerUrl.setEditable(true); jcbTimestampServerUrl.setEnabled(false); jcbTimestampServerUrl.setToolTipText(res.getString("DSignJar.jcbTimestampServerUrl.tooltip")); jcbTimestampServerUrl.setModel(new DefaultComboBoxModel<String>(getTsaUrls())); jbOK = new JButton(res.getString("DSignJar.jbOK.text")); jbCancel = new JButton(res.getString("DSignJar.jbCancel.text")); jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY); jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel); // layout Container pane = getContentPane(); pane.setLayout(new MigLayout("insets dialog, fill", "[para]unrel[right]unrel[]", "[]unrel[]")); MiGUtil.addSeparator(pane, res.getString("DSignJar.jlFiles.text")); pane.add(jlInputJar, "skip"); pane.add(jtfInputJar, "sgx"); pane.add(jbInputJarBrowse, "wrap"); pane.add(jlSignDirectly, "skip"); pane.add(jcbSignDirectly, "wrap"); pane.add(jlOutputJar, "skip"); pane.add(jtfOutputJar, "sgx"); pane.add(jbOutputJarBrowse, "wrap para"); MiGUtil.addSeparator(pane, res.getString("DSignJar.jlSignature.text")); pane.add(jlSignatureName, "skip"); pane.add(jtfSignatureName, "sgx, wrap"); pane.add(jlSignatureAlgorithm, "skip"); pane.add(jcbSignatureAlgorithm, "sgx, wrap"); pane.add(jlDigestAlgorithm, "skip"); pane.add(jcbDigestAlgorithm, "sgx, wrap para"); MiGUtil.addSeparator(pane, res.getString("DSignJar.jlTimestamp.text")); pane.add(jlAddTimestamp, "skip"); pane.add(jcbAddTimestamp, "wrap"); pane.add(jlTimestampServerUrl, "skip"); pane.add(jcbTimestampServerUrl, "sgx, wrap para"); pane.add(new JSeparator(), "spanx, growx, wrap para"); pane.add(jpButtons, "right, spanx"); // actions jbInputJarBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DSignJar.this); inputJarBrowsePressed(); } finally { CursorUtil.setCursorFree(DSignJar.this); } } }); jcbSignDirectly.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { jtfOutputJar.setEnabled(!jcbSignDirectly.isSelected()); jbOutputJarBrowse.setEnabled(!jcbSignDirectly.isSelected()); } }); jbOutputJarBrowse.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { CursorUtil.setCursorBusy(DSignJar.this); outputJarBrowsePressed(); } finally { CursorUtil.setCursorFree(DSignJar.this); } } }); jcbAddTimestamp.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent evt) { jcbTimestampServerUrl.setEnabled(jcbAddTimestamp.isSelected()); } }); jbOK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { okPressed(); } }); jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); jbCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { closeDialog(); } }); setResizable(false); getRootPane().setDefaultButton(jbOK); pack(); setLocationRelativeTo(null); }
From source file:org.kuali.test.creator.TestCreator.java
private void createMenuBar() { JMenuBar mainMenu = new JMenuBar(); JMenuItem menu = new JMenu(); menu.setMnemonic('f'); menu.setText("File"); JMenuItem m = new JMenuItem("Reload Configuration"); m.addActionListener(new ActionListener() { @Override/*from w w w. j ava 2s. c o m*/ public void actionPerformed(ActionEvent evt) { handleReloadConfiguation(evt); } }); menu.add(m); m = new JMenuItem("Schedule Tests..."); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleScheduleTests(evt); } }); menu.add(m); menu.add(new JSeparator()); saveConfigurationMenuItem = new JMenuItem("Save Repository Configuration"); saveConfigurationMenuItem.setEnabled(false); saveConfigurationMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { testRepositoryTree.saveConfiguration(); saveConfigurationButton.setEnabled(false); saveConfigurationMenuItem.setEnabled(false); } }); menu.add(saveConfigurationMenuItem); JMenuItem backupRepositoryMenuItem = new JMenuItem("Backup Repository"); backupRepositoryMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleBackupRepository(); } }); menu.add(backupRepositoryMenuItem); menu.add(new JSeparator()); createTestMenuItem = new JMenuItem("Create Test"); createTestMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleCreateTest(null); } }); menu.add(createTestMenuItem); menu.add(new JSeparator()); JMenuItem setup = new JMenu("Setup"); m = new JMenuItem("Add Platform"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleAddPlatform(evt); } }); setup.add(m); m = new JMenuItem("Add Database Connection"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleAddDatabaseConnection(evt); } }); setup.add(m); m = new JMenuItem("Add Web Service"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleAddWebService(evt); } }); setup.add(m); m = new JMenuItem("Add JMX Connection"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleAddJmxConnection(evt); } }); setup.add(m); setup.add(new JSeparator()); m = new JMenuItem("Parameters requiring encryption"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleParametersRequiringEncryptionSetup(); } }); setup.add(m); m = new JMenuItem("Auto replace parameters"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleAutoReplaceParameterSetup(); } }); setup.add(m); setup.add(new JSeparator()); m = new JMenuItem("Email Setup"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleEmailSetup(evt); } }); setup.add(m); menu.add(setup); menu.add(new JSeparator()); m = new JMenuItem("Exit"); m.setMnemonic('x'); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { exitApplication.doClick(); } }); menu.add(m); mainMenu.add(menu); menu = new JMenu("Help"); menu.setMnemonic('h'); m = new JMenuItem("Contents"); m.setMnemonic('c'); menu.add(m); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { showHelp(evt); } }); m = new JMenuItem("About"); m.setMnemonic('a'); menu.add(m); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { showHelpAbout(); } }); mainMenu.add(menu); setJMenuBar(mainMenu); }
From source file:org.kuali.test.creator.TestCreator.java
private JPanel createToolBar() { JPanel retval = new JPanel(new BorderLayout(2, 2)); JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false);//from ww w. j a va 2 s. c om toolbar.setMargin(new Insets(1, 5, 2, 0)); ToolbarButton b; toolbar.add(b = new ToolbarButton(Constants.PLATFORM_TOOLBAR_ICON, "add platform")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddPlatform(e); } }); toolbar.add(b = new ToolbarButton(Constants.DATABASE_TOOLBAR_ICON, "add database connection")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddDatabaseConnection(e); } }); toolbar.add(b = new ToolbarButton(Constants.JMX_CONNECTION_TOOLBAR_ICON, "add JMX connection")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddJmxConnection(e); } }); toolbar.add(b = new ToolbarButton(Constants.WEB_SERVICE_TOOLBAR_ICON, "add web service")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleAddWebService(e); } }); toolbar.add(b = new ToolbarButton(Constants.SCHEDULE_TEST_TOOLBAR_ICON, "schedule test")); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleScheduleTests(e); } }); toolbar.addSeparator(); toolbar.add(saveConfigurationButton = new ToolbarButton(Constants.SAVE_CONFIGURATION_ICON, "save repository configuration") { @Override public void setEnabled(boolean enabled) { if (enabled) { getConfiguration().setModified(true); } super.setEnabled(enabled); } }); saveConfigurationButton.setEnabled(false); saveConfigurationButton.setMargin(new Insets(1, 1, 1, 1)); saveConfigurationButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleSaveConfiguration(); } }); toolbar.add(createTestButton = new ToolbarButton(Constants.TEST_ICON, "create new test")); createTestButton.setMargin(new Insets(1, 1, 1, 1)); createTestButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { handleCreateTest(null); } }); toolbar.addSeparator(); toolbar.add( exitApplication = new ToolbarButton(Constants.EXIT_APPLICATION_TOOLBAR_ICON, "exit application")); exitApplication.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(TestCreator.this, "Exit Test Application?", "Exit", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { startSpinner("Shutting down application..."); handleExit(0); } } }); toolbar.addSeparator(); toolbar.add(spinner = new Spinner()); toolbar.add(spinner2 = new Spinner(true)); retval.add(new JSeparator(), BorderLayout.NORTH); retval.add(toolbar, BorderLayout.CENTER); this.enableCreateTestActions(havePlatforms()); return retval; }
From source file:org.kuali.test.ui.base.SimpleInputDlg.java
/** * *///from www .j a va2 s. com protected void addStandardButtons() { JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton b; p.add(b = new JButton(Constants.OK_ACTION)); b.addActionListener(this); p.add(b = new JButton(Constants.CANCEL_ACTION)); b.addActionListener(this); JPanel p2 = new JPanel(new BorderLayout()); p2.add(new JSeparator(), BorderLayout.NORTH); p2.add(p, BorderLayout.CENTER); getContentPane().add(p2, BorderLayout.SOUTH); }