List of usage examples for javax.swing JSeparator JSeparator
public JSeparator()
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
private JMenuBar initMenuBar() { JMenuBar menubar = new JMenuBar(); {//from ww w .j a v a2s .c om JMenu menu = new JMenu("Synchronisation"); { JMenuItem m = new JMenuItem("Kurse auswhlen"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { chooseCourses(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Automatische Synchronisation"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showAutoSyncSettings(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Neue Dateien zeigen"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showNewFiles(); } }); menu.add(m); } menubar.add(menu); } { JMenu menu = new JMenu("Einstellungen"); { JMenuItem m = new JMenuItem("Speicherpfad ndern"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeBaseDir(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Speicherpfad ffnen"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openBaseDir(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Maximale Dateigre ndern"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeMaxFileSize(); } }); menu.add(m); } { final JCheckBoxMenuItem menuitem = new JCheckBoxMenuItem( "Benachrichtigungen im Systemtray anzeigen"); menuitem.setSelected(iliasProperties.isShowNotifications()); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { iliasProperties.setShowNotifications(!iliasProperties.isShowNotifications()); saveProperties(iliasProperties); menuitem.setSelected(iliasProperties.isShowNotifications()); } }); menu.add(menuitem); } { menu.add(new JSeparator()); } { JMenuItem m = new JMenuItem("Design ndern"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeLookAndFeel(); } }); menu.add(m); } { menu.add(new JSeparator()); } { JMenuItem m = new JMenuItem("Server einstellen"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { chooseServer(); } }); menu.add(m); } menubar.add(menu); } { JMenu menu = new JMenu("Hilfe"); { JMenuItem m = new JMenuItem("Fehler melden, Feedback geben"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFeedbackPage(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Webseite"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openWebsite(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Android App"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openAndroidWebsite(); } }); menu.add(m); } { JMenuItem m = new JMenuItem("Info"); m.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showInfo(); } }); menu.add(m); } menubar.add(menu); } return menubar; }
From source file:com._17od.upm.gui.AccountDialog.java
public AccountDialog(AccountInformation account, JFrame parentWindow, boolean readOnly, ArrayList existingAccounts) { super(parentWindow, true); boolean addingAccount = false; //Request focus on Account JDialog when mouse clicked this.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 1) { requestFocus();//from ww w . ja va 2s. c om } } }); // Set the title based on weather we've been opened in readonly mode and // weather the // Account passed in is empty or not String title = null; if (readOnly) { title = Translator.translate("viewAccount"); } else if (!readOnly && account.getAccountName().trim().equals("")) { title = Translator.translate("addAccount"); addingAccount = true; } else { title = Translator.translate("editAccount"); } setTitle(title); this.pAccount = account; this.existingAccounts = existingAccounts; this.parentWindow = parentWindow; getContentPane().setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); Container container = getContentPane(); // The AccountName Row JLabel accountLabel = new JLabel(Translator.translate("account")); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(10, 10, 10, 10); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; container.add(accountLabel, c); // This panel will hold the Account field and the copy and paste // buttons. JPanel accountPanel = new JPanel(new GridBagLayout()); accountName = new JTextField(new String(pAccount.getAccountName()), 20); if (readOnly) { accountName.setEditable(false); } c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; accountPanel.add(accountName, c); accountName.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { accountName.selectAll(); } }); JButton acctCopyButton = new JButton(); acctCopyButton.setIcon(Util.loadImage("copy-icon.png")); acctCopyButton.setToolTipText("Copy"); acctCopyButton.setEnabled(true); acctCopyButton.setMargin(new Insets(0, 0, 0, 0)); acctCopyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { copyTextField(accountName); } }); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; accountPanel.add(acctCopyButton, c); JButton acctPasteButton = new JButton(); acctPasteButton.setIcon(Util.loadImage("paste-icon.png")); acctPasteButton.setToolTipText("Paste"); acctPasteButton.setEnabled(!readOnly); acctPasteButton.setMargin(new Insets(0, 0, 0, 0)); acctPasteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { pasteToTextField(accountName); } }); c.gridx = 2; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; accountPanel.add(acctPasteButton, c); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(10, 10, 10, 10); c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; container.add(accountPanel, c); // Userid Row JLabel useridLabel = new JLabel(Translator.translate("userid")); c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(10, 10, 10, 10); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; container.add(useridLabel, c); // This panel will hold the User ID field and the copy and paste // buttons. JPanel idPanel = new JPanel(new GridBagLayout()); userId = new JTextField(new String(pAccount.getUserId()), 20); if (readOnly) { userId.setEditable(false); } c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; idPanel.add(userId, c); userId.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { userId.selectAll(); } }); JButton idCopyButton = new JButton(); idCopyButton.setIcon(Util.loadImage("copy-icon.png")); idCopyButton.setToolTipText("Copy"); idCopyButton.setEnabled(true); idCopyButton.setMargin(new Insets(0, 0, 0, 0)); idCopyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { copyTextField(userId); } }); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; idPanel.add(idCopyButton, c); JButton idPasteButton = new JButton(); idPasteButton.setIcon(Util.loadImage("paste-icon.png")); idPasteButton.setToolTipText("Paste"); idPasteButton.setEnabled(!readOnly); idPasteButton.setMargin(new Insets(0, 0, 0, 0)); idPasteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { pasteToTextField(userId); } }); c.gridx = 2; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; idPanel.add(idPasteButton, c); c.gridx = 1; c.gridy = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(10, 10, 10, 10); c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; container.add(idPanel, c); // Password Row JLabel passwordLabel = new JLabel(Translator.translate("password")); c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.FIRST_LINE_START; c.insets = new Insets(15, 10, 10, 10); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; container.add(passwordLabel, c); // This panel will hold the password, generate password button, copy and // paste buttons, and hide password checkbox JPanel passwordPanel = new JPanel(new GridBagLayout()); password = new JPasswordField(new String(pAccount.getPassword()), 20); // allow CTRL-C on the password field password.putClientProperty("JPasswordField.cutCopyAllowed", Boolean.TRUE); password.setEditable(!readOnly); password.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { password.selectAll(); } }); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; passwordPanel.add(password, c); JButton generateRandomPasswordButton = new JButton(Translator.translate("generate")); if (readOnly) { generateRandomPasswordButton.setEnabled(false); } generateRandomPasswordButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionevent) { // Get the user's preference about including or not Escape // Characters to generated passwords Boolean includeEscapeChars = new Boolean( Preferences.get(Preferences.ApplicationOptions.INCLUDE_ESCAPE_CHARACTERS, "true")); int pwLength = Preferences.getInt(Preferences.ApplicationOptions.ACCOUNT_PASSWORD_LENGTH, 8); String Password; if ((includeEscapeChars.booleanValue()) && (pwLength > 3)) { // Verify that the generated password satisfies the criteria // for strong passwords(including Escape Characters) do { Password = GeneratePassword(pwLength, includeEscapeChars.booleanValue()); } while (!(CheckPassStrong(Password, includeEscapeChars.booleanValue()))); } else if (!(includeEscapeChars.booleanValue()) && (pwLength > 2)) { // Verify that the generated password satisfies the criteria // for strong passwords(excluding Escape Characters) do { Password = GeneratePassword(pwLength, includeEscapeChars.booleanValue()); } while (!(CheckPassStrong(Password, includeEscapeChars.booleanValue()))); } else { // Else a weak password of 3 or less chars will be produced Password = GeneratePassword(pwLength, includeEscapeChars.booleanValue()); } password.setText(Password); } }); if (addingAccount) { generateRandomPasswordButton.doClick(); } c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; passwordPanel.add(generateRandomPasswordButton, c); JButton pwCopyButton = new JButton(); pwCopyButton.setIcon(Util.loadImage("copy-icon.png")); pwCopyButton.setToolTipText("Copy"); pwCopyButton.setEnabled(true); pwCopyButton.setMargin(new Insets(0, 0, 0, 0)); pwCopyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { copyTextField(password); } }); c.gridx = 2; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; passwordPanel.add(pwCopyButton, c); JButton pwPasteButton = new JButton(); pwPasteButton.setIcon(Util.loadImage("paste-icon.png")); pwPasteButton.setToolTipText("Paste"); pwPasteButton.setEnabled(!readOnly); pwPasteButton.setMargin(new Insets(0, 0, 0, 0)); pwPasteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { pasteToTextField(password); } }); c.gridx = 3; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; passwordPanel.add(pwPasteButton, c); JCheckBox hidePasswordCheckbox = new JCheckBox(Translator.translate("hide"), true); defaultEchoChar = password.getEchoChar(); hidePasswordCheckbox.setMargin(new Insets(5, 0, 5, 0)); hidePasswordCheckbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { password.setEchoChar(defaultEchoChar); } else { password.setEchoChar((char) 0); } } }); Boolean hideAccountPassword = new Boolean( Preferences.get(Preferences.ApplicationOptions.ACCOUNT_HIDE_PASSWORD, "true")); hidePasswordCheckbox.setSelected(hideAccountPassword.booleanValue()); c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 0); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; passwordPanel.add(hidePasswordCheckbox, c); c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(10, 10, 10, 10); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; container.add(passwordPanel, c); // URL Row JLabel urlLabel = new JLabel(Translator.translate("url")); c.gridx = 0; c.gridy = 3; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(10, 10, 10, 10); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; container.add(urlLabel, c); // This panel will hold the URL field and the copy and paste buttons. JPanel urlPanel = new JPanel(new GridBagLayout()); url = new JTextField(new String(pAccount.getUrl()), 20); if (readOnly) { url.setEditable(false); } c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; urlPanel.add(url, c); url.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { url.selectAll(); } }); final JButton urlLaunchButton = new JButton(); urlLaunchButton.setIcon(Util.loadImage("launch-url-sm.png")); urlLaunchButton.setToolTipText("Launch URL"); urlLaunchButton.setEnabled(true); urlLaunchButton.setMargin(new Insets(0, 0, 0, 0)); urlLaunchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { String urlText = url.getText(); // Check if the selected url is null or emty and inform the user // via JoptioPane message if ((urlText == null) || (urlText.length() == 0)) { JOptionPane.showMessageDialog(urlLaunchButton.getParent(), Translator.translate("EmptyUrlJoptionpaneMsg"), Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE); // Check if the selected url is a valid formated url(via // urlIsValid() method) and inform the user via JoptioPane // message } else if (!(urlIsValid(urlText))) { JOptionPane.showMessageDialog(urlLaunchButton.getParent(), Translator.translate("InvalidUrlJoptionpaneMsg"), Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE); // Call the method LaunchSelectedURL() using the selected // url as input } else { LaunchSelectedURL(urlText); } } }); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; urlPanel.add(urlLaunchButton, c); JButton urlCopyButton = new JButton(); urlCopyButton.setIcon(Util.loadImage("copy-icon.png")); urlCopyButton.setToolTipText("Copy"); urlCopyButton.setEnabled(true); urlCopyButton.setMargin(new Insets(0, 0, 0, 0)); urlCopyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { copyTextField(url); } }); c.gridx = 2; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; urlPanel.add(urlCopyButton, c); JButton urlPasteButton = new JButton(); urlPasteButton.setIcon(Util.loadImage("paste-icon.png")); urlPasteButton.setToolTipText("Paste"); urlPasteButton.setEnabled(!readOnly); urlPasteButton.setMargin(new Insets(0, 0, 0, 0)); urlPasteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { pasteToTextField(url); } }); c.gridx = 3; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; urlPanel.add(urlPasteButton, c); c.gridx = 1; c.gridy = 3; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(10, 10, 10, 10); c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; container.add(urlPanel, c); // Notes Row JLabel notesLabel = new JLabel(Translator.translate("notes")); c.gridx = 0; c.gridy = 4; c.anchor = GridBagConstraints.FIRST_LINE_START; c.insets = new Insets(10, 10, 10, 10); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; container.add(notesLabel, c); // This panel will hold the Notes text area and the copy and paste // buttons. JPanel notesPanel = new JPanel(new GridBagLayout()); notes = new JTextArea(new String(pAccount.getNotes()), 10, 20); if (readOnly) { notes.setEditable(false); } notes.setLineWrap(true); // Enable line wrapping. notes.setWrapStyleWord(true); // Line wrap at whitespace. JScrollPane notesScrollPane = new JScrollPane(notes); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.fill = GridBagConstraints.BOTH; notesPanel.add(notesScrollPane, c); JButton notesCopyButton = new JButton(); notesCopyButton.setIcon(Util.loadImage("copy-icon.png")); notesCopyButton.setToolTipText("Copy"); notesCopyButton.setEnabled(true); notesCopyButton.setMargin(new Insets(0, 0, 0, 0)); notesCopyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { copyTextArea(notes); } }); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; notesPanel.add(notesCopyButton, c); JButton notesPasteButton = new JButton(); notesPasteButton.setIcon(Util.loadImage("paste-icon.png")); notesPasteButton.setToolTipText("Paste"); notesPasteButton.setEnabled(!readOnly); notesPasteButton.setMargin(new Insets(0, 0, 0, 0)); notesPasteButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { pasteToTextArea(notes); } }); c.gridx = 2; c.gridy = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; c.insets = new Insets(0, 0, 0, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; notesPanel.add(notesPasteButton, c); c.gridx = 1; c.gridy = 4; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(10, 10, 10, 10); c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; container.add(notesPanel, c); // Seperator Row JSeparator sep = new JSeparator(); c.gridx = 0; c.gridy = 5; c.anchor = GridBagConstraints.PAGE_END; c.insets = new Insets(0, 0, 0, 0); c.weightx = 0; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; container.add(sep, c); // Button Row JPanel buttonPanel = new JPanel(); JButton okButton = new JButton(Translator.translate("ok")); // Link Enter key to okButton getRootPane().setDefaultButton(okButton); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButtonAction(); } }); buttonPanel.add(okButton); if (!readOnly) { JButton cancelButton = new JButton(Translator.translate("cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeButtonAction(); } }); buttonPanel.add(cancelButton); } c.gridx = 0; c.gridy = 6; c.anchor = GridBagConstraints.PAGE_END; c.insets = new Insets(5, 0, 5, 0); c.weightx = 0; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; container.add(buttonPanel, c); }
From source file:org.esa.beam.visat.toolviews.stat.ScatterPlotPanel.java
private JPanel createInputParameterPanel() { final PropertyDescriptor boxSizeDescriptor = bindingContext.getPropertySet() .getDescriptor(PROPERTY_NAME_BOX_SIZE); boxSizeDescriptor.setValueRange(new ValueRange(1, 101)); boxSizeDescriptor.setAttribute("stepSize", 2); boxSizeDescriptor.setValidator(new Validator() { @Override//from ww w . j av a 2s .c om public void validateValue(Property property, Object value) throws ValidationException { if (((Number) value).intValue() % 2 == 0) { throw new ValidationException("Only odd values allowed as box size."); } } }); final JSpinner boxSizeSpinner = new JSpinner(); bindingContext.bind(PROPERTY_NAME_BOX_SIZE, boxSizeSpinner); final JPanel boxSizePanel = new JPanel(new BorderLayout(5, 3)); boxSizePanel.add(new JLabel("Box size:"), BorderLayout.WEST); boxSizePanel.add(boxSizeSpinner); correlativeFieldSelector = new CorrelativeFieldSelector(bindingContext); final JPanel pointDataSourcePanel = new JPanel(new BorderLayout(5, 3)); pointDataSourcePanel.add(correlativeFieldSelector.pointDataSourceLabel, BorderLayout.NORTH); pointDataSourcePanel.add(correlativeFieldSelector.pointDataSourceList); final JPanel pointDataFieldPanel = new JPanel(new BorderLayout(5, 3)); pointDataFieldPanel.add(correlativeFieldSelector.dataFieldLabel, BorderLayout.NORTH); pointDataFieldPanel.add(correlativeFieldSelector.dataFieldList); final JCheckBox xLogCheck = new JCheckBox("Log10 scaled"); bindingContext.bind(PROPERTY_NAME_X_AXIS_LOG_SCALED, xLogCheck); final JPanel xAxisOptionPanel = new JPanel(new BorderLayout()); xAxisOptionPanel.add(xAxisRangeControl.getPanel()); xAxisOptionPanel.add(xLogCheck, BorderLayout.SOUTH); final JCheckBox yLogCheck = new JCheckBox("Log10 scaled"); bindingContext.bind(PROPERTY_NAME_Y_AXIS_LOG_SCALED, yLogCheck); final JPanel yAxisOptionPanel = new JPanel(new BorderLayout()); yAxisOptionPanel.add(yAxisRangeControl.getPanel()); yAxisOptionPanel.add(yLogCheck, BorderLayout.SOUTH); final JCheckBox acceptableCheck = new JCheckBox("Show tolerance range"); JLabel fieldPrefix = new JLabel("+/-"); final JTextField acceptableField = new JTextField(); acceptableField.setPreferredSize(new Dimension(40, acceptableField.getPreferredSize().height)); acceptableField.setHorizontalAlignment(JTextField.RIGHT); final JLabel percentLabel = new JLabel(" %"); bindingContext.bind(PROPERTY_NAME_SHOW_ACCEPTABLE_DEVIATION, acceptableCheck); bindingContext.bind(PROPERTY_NAME_ACCEPTABLE_DEVIATION, acceptableField); bindingContext.getBinding(PROPERTY_NAME_ACCEPTABLE_DEVIATION).addComponent(percentLabel); bindingContext.getBinding(PROPERTY_NAME_ACCEPTABLE_DEVIATION).addComponent(fieldPrefix); bindingContext.bindEnabledState(PROPERTY_NAME_ACCEPTABLE_DEVIATION, true, PROPERTY_NAME_SHOW_ACCEPTABLE_DEVIATION, true); final JPanel confidencePanel = GridBagUtils.createPanel(); GridBagConstraints confidencePanelConstraints = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=5,weighty=0,weightx=1"); GridBagUtils.addToPanel(confidencePanel, acceptableCheck, confidencePanelConstraints, "gridy=0,gridwidth=3"); GridBagUtils.addToPanel(confidencePanel, fieldPrefix, confidencePanelConstraints, "weightx=0,insets.left=22,gridy=1,gridx=0,insets.top=4,gridwidth=1"); GridBagUtils.addToPanel(confidencePanel, acceptableField, confidencePanelConstraints, "weightx=1,gridx=1,insets.left=2,insets.top=2"); GridBagUtils.addToPanel(confidencePanel, percentLabel, confidencePanelConstraints, "weightx=0,gridx=2,insets.left=0,insets.top=4"); final JCheckBox regressionCheck = new JCheckBox("Show regression line"); bindingContext.bind(PROPERTY_NAME_SHOW_REGRESSION_LINE, regressionCheck); // UI arrangement JPanel middlePanel = GridBagUtils.createPanel(); GridBagConstraints middlePanelConstraints = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=6,weighty=0,weightx=1"); GridBagUtils.addToPanel(middlePanel, boxSizePanel, middlePanelConstraints, "gridy=0,insets.left=6"); GridBagUtils.addToPanel(middlePanel, pointDataSourcePanel, middlePanelConstraints, "gridy=1"); GridBagUtils.addToPanel(middlePanel, pointDataFieldPanel, middlePanelConstraints, "gridy=2"); GridBagUtils.addToPanel(middlePanel, xAxisOptionPanel, middlePanelConstraints, "gridy=3,insets.left=0"); GridBagUtils.addToPanel(middlePanel, yAxisOptionPanel, middlePanelConstraints, "gridy=4"); GridBagUtils.addToPanel(middlePanel, new JSeparator(), middlePanelConstraints, "gridy=5,insets.left=4"); GridBagUtils.addToPanel(middlePanel, confidencePanel, middlePanelConstraints, "gridy=6,fill=HORIZONTAL,insets.left=-4"); GridBagUtils.addToPanel(middlePanel, regressionCheck, middlePanelConstraints, "gridy=7,insets.left=-4,insets.top=8"); return middlePanel; }
From source file:com.mirth.connect.connectors.http.HttpListener.java
private void initComponentsManual() { staticResourcesTable.setModel(new RefreshTableModel(StaticResourcesColumn.getNames(), 0) { @Override//from w w w.j a va 2 s .co m public boolean isCellEditable(int rowIndex, int columnIndex) { return true; } }); staticResourcesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); staticResourcesTable.setRowHeight(UIConstants.ROW_HEIGHT); staticResourcesTable.setFocusable(true); staticResourcesTable.setSortable(false); staticResourcesTable.setOpaque(true); staticResourcesTable.setDragEnabled(false); staticResourcesTable.getTableHeader().setReorderingAllowed(false); staticResourcesTable.setShowGrid(true, true); staticResourcesTable.setAutoCreateColumnsFromModel(false); staticResourcesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); staticResourcesTable.setRowSelectionAllowed(true); staticResourcesTable.setCustomEditorControls(true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { staticResourcesTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } class ContextPathCellEditor extends TextFieldCellEditor { public ContextPathCellEditor() { getTextField().setDocument(new MirthFieldConstraints("^\\S*$")); } @Override protected boolean valueChanged(String value) { if (StringUtils.isEmpty(value) || value.equals("/")) { return false; } if (value.equals(getOriginalValue())) { return false; } for (int i = 0; i < staticResourcesTable.getRowCount(); i++) { if (value.equals(fixContentPath((String) staticResourcesTable.getValueAt(i, StaticResourcesColumn.CONTEXT_PATH.getIndex())))) { return false; } } parent.setSaveEnabled(true); return true; } @Override public Object getCellEditorValue() { String value = fixContentPath((String) super.getCellEditorValue()); String baseContextPath = getBaseContextPath(); if (value.equals(baseContextPath)) { return null; } else { return fixContentPath(StringUtils.removeStartIgnoreCase(value, baseContextPath + "/")); } } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { String resourceContextPath = fixContentPath((String) value); setOriginalValue(resourceContextPath); getTextField().setText(getBaseContextPath() + resourceContextPath); return getTextField(); } } ; staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTEXT_PATH.getIndex()) .setCellEditor(new ContextPathCellEditor()); staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTEXT_PATH.getIndex()) .setCellRenderer(new DefaultTableCellRenderer() { @Override protected void setValue(Object value) { super.setValue(getBaseContextPath() + fixContentPath((String) value)); } }); class ResourceTypeCellEditor extends MirthComboBoxTableCellEditor implements ActionListener { private Object originalValue; public ResourceTypeCellEditor(JTable table, Object[] items, int clickCount, boolean focusable) { super(table, items, clickCount, focusable, null); for (ActionListener actionListener : comboBox.getActionListeners()) { comboBox.removeActionListener(actionListener); } comboBox.addActionListener(this); } @Override public boolean stopCellEditing() { if (ObjectUtils.equals(getCellEditorValue(), originalValue)) { cancelCellEditing(); } else { parent.setSaveEnabled(true); } return super.stopCellEditing(); } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { originalValue = value; return super.getTableCellEditorComponent(table, value, isSelected, row, column); } @Override public void actionPerformed(ActionEvent evt) { ((AbstractTableModel) staticResourcesTable.getModel()).fireTableCellUpdated( staticResourcesTable.getSelectedRow(), StaticResourcesColumn.VALUE.getIndex()); stopCellEditing(); fireEditingStopped(); } } String[] resourceTypes = ResourceType.stringValues(); staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()).setMinWidth(100); staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()).setMaxWidth(100); staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()) .setCellEditor(new ResourceTypeCellEditor(staticResourcesTable, resourceTypes, 1, false)); staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()) .setCellRenderer(new MirthComboBoxTableCellRenderer(resourceTypes)); class ValueCellEditor extends AbstractCellEditor implements TableCellEditor { private JPanel panel; private JLabel label; private JTextField textField; private String text; private String originalValue; public ValueCellEditor() { panel = new JPanel(new MigLayout("insets 0 1 0 0, novisualpadding, hidemode 3")); panel.setBackground(UIConstants.BACKGROUND_COLOR); label = new JLabel(); label.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { new ValueDialog(); stopCellEditing(); } }); panel.add(label, "grow, pushx, h 19!"); textField = new JTextField(); panel.add(textField, "grow, pushx, h 19!"); } @Override public boolean isCellEditable(EventObject evt) { if (evt == null) { return false; } if (evt instanceof MouseEvent) { return ((MouseEvent) evt).getClickCount() >= 2; } return true; } @Override public Object getCellEditorValue() { if (label.isVisible()) { return text; } else { return textField.getText(); } } @Override public boolean stopCellEditing() { if (ObjectUtils.equals(getCellEditorValue(), originalValue)) { cancelCellEditing(); } else { parent.setSaveEnabled(true); } return super.stopCellEditing(); } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { boolean custom = table.getValueAt(row, StaticResourcesColumn.RESOURCE_TYPE.getIndex()) .equals(ResourceType.CUSTOM.toString()); label.setVisible(custom); textField.setVisible(!custom); panel.setBackground(table.getSelectionBackground()); label.setBackground(panel.getBackground()); label.setMaximumSize(new Dimension(table.getColumnModel().getColumn(column).getWidth(), 19)); String text = (String) value; this.text = text; originalValue = text; label.setText(text); textField.setText(text); return panel; } class ValueDialog extends MirthDialog { public ValueDialog() { super(parent, true); setTitle("Custom Value"); setPreferredSize(new Dimension(600, 500)); setLayout(new MigLayout("insets 12, novisualpadding, hidemode 3, fill", "", "[grow]7[]")); setBackground(UIConstants.BACKGROUND_COLOR); getContentPane().setBackground(getBackground()); final MirthSyntaxTextArea textArea = new MirthSyntaxTextArea(); textArea.setSaveEnabled(false); textArea.setText(text); textArea.setBorder(BorderFactory.createEtchedBorder()); add(textArea, "grow"); add(new JSeparator(), "newline, grow"); JPanel buttonPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3")); buttonPanel.setBackground(getBackground()); JButton openFileButton = new JButton("Open File..."); openFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { String content = parent.browseForFileString(null); if (content != null) { textArea.setText(content); } } }); buttonPanel.add(openFileButton); JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { text = textArea.getText(); label.setText(text); textField.setText(text); staticResourcesTable.getModel().setValueAt(text, staticResourcesTable.getSelectedRow(), StaticResourcesColumn.VALUE.getIndex()); parent.setSaveEnabled(true); dispose(); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { dispose(); } }); buttonPanel.add(cancelButton); add(buttonPanel, "newline, right"); pack(); setLocationRelativeTo(parent); setVisible(true); } } } ; staticResourcesTable.getColumnExt(StaticResourcesColumn.VALUE.getIndex()) .setCellEditor(new ValueCellEditor()); staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex()).setMinWidth(100); staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex()).setMaxWidth(150); staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex()) .setCellEditor(new TextFieldCellEditor() { @Override protected boolean valueChanged(String value) { if (value.equals(getOriginalValue())) { return false; } parent.setSaveEnabled(true); return true; } }); staticResourcesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (getSelectedRow(staticResourcesTable) != -1) { staticResourcesLastIndex = getSelectedRow(staticResourcesTable); staticResourcesDeleteButton.setEnabled(true); } else { staticResourcesDeleteButton.setEnabled(false); } } }); contextPathField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent evt) { changedUpdate(evt); } @Override public void removeUpdate(DocumentEvent evt) { changedUpdate(evt); } @Override public void changedUpdate(DocumentEvent evt) { ((AbstractTableModel) staticResourcesTable.getModel()).fireTableDataChanged(); } }); staticResourcesDeleteButton.setEnabled(false); }
From source file:org.jets3t.apps.cockpit.Cockpit.java
/** * Initialise the application's menu bar. *///from ww w . j a va2 s .c o m private void initMenus() { JMenuBar appMenuBar = new JMenuBar(); if (this.isStandAloneApplication && OS_NAME_MAC.equals(System.getProperty("os.name"))) { /* * We need to check we're running on a Mac before adding the menu to the * owner frame, otherwise the menus will be displayed *behind* the main * GUI panel on Windows Vista and later [sigh] */ ownerFrame.setJMenuBar(appMenuBar); } else { this.setJMenuBar(appMenuBar); } // Service menu JMenu serviceMenu = new JMenu("Service"); loginMenuItem = new JMenuItem("Log in..."); loginMenuItem.setActionCommand("LoginEvent"); loginMenuItem.addActionListener(this); guiUtils.applyIcon(loginMenuItem, "/images/nuvola/16x16/actions/connect_creating.png"); serviceMenu.add(loginMenuItem); logoutMenuItem = new JMenuItem("Log out"); logoutMenuItem.setActionCommand("LogoutEvent"); logoutMenuItem.addActionListener(this); guiUtils.applyIcon(logoutMenuItem, "/images/nuvola/16x16/actions/connect_no.png"); serviceMenu.add(logoutMenuItem); loginSwitchMenu = new JMenu("Switch login"); loginSwitchMenu.addActionListener(this); serviceMenu.add(new JSeparator()); guiUtils.applyIcon(loginSwitchMenu, "/images/nuvola/16x16/actions/connect_established.png"); serviceMenu.add(loginSwitchMenu); loginSwitchMenu.setEnabled(false); if (isStandAloneApplication) { serviceMenu.add(new JSeparator()); JMenuItem quitMenuItem = new JMenuItem("Quit"); quitMenuItem.setActionCommand("QuitEvent"); quitMenuItem.addActionListener(this); guiUtils.applyIcon(quitMenuItem, "/images/nuvola/16x16/actions/exit.png"); serviceMenu.add(quitMenuItem); } logoutMenuItem.setEnabled(false); // Bucket action menu. bucketActionMenu = new JPopupMenu(); refreshBucketMenuItem = new JMenuItem("Refresh bucket listing"); refreshBucketMenuItem.setActionCommand("RefreshBuckets"); refreshBucketMenuItem.addActionListener(this); guiUtils.applyIcon(refreshBucketMenuItem, "/images/nuvola/16x16/actions/reload.png"); bucketActionMenu.add(refreshBucketMenuItem); viewBucketPropertiesMenuItem = new JMenuItem("View bucket properties..."); viewBucketPropertiesMenuItem.setActionCommand("ViewBucketProperties"); viewBucketPropertiesMenuItem.addActionListener(this); guiUtils.applyIcon(viewBucketPropertiesMenuItem, "/images/nuvola/16x16/actions/viewmag.png"); bucketActionMenu.add(viewBucketPropertiesMenuItem); updateBucketACLMenuItem = new JMenuItem("Update bucket's Access Control List..."); updateBucketACLMenuItem.setActionCommand("UpdateBucketACL"); updateBucketACLMenuItem.addActionListener(this); guiUtils.applyIcon(updateBucketACLMenuItem, "/images/nuvola/16x16/actions/encrypted.png"); bucketActionMenu.add(updateBucketACLMenuItem); updateBucketRequesterPaysStatusMenuItem = new JMenuItem("Update bucket's Requester Pays status..."); updateBucketRequesterPaysStatusMenuItem.setActionCommand("UpdateBucketRequesterPaysStatus"); updateBucketRequesterPaysStatusMenuItem.addActionListener(this); guiUtils.applyIcon(updateBucketRequesterPaysStatusMenuItem, "/images/nuvola/16x16/actions/identity.png"); bucketActionMenu.add(updateBucketRequesterPaysStatusMenuItem); bucketActionMenu.add(new JSeparator()); createBucketMenuItem = new JMenuItem("Create new bucket..."); createBucketMenuItem.setActionCommand("CreateBucket"); createBucketMenuItem.addActionListener(this); guiUtils.applyIcon(createBucketMenuItem, "/images/nuvola/16x16/actions/viewmag+.png"); bucketActionMenu.add(createBucketMenuItem); JMenuItem thirdPartyBucketMenuItem = new JMenuItem("Add third-party bucket..."); thirdPartyBucketMenuItem.setActionCommand("AddThirdPartyBucket"); thirdPartyBucketMenuItem.addActionListener(this); guiUtils.applyIcon(thirdPartyBucketMenuItem, "/images/nuvola/16x16/actions/viewmagfit.png"); bucketActionMenu.add(thirdPartyBucketMenuItem); bucketActionMenu.add(new JSeparator()); deleteBucketMenuItem = new JMenuItem("Delete bucket..."); deleteBucketMenuItem.setActionCommand("DeleteBucket"); deleteBucketMenuItem.addActionListener(this); guiUtils.applyIcon(deleteBucketMenuItem, "/images/nuvola/16x16/actions/cancel.png"); bucketActionMenu.add(deleteBucketMenuItem); viewBucketPropertiesMenuItem.setEnabled(false); refreshBucketMenuItem.setEnabled(false); createBucketMenuItem.setEnabled(false); updateBucketACLMenuItem.setEnabled(false); updateBucketRequesterPaysStatusMenuItem.setEnabled(false); deleteBucketMenuItem.setEnabled(false); // Object action menu. objectActionMenu = new JPopupMenu(); refreshObjectMenuItem = new JMenuItem("Refresh object listing"); refreshObjectMenuItem.setActionCommand("RefreshObjects"); refreshObjectMenuItem.addActionListener(this); guiUtils.applyIcon(refreshObjectMenuItem, "/images/nuvola/16x16/actions/reload.png"); objectActionMenu.add(refreshObjectMenuItem); viewOrModifyObjectAttributesMenuItem = new JMenuItem("View or Modify object attributes..."); viewOrModifyObjectAttributesMenuItem.setActionCommand("ViewOrModifyObjectAttributes"); viewOrModifyObjectAttributesMenuItem.addActionListener(this); guiUtils.applyIcon(viewOrModifyObjectAttributesMenuItem, "/images/nuvola/16x16/actions/viewmag.png"); objectActionMenu.add(viewOrModifyObjectAttributesMenuItem); copyObjectsMenuItem = new JMenuItem("Copy or Move objects..."); copyObjectsMenuItem.setActionCommand("CopyObjects"); copyObjectsMenuItem.addActionListener(this); guiUtils.applyIcon(copyObjectsMenuItem, "/images/nuvola/16x16/actions/filenew.png"); objectActionMenu.add(copyObjectsMenuItem); updateObjectACLMenuItem = new JMenuItem("View or Modify Access Control Lists..."); updateObjectACLMenuItem.setActionCommand("UpdateObjectACL"); updateObjectACLMenuItem.addActionListener(this); guiUtils.applyIcon(updateObjectACLMenuItem, "/images/nuvola/16x16/actions/encrypted.png"); objectActionMenu.add(updateObjectACLMenuItem); downloadObjectMenuItem = new JMenuItem("Download objects..."); downloadObjectMenuItem.setActionCommand("DownloadObjects"); downloadObjectMenuItem.addActionListener(this); guiUtils.applyIcon(downloadObjectMenuItem, "/images/nuvola/16x16/actions/1downarrow.png"); objectActionMenu.add(downloadObjectMenuItem); uploadFilesMenuItem = new JMenuItem("Upload files..."); uploadFilesMenuItem.setActionCommand("UploadFiles"); uploadFilesMenuItem.addActionListener(this); guiUtils.applyIcon(uploadFilesMenuItem, "/images/nuvola/16x16/actions/1uparrow.png"); objectActionMenu.add(uploadFilesMenuItem); objectActionMenu.add(new JSeparator()); generatePublicGetUrls = new JMenuItem("Generate Public GET URLs..."); generatePublicGetUrls.setActionCommand("GeneratePublicGetURLs"); generatePublicGetUrls.addActionListener(this); guiUtils.applyIcon(generatePublicGetUrls, "/images/nuvola/16x16/actions/wizard.png"); objectActionMenu.add(generatePublicGetUrls); generateTorrentUrl = new JMenuItem("Generate Torrent URL..."); generateTorrentUrl.setActionCommand("GenerateTorrentURL"); generateTorrentUrl.addActionListener(this); guiUtils.applyIcon(generateTorrentUrl, "/images/nuvola/16x16/actions/wizard.png"); objectActionMenu.add(generateTorrentUrl); objectActionMenu.add(new JSeparator()); deleteObjectMenuItem = new JMenuItem("Delete objects..."); deleteObjectMenuItem.setActionCommand("DeleteObjects"); deleteObjectMenuItem.addActionListener(this); guiUtils.applyIcon(deleteObjectMenuItem, "/images/nuvola/16x16/actions/cancel.png"); objectActionMenu.add(deleteObjectMenuItem); viewOrModifyObjectAttributesMenuItem.setEnabled(false); copyObjectsMenuItem.setEnabled(false); refreshObjectMenuItem.setEnabled(false); updateObjectACLMenuItem.setEnabled(false); downloadObjectMenuItem.setEnabled(false); uploadFilesMenuItem.setEnabled(false); generatePublicGetUrls.setEnabled(false); generateTorrentUrl.setEnabled(false); deleteObjectMenuItem.setEnabled(false); // Tools menu. JMenu toolsMenu = new JMenu("Tools"); bucketLoggingMenuItem = new JMenuItem("Configure Bucket logging..."); bucketLoggingMenuItem.setActionCommand("BucketLogging"); bucketLoggingMenuItem.addActionListener(this); bucketLoggingMenuItem.setEnabled(false); guiUtils.applyIcon(bucketLoggingMenuItem, "/images/nuvola/16x16/actions/toggle_log.png"); toolsMenu.add(bucketLoggingMenuItem); manageDistributionsMenuItem = new JMenuItem("CloudFront Distributions..."); manageDistributionsMenuItem.setActionCommand("ManageDistributions"); manageDistributionsMenuItem.addActionListener(this); guiUtils.applyIcon(manageDistributionsMenuItem, "/images/nuvola/16x16/actions/irkick.png"); manageDistributionsMenuItem.setEnabled(false); toolsMenu.add(manageDistributionsMenuItem); toolsMenu.add(new JSeparator()); preferencesDialogMenuItem = new JMenuItem("Preferences..."); preferencesDialogMenuItem.setActionCommand("PreferencesDialog"); preferencesDialogMenuItem.addActionListener(this); guiUtils.applyIcon(preferencesDialogMenuItem, "/images/nuvola/16x16/actions/configure.png"); toolsMenu.add(preferencesDialogMenuItem); // Help menu. JMenu helpMenu = new JMenu("Help"); cockpitHelpMenuItem = new JMenuItem("Cockpit Guide"); guiUtils.applyIcon(cockpitHelpMenuItem, "/images/nuvola/16x16/actions/help.png"); cockpitHelpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { followHyperlink(new URL(JETS3T_COCKPIT_HELP_PAGE), "_blank"); } catch (MalformedURLException ex) { throw new IllegalStateException("Invalid URL embedded in program: " + JETS3T_COCKPIT_HELP_PAGE); } } }); helpMenu.add(cockpitHelpMenuItem); amazonS3HelpMenuItem = new JMenuItem("Amazon S3"); guiUtils.applyIcon(amazonS3HelpMenuItem, "/images/nuvola/16x16/actions/gohome.png"); amazonS3HelpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { followHyperlink(new URL(AMAZON_S3_PAGE), "_blank"); } catch (MalformedURLException ex) { throw new IllegalStateException("Invalid URL embedded in program: " + AMAZON_S3_PAGE); } } }); helpMenu.add(amazonS3HelpMenuItem); // Build application menu bar. appMenuBar.add(serviceMenu); appMenuBar.add(toolsMenu); appMenuBar.add(helpMenu); }
From source file:com.github.lindenb.jvarkit.tools.bamviewgui.BamFileRef.java
BamFrame(List<BamFileRef> BamFileRefs) { super((JFrame) null, "Bam View (" + BamFileRefs.size() + " files)", ModalityType.APPLICATION_MODAL); this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); this.BamFileRefs = BamFileRefs; addWindowListener(new WindowAdapter() { @Override/*from w w w . j av a 2s . com*/ public void windowOpened(WindowEvent e) { removeWindowListener(this); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); d.width -= 150; d.height -= 150; for (BamFileRef vfr : BamFrame.this.BamFileRefs) { LOG.info("Reading " + vfr.bamFile); int w = (int) (d.width * 0.8); int h = (int) (d.height * 0.8); BamInternalFrame iFrame = new BamInternalFrame(vfr); iFrame.setBounds(Math.max((int) ((d.width - w) * Math.random()), 0), Math.max((int) ((d.height - h) * Math.random()), 0), w, h); desktopPane.add(iFrame); BamInternalFrames.add(iFrame); iFrame.setVisible(true); iFrame.jTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { JTable t = (JTable) e.getSource(); int row = t.getSelectedRow(); if (row == -1) return; BamTableModel tm = (BamTableModel) t.getModel(); showIgv(tm.getValueAt(row, 0), tm.getValueAt(row, 1)); } } }); } reloadFrameContent(); } }); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { doMenuClose(); } }); JMenuBar bar = new JMenuBar(); setJMenuBar(bar); JMenu menu = new JMenu("File"); bar.add(menu); menu.add(new AbstractAction("Quit") { @Override public void actionPerformed(ActionEvent e) { doMenuClose(); } }); menu = new JMenu("Flags"); bar.add(menu); for (SamFlag flag : SamFlag.values()) { JCheckBox cbox = new JCheckBox("Require " + flag); requiredFlags.add(cbox); menu.add(cbox); } menu.add(new JSeparator()); for (SamFlag flag : SamFlag.values()) { JCheckBox cbox = new JCheckBox("Filter out " + flag); filteringFlags.add(cbox); menu.add(cbox); } JPanel contentPane = new JPanel(new BorderLayout(5, 5)); setContentPane(contentPane); this.desktopPane = new JDesktopPane(); contentPane.add(this.desktopPane, BorderLayout.CENTER); JPanel top = new JPanel(new FlowLayout(FlowLayout.LEADING)); contentPane.add(top, BorderLayout.NORTH); JLabel lbl = new JLabel("Max Rows:", JLabel.LEADING); JSpinner spinner = new JSpinner(this.numFetchModel = new SpinnerNumberModel(100, 1, 10000, 10)); lbl.setLabelFor(spinner); top.add(lbl); top.add(spinner); lbl = new JLabel("Timeout (secs):", JLabel.LEADING); spinner = new JSpinner(this.numSecondsModel = new SpinnerNumberModel(2, 1, 10000, 1)); lbl.setLabelFor(spinner); top.add(lbl); top.add(spinner); //lbl=new JLabel("JEXL:",JLabel.LEADING); /*jexlField=new JTextField(20); lbl.setLabelFor(jexlField); top.add(lbl); top.add(jexlField);*/ lbl = new JLabel("Region:", JLabel.LEADING); selectRgnField = new JTextField(20); lbl.setLabelFor(selectRgnField); AbstractAction action = new AbstractAction("Select") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent a) { if ( /* (jexlField.getText().trim().isEmpty() || parseJex(jexlField.getText().trim())!=null) && */ (selectRgnField.getText().trim().isEmpty() || parseOne(selectRgnField.getText()) != null)) { reloadFrameContent(); } else { LOG.info("Bad input " + selectRgnField.getText()); } } }; selectRgnField.addActionListener(action); //jexlField.addActionListener(action); top.add(lbl); top.add(selectRgnField); top.add(new JButton(action)); }
From source file:at.becast.youploader.gui.FrmMain.java
public void initMenuBar() { JMenuBar mnuBar = new JMenuBar(); JMenu mnuFile = new JMenu(); JMenuItem mnuQuit = new JMenuItem(); mnuAcc = new JMenu(); mnuFile.setText(LANG.getString("frmMain.menu.File")); mnuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK)); mnuQuit.setText(LANG.getString("frmMain.menu.Quit")); mnuQuit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mnuQuitActionPerformed();/*from w w w . j a v a 2 s . co m*/ } }); mnuFile.add(mnuQuit); mnuBar.add(mnuFile); mnuAcc.setText(LANG.getString("frmMain.menu.Account")); mnuBar.add(mnuAcc); JSeparator separator = new JSeparator(); JMenuItem mntmAddAccount = new JMenuItem(LANG.getString("frmMain.menu.AddAccount")); mntmAddAccount.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mntmAddAccountActionPerformed(); } }); mnuAcc.add(mntmAddAccount); mnuAcc.add(separator); JMenu mnLanguage = new JMenu("Language"); mnLanguage.setVisible(false); mnLanguage.setEnabled(false); mnuBar.add(mnLanguage); JMenu menu = new JMenu("?"); mnuBar.add(menu); JMenuItem mntmDonate = new JMenuItem(LANG.getString("frmMain.menu.Donate")); menu.add(mntmDonate); mntmDonate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { donateButton(); } }); JMenuItem mntmAbout = new JMenuItem(LANG.getString("frmMain.menu.About")); mntmAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { FrmAbout about = new FrmAbout(); about.setVisible(true); } }); menu.add(mntmAbout); JMenuItem mntmShowLogfile = new JMenuItem(LANG.getString("frmMain.menu.ShowLogfile")); mntmShowLogfile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DesktopUtil.openDir(new File(System.getProperty("user.home") + "/YouPloader")); } }); menu.add(mntmShowLogfile); JMenuItem mntmUploadLogfile = new JMenuItem(LANG.getString("frmMain.menu.UploadLatestLogfile")); mntmUploadLogfile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DesktopUtil.openDir(new File(System.getProperty("user.home") + "/YouPloader")); } }); menu.add(mntmUploadLogfile); chckbxmntmCheckForUpdates = new JCheckBoxMenuItem(LANG.getString("frmMain.menu.CheckforUpdates")); menu.add(chckbxmntmCheckForUpdates); if (Main.s.setting.get("notify_updates").equals("1")) { chckbxmntmCheckForUpdates.setSelected(true); } chckbxmntmCheckForUpdates.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { toggleUpdateNotifier(); } }); setJMenuBar(mnuBar); }
From source file:jchrest.gui.Shell.java
private JMenu createShellMenu() { JMenuItem exit = new JMenuItem("Exit", new ImageIcon(Shell.class.getResource("icons/Stop16.gif"))); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0);/*w w w . ja v a 2 s . c o m*/ } }); JMenu menu = new JMenu("Shell"); menu.setMnemonic(KeyEvent.VK_S); menu.add(new AboutAction(this)); menu.getItem(0).setMnemonic(KeyEvent.VK_A); menu.add(new LookFeelAction(this)); menu.getItem(1).setMnemonic(KeyEvent.VK_T); menu.add(new JSeparator()); menu.add(exit); menu.getItem(3).setMnemonic(KeyEvent.VK_X); menu.getItem(0).setAccelerator(KeyStroke.getKeyStroke('A', java.awt.Event.CTRL_MASK, false)); menu.getItem(3).setAccelerator(KeyStroke.getKeyStroke('X', java.awt.Event.CTRL_MASK, false)); return menu; }
From source file:net.sf.firemox.clickable.target.card.MCard.java
@Override public void mouseClicked(MouseEvent e) { if (!(getParent() instanceof MZone) && !(getParent() instanceof MCard)) { return;//from w w w . j ava2 s . c om } StackManager.noReplayToken.take(); MZone container = getContainer(); try { TargetFactory.triggerTargetable = this; if (ConnectionManager.isConnected() && e.getButton() == MouseEvent.BUTTON1) { // only if left button is pressed if (!StackManager.actionManager.clickOn(this)) { // this card is activated and you control it if (!(StackManager.actionManager.currentAction instanceof WaitingAbility)) { // we are not waiting ability if (container instanceof ExpandableZone) { ((ExpandableZone) container).toggle(); } return; } final List<Ability> abilities = ((WaitingAbility) StackManager.actionManager.currentAction) .abilitiesOf(this); final List<Ability> advAbilities = ((WaitingAbility) StackManager.actionManager.currentAction) .advancedAbilitiesOf(this); // is there any playable ability with this card ? if ((abilities == null || abilities.isEmpty()) && (advAbilities == null || advAbilities.isEmpty())) { // no playable ability, and this card is not wait for -> toggle if (container instanceof ExpandableZone) { ((ExpandableZone) container).toggle(); } return; } // a choice has to be made if (advAbilities != null && !advAbilities.isEmpty() || abilities != null && abilities.size() > 1) { /* * several abilities for this card, we fill the popup ability menu */ TargetFactory.abilitiesMenu.removeAll(); if (abilities != null) { for (Ability ability : abilities) { final JMenuItem item = new JMenuItem( "<html>" + ability.toHtmlString(null) + "</html>"); item.addActionListener(this); TargetFactory.abilitiesMenu.add(item); } } if (advAbilities != null && !advAbilities.isEmpty()) { TargetFactory.abilitiesMenu.add(new JSeparator()); for (Ability ability : advAbilities) { final JMenuItem item = new JMenuItem( "<html>" + ability.toHtmlString(null) + "</html>", WARNING_PICTURE); item.addActionListener(this); TargetFactory.abilitiesMenu.add(item); } } // show the option popup menu TargetFactory.abilitiesMenu.show(e.getComponent(), e.getX(), e.getY()); return; } else if (abilities != null && abilities.size() == 1 && (advAbilities == null || advAbilities.isEmpty())) { // only one playable ability, we select it automatically ((UserAbility) abilities.get(0)).mouseClicked(0); } } else if (StackManager.idHandedPlayer != 0) { if (container instanceof ExpandableZone) { ((ExpandableZone) container).toggle(); } } else { // Since this click has been handled, the opponent will be informed on sendClickToOpponent(); StackManager.actionManager.succeedClickOn(this); } } else if (ConnectionManager.isConnected()) { // only if not left button is pressed CardFactory.contextMenu.removeAll(); TargetFactory.triggerTargetable = this; // add counter item CardFactory.countItem.setText(LanguageManager.getString("countcard", container.toString(), String.valueOf(container.getCardCount()))); CardFactory.contextMenu.add(CardFactory.countItem); // add refresh picture item CardFactory.contextMenu.add(CardFactory.reloadPictureItem); // add expand/gather item if (container instanceof ExpandableZone) { if (container == ZoneManager.expandedZone) { CardFactory.contextMenu.add(CardFactory.gatherItem); } else { CardFactory.contextMenu.add(CardFactory.expandItem); } } CardFactory.contextMenu.add(new JSeparator()); // add the "database" item --> activate the tabbed panel CardFactory.contextMenu.add(CardFactory.databaseCardInfoItem); // TODO add "java properties" item --> show an inspect popup. // CardFactory.contextMenu.add(CardFactory.javaDebugItem); // TODO add "show id" option // show the option popup menu CardFactory.contextMenu.show(e.getComponent(), e.getX(), e.getY()); } } catch (Throwable t) { t.printStackTrace(); } finally { StackManager.noReplayToken.release(); } }
From source file:gui.DownloadManagerGUI.java
private JMenuBar initMenuBar() { JMenuBar menuBar = new JMenuBar(); ///////////////////////////////////////////////////////////////////////// JMenu fileMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.fileMenu.name")); exportDataItem = new JMenuItem("Export Data..."); importDataItem = new JMenuItem("Import Data..."); exitItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.exitItem.name")); exitItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.exitItem.iconPath")))); // NOI18N exportDataItem.setEnabled(false);//w ww . j a v a2s .c o m importDataItem.setEnabled(false); // fileMenu.add(exportDataItem); // fileMenu.add(importDataItem); fileMenu.addSeparator(); fileMenu.add(exitItem); ///////////////////////////////////////////////////////////////////////// JMenu windowMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.windowMenu.name")); JMenu showMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.showMenu.name")); prefsItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.prefsItem.name")); prefsItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.prefsItem.iconPath")))); JCheckBoxMenuItem showFormItem = new JCheckBoxMenuItem( messagesBundle.getString("downloadManagerGUI.showFormItem.name")); showFormItem.setSelected(true); showMenu.add(showFormItem); windowMenu.add(showMenu); windowMenu.add(prefsItem); exportDataItem.addActionListener(this); importDataItem.addActionListener(this); exitItem.addActionListener(this); prefsItem.addActionListener(this); ///////////////////////////////////////////////////////////////////////// JMenu downloadsMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.downloadsMenu.name")); newDownloadItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.newDownloadItem.name")); newDownloadItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.newDownloadItem.iconPath")))); openItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.openItem.name")); openFolderItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.openFolderItem.name")); resumeItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.resumeItem.name")); resumeItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.resumeItem.iconPath")))); pauseItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.pauseItem.name")); pauseItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.pauseItem.iconPath")))); pauseAllItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.pauseAllItem.name")); pauseAllItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.pauseAllItem.iconPath")))); clearItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.clearItem.name")); clearItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.clearItem.iconPath")))); clearAllCompletedItem = new JMenuItem( messagesBundle.getString("downloadManagerGUI.clearAllCompletedItem.name")); clearAllCompletedItem.setIcon(new javax.swing.ImageIcon(getClass() .getResource(messagesBundle.getString("downloadManagerGUI.clearAllCompletedItem.iconPath")))); reJoinItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.reJoinItem.name")); reJoinItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.reJoinItem.iconPath")))); reDownloadItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.reDownloadItem.name")); reDownloadItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.reDownloadItem.iconPath")))); moveToQueueItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.moveToQueueItem.name")); removeFromQueueItem = new JMenuItem( messagesBundle.getString("downloadManagerGUI.removeFromQueueItem.name")); propertiesItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.propertiesItem.name")); propertiesItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.propertiesItem.iconPath")))); downloadsMenu.add(newDownloadItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(openItem); downloadsMenu.add(openFolderItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(resumeItem); downloadsMenu.add(pauseItem); downloadsMenu.add(pauseAllItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(clearItem); downloadsMenu.add(clearAllCompletedItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(reJoinItem); downloadsMenu.add(reDownloadItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(moveToQueueItem); downloadsMenu.add(removeFromQueueItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(propertiesItem); newDownloadItem.addActionListener(this); openItem.addActionListener(this); openFolderItem.addActionListener(this); resumeItem.addActionListener(this); pauseItem.addActionListener(this); pauseAllItem.addActionListener(this); clearItem.addActionListener(this); clearAllCompletedItem.addActionListener(this); reDownloadItem.addActionListener(this); moveToQueueItem.addActionListener(this); removeFromQueueItem.addActionListener(this); propertiesItem.addActionListener(this); setStateOfMenuItems(); ///////////////////////////////////////////////////////////////////////// JMenu helpMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.helpMenu.name")); aboutItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.aboutItem.name")); aboutItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.aboutItem.iconPath")))); helpMenu.add(aboutItem); aboutItem.addActionListener(this); menuBar.add(fileMenu); menuBar.add(windowMenu); menuBar.add(downloadsMenu); menuBar.add(helpMenu); showFormItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ev.getSource(); if (menuItem.isSelected()) { mainSplitPane.setDividerLocation((int) categoryPanel.getMinimumSize().getWidth()); } categoryPanel.setVisible(menuItem.isSelected()); } }); fileMenu.setMnemonic(KeyEvent.VK_F); exitItem.setMnemonic(KeyEvent.VK_X); prefsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); importDataItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK)); return menuBar; }