List of usage examples for javax.swing ButtonGroup ButtonGroup
public ButtonGroup()
ButtonGroup
. From source file:components.DialogDemo.java
/** Creates the panel shown by the first tab. */ private JPanel createSimpleDialogBox() { final int numButtons = 4; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); JButton showItButton = null;//from ww w .j a v a 2s . c o m final String defaultMessageCommand = "default"; final String yesNoCommand = "yesno"; final String yeahNahCommand = "yeahnah"; final String yncCommand = "ync"; radioButtons[0] = new JRadioButton("OK (in the L&F's words)"); radioButtons[0].setActionCommand(defaultMessageCommand); radioButtons[1] = new JRadioButton("Yes/No (in the L&F's words)"); radioButtons[1].setActionCommand(yesNoCommand); radioButtons[2] = new JRadioButton("Yes/No " + "(in the programmer's words)"); radioButtons[2].setActionCommand(yeahNahCommand); radioButtons[3] = new JRadioButton("Yes/No/Cancel " + "(in the programmer's words)"); radioButtons[3].setActionCommand(yncCommand); for (int i = 0; i < numButtons; i++) { group.add(radioButtons[i]); } radioButtons[0].setSelected(true); showItButton = new JButton("Show it!"); showItButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String command = group.getSelection().getActionCommand(); //ok dialog if (command == defaultMessageCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green."); //yes/no dialog } else if (command == yesNoCommand) { int n = JOptionPane.showConfirmDialog(frame, "Would you like green eggs and ham?", "An Inane Question", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { setLabel("Ewww!"); } else if (n == JOptionPane.NO_OPTION) { setLabel("Me neither!"); } else { setLabel("Come on -- tell me!"); } //yes/no (not in those words) } else if (command == yeahNahCommand) { Object[] options = { "Yes, please", "No way!" }; int n = JOptionPane.showOptionDialog(frame, "Would you like green eggs and ham?", "A Silly Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == JOptionPane.YES_OPTION) { setLabel("You're kidding!"); } else if (n == JOptionPane.NO_OPTION) { setLabel("I don't like them, either."); } else { setLabel("Come on -- 'fess up!"); } //yes/no/cancel (not in those words) } else if (command == yncCommand) { Object[] options = { "Yes, please", "No, thanks", "No eggs, no ham!" }; int n = JOptionPane.showOptionDialog(frame, "Would you like some green eggs to go " + "with that ham?", "A Silly Question", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); if (n == JOptionPane.YES_OPTION) { setLabel("Here you go: green eggs and ham!"); } else if (n == JOptionPane.NO_OPTION) { setLabel("OK, just the ham, then."); } else if (n == JOptionPane.CANCEL_OPTION) { setLabel("Well, I'm certainly not going to eat them!"); } else { setLabel("Please tell me what you want!"); } } return; } }); return createPane(simpleDialogDesc + ":", radioButtons, showItButton); }
From source file:QandE.LunarPhasesRB.java
private void addWidgets() { /*/*from w w w . j a va 2 s . c o m*/ * Create a label for displaying the moon phase images and * put a border around it. */ phaseIconLabel = new JLabel(); phaseIconLabel.setHorizontalAlignment(JLabel.CENTER); phaseIconLabel.setVerticalAlignment(JLabel.CENTER); phaseIconLabel.setVerticalTextPosition(JLabel.CENTER); phaseIconLabel.setHorizontalTextPosition(JLabel.CENTER); phaseIconLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); phaseIconLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0), phaseIconLabel.getBorder())); //Create radio buttons with lunar phase choices. JRadioButton newButton = new JRadioButton("New"); newButton.setActionCommand("0"); newButton.setSelected(true); JRadioButton waxingCrescentButton = new JRadioButton("Waxing Crescent"); waxingCrescentButton.setActionCommand("1"); JRadioButton firstQuarterButton = new JRadioButton("First Quarter"); firstQuarterButton.setActionCommand("2"); JRadioButton waxingGibbousButton = new JRadioButton("Waxing Gibbous"); waxingGibbousButton.setActionCommand("3"); JRadioButton fullButton = new JRadioButton("Full"); fullButton.setActionCommand("4"); JRadioButton waningGibbousButton = new JRadioButton("Waning Gibbous"); waningGibbousButton.setActionCommand("5"); JRadioButton thirdQuarterButton = new JRadioButton("Third Quarter"); thirdQuarterButton.setActionCommand("6"); JRadioButton waningCrescentButton = new JRadioButton("Waning Crescent"); waningCrescentButton.setActionCommand("7"); // Create a button group and add the radio buttons. ButtonGroup group = new ButtonGroup(); group.add(newButton); group.add(waxingCrescentButton); group.add(firstQuarterButton); group.add(waxingGibbousButton); group.add(fullButton); group.add(waningGibbousButton); group.add(thirdQuarterButton); group.add(waningCrescentButton); // Display the first image. phaseIconLabel.setIcon(new ImageIcon("images/image0.jpg")); phaseIconLabel.setText(""); //Make the radio buttons appear in a center-aligned column. selectPanel.setLayout(new BoxLayout(selectPanel, BoxLayout.PAGE_AXIS)); selectPanel.setAlignmentX(Component.CENTER_ALIGNMENT); //Add a border around the select panel. selectPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Select Phase"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Add a border around the display panel. displayPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Display Phase"), BorderFactory.createEmptyBorder(5, 5, 5, 5))); //Add image and moon phases radio buttons to select panel. displayPanel.add(phaseIconLabel); selectPanel.add(newButton); selectPanel.add(waxingCrescentButton); selectPanel.add(firstQuarterButton); selectPanel.add(waxingGibbousButton); selectPanel.add(fullButton); selectPanel.add(waningGibbousButton); selectPanel.add(thirdQuarterButton); selectPanel.add(waningCrescentButton); //Listen to events from the radio buttons. newButton.addActionListener(this); waxingCrescentButton.addActionListener(this); firstQuarterButton.addActionListener(this); waxingGibbousButton.addActionListener(this); fullButton.addActionListener(this); waningGibbousButton.addActionListener(this); thirdQuarterButton.addActionListener(this); waningCrescentButton.addActionListener(this); }
From source file:org.broad.igv.peaks.PeakTrackMenu.java
public void addColorByItems() { addSeparator();/*w w w .j a va 2s .c o m*/ add(new JLabel("Color by")); ButtonGroup group = new ButtonGroup(); colorByScoreMI = new JRadioButtonMenuItem("Score"); colorByScoreMI.setSelected(PeakTrack.getColorOption() == PeakTrack.ColorOption.SCORE); colorByScoreMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PeakTrack.setShadeOption(PeakTrack.ColorOption.SCORE); IGV.getInstance().repaint(); } }); colorByFoldMI = new JRadioButtonMenuItem("Fold change"); colorByFoldMI.setSelected(PeakTrack.getColorOption() == PeakTrack.ColorOption.FOLD_CHANGE); colorByFoldMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { PeakTrack.setShadeOption(PeakTrack.ColorOption.FOLD_CHANGE); IGV.getInstance().repaint(); } }); add(colorByScoreMI); add(colorByFoldMI); group.add(colorByScoreMI); group.add(colorByFoldMI); }
From source file:ca.phon.app.session.editor.TranscriberSelectionDialog.java
/** Init display and listeners */ private void initDialog() { // setup layout // layout will be seperated into two sections, existing // and new transcripts FormLayout outerLayout = new FormLayout("3dlu, pref, right:pref:grow, 3dlu", "pref, 3dlu, top:pref:noGrow, 3dlu, pref, 3dlu, fill:pref:grow, 3dlu, pref"); this.getContentPane().setLayout(outerLayout); // create the 'new' panel first FormLayout newLayout = new FormLayout("left:pref:noGrow, 3dlu, fill:pref:grow", "bottom:pref:noGrow, 3dlu, bottom:pref:noGrow, 3dlu, bottom:pref:noGrow, 3dlu, bottom:pref:noGrow, 3dlu, bottom:pref:noGrow, fill:pref:grow"); JPanel newPanel = new JPanel(newLayout); this.newTranscriptButton = new JRadioButton(); this.newTranscriptButton.setText("New Transcriber"); this.newTranscriptButton.setSelected(true); this.newTranscriptButton.addActionListener(new ActionListener() { @Override//from w w w .j a va2 s . c o m public void actionPerformed(ActionEvent arg0) { realNameField.setEnabled(true); usernameField.setEnabled(true); passwordRequiredBox.setEnabled(true); if (passwordRequiredBox.isSelected()) { passwordField.setEnabled(true); checkField.setEnabled(true); } existingUserList.setEnabled(false); } }); this.existingTranscriptButton = new JRadioButton(); this.existingTranscriptButton.setText("Existing Transcriber"); this.existingTranscriptButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { realNameField.setEnabled(false); usernameField.setEnabled(false); passwordRequiredBox.setEnabled(false); passwordField.setEnabled(false); checkField.setEnabled(false); existingUserList.setEnabled(true); } }); ButtonGroup bg = new ButtonGroup(); bg.add(this.newTranscriptButton); bg.add(this.existingTranscriptButton); this.realNameField = new JTextField(); this.usernameField = new JTextField(); this.passwordRequiredBox = new JCheckBox(); this.passwordRequiredBox.setText("Use password"); this.passwordRequiredBox.setSelected(false); this.passwordRequiredBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { passwordField.setEnabled(passwordRequiredBox.isSelected()); checkField.setEnabled(passwordRequiredBox.isSelected()); } }); this.passwordField = new JPasswordField(); this.passwordField.setEnabled(false); this.checkField = new JPasswordField(); this.checkField.setEnabled(false); CellConstraints cc = new CellConstraints(); newPanel.add(new JLabel("Full Name:"), cc.xy(1, 1)); newPanel.add(this.realNameField, cc.xy(3, 1)); newPanel.add(new JLabel("Username:"), cc.xy(1, 3)); newPanel.add(this.usernameField, cc.xy(3, 3)); newPanel.add(this.passwordRequiredBox, cc.xyw(1, 5, 3)); newPanel.add(new JLabel("Password:"), cc.xy(1, 7)); newPanel.add(this.passwordField, cc.xy(3, 7)); newPanel.add(this.checkField, cc.xy(3, 9)); // create the 'existing' panel FormLayout existingLayout = new FormLayout( // just a list "fill:pref:grow", "fill:pref:grow"); JPanel existingPanel = new JPanel(existingLayout); List<String> existingUserData = new ArrayList<String>(); for (Transcriber t : session.getTranscribers()) existingUserData.add(t.getRealName() + " - " + t.getUsername()); this.existingUserList = new JList(existingUserData.toArray()); this.existingUserList.setEnabled(false); existingPanel.add(this.existingUserList, cc.xy(1, 1)); // create the button panel this.okButton = new JButton("OK"); this.okButton.setDefaultCapable(true); this.okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (checkDialog()) { okHandler(); } } }); getRootPane().setDefaultButton(okButton); this.cancelButton = new JButton("Cancel"); this.cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { cancelHandler(); } }); final JComponent bar = ButtonBarBuilder.buildOkCancelBar(okButton, cancelButton); this.getContentPane().add(bar, cc.xy(3, 9)); this.getContentPane().add(this.newTranscriptButton, cc.xy(2, 1)); this.getContentPane().add(newPanel, cc.xyw(2, 3, 2)); this.getContentPane().add(this.existingTranscriptButton, cc.xy(2, 5)); this.getContentPane().add(new JScrollPane(existingPanel), cc.xyw(2, 7, 2)); }
From source file:components.FrameDemo2.java
protected JComponent createOptionControls() { JLabel label1 = new JLabel("Decoration options for subsequently created frames:"); ButtonGroup bg1 = new ButtonGroup(); JLabel label2 = new JLabel("Icon options:"); ButtonGroup bg2 = new ButtonGroup(); //Create the buttons JRadioButton rb1 = new JRadioButton(); rb1.setText("Look and feel decorated"); rb1.setActionCommand(LF_DECORATIONS); rb1.addActionListener(this); rb1.setSelected(true);/*from w w w . j av a 2 s . co m*/ bg1.add(rb1); // JRadioButton rb2 = new JRadioButton(); rb2.setText("Window system decorated"); rb2.setActionCommand(WS_DECORATIONS); rb2.addActionListener(this); bg1.add(rb2); // JRadioButton rb3 = new JRadioButton(); rb3.setText("No decorations"); rb3.setActionCommand(NO_DECORATIONS); rb3.addActionListener(this); bg1.add(rb3); // // JRadioButton rb4 = new JRadioButton(); rb4.setText("Default icon"); rb4.setActionCommand(DEFAULT_ICON); rb4.addActionListener(this); rb4.setSelected(true); bg2.add(rb4); // JRadioButton rb5 = new JRadioButton(); rb5.setText("Icon from a JPEG file"); rb5.setActionCommand(FILE_ICON); rb5.addActionListener(this); bg2.add(rb5); // JRadioButton rb6 = new JRadioButton(); rb6.setText("Painted icon"); rb6.setActionCommand(PAINT_ICON); rb6.addActionListener(this); bg2.add(rb6); //Add everything to a container. Box box = Box.createVerticalBox(); box.add(label1); box.add(Box.createVerticalStrut(5)); //spacer box.add(rb1); box.add(rb2); box.add(rb3); // box.add(Box.createVerticalStrut(15)); //spacer box.add(label2); box.add(Box.createVerticalStrut(5)); //spacer box.add(rb4); box.add(rb5); box.add(rb6); //Add some breathing room. box.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return box; }
From source file:net.sf.jabref.gui.journals.ManageJournalsPanel.java
public ManageJournalsPanel(final JabRefFrame frame) { this.frame = frame; personalFile.setEditable(false);/*from w w w.j a v a2 s .c om*/ ButtonGroup group = new ButtonGroup(); group.add(newFile); group.add(oldFile); addExtPan.setLayout(new BorderLayout()); JButton addExt = new JButton(IconTheme.JabRefIcon.ADD.getIcon()); addExtPan.add(addExt, BorderLayout.EAST); addExtPan.setToolTipText(Localization.lang("Add")); FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:200dlu:grow, 4dlu, fill:pref", "pref, pref, pref, 20dlu, 20dlu, fill:200dlu, 4dlu, pref"); FormBuilder builder = FormBuilder.create().layout(layout); builder.addSeparator(Localization.lang("Built-in journal list")).xyw(2, 1, 6); JLabel description = new JLabel( "<HTML>" + Localization.lang("JabRef includes a built-in list of journal abbreviations.") + "<br>" + Localization.lang( "You can add additional journal names by setting up a personal journal list,<br>as " + "well as linking to external journal lists.") + "</HTML>"); description.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); builder.add(description).xyw(2, 2, 6); JButton viewBuiltin = new JButton(Localization.lang("View")); builder.add(viewBuiltin).xy(7, 2); builder.addSeparator(Localization.lang("Personal journal list")).xyw(2, 3, 6); builder.add(newFile).xy(3, 4); builder.add(newNameTf).xy(5, 4); JButton browseNew = new JButton(Localization.lang("Browse")); builder.add(browseNew).xy(7, 4); builder.add(oldFile).xy(3, 5); builder.add(personalFile).xy(5, 5); JButton browseOld = new JButton(Localization.lang("Browse")); builder.add(browseOld).xy(7, 5); userPanel.setLayout(new BorderLayout()); builder.add(userPanel).xyw(2, 6, 4); ButtonStackBuilder butBul = new ButtonStackBuilder(); butBul.addButton(add); butBul.addButton(remove); butBul.addGlue(); builder.add(butBul.getPanel()).xy(7, 6); builder.addSeparator(Localization.lang("External files")).xyw(2, 8, 6); externalFilesPanel.setLayout(new BorderLayout()); setLayout(new BorderLayout()); builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(builder.getPanel(), BorderLayout.NORTH); add(externalFilesPanel, BorderLayout.CENTER); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); JButton ok = new JButton(Localization.lang("OK")); bb.addButton(ok); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addUnrelatedGap(); JButton help = new HelpAction(HelpFile.JOURNAL_ABBREV).getHelpButton(); bb.addButton(help); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); dialog = new JDialog(frame, Localization.lang("Journal abbreviations"), false); dialog.getContentPane().add(this, BorderLayout.CENTER); dialog.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); // Set up panel for editing a single journal, to be used in a dialog box: FormLayout layout2 = new FormLayout("right:pref, 4dlu, fill:180dlu", "p, 2dlu, p"); FormBuilder builder2 = FormBuilder.create().layout(layout2); builder2.add(Localization.lang("Journal name")).xy(1, 1); builder2.add(nameTf).xy(3, 1); builder2.add(Localization.lang("ISO abbreviation")).xy(1, 3); builder2.add(abbrTf).xy(3, 3); journalEditPanel = builder2.getPanel(); viewBuiltin.addActionListener(e -> { JTable table = new JTable(JournalAbbreviationsUtil.getTableModel(Globals.journalAbbreviationLoader .getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs)) .getAbbreviations())); JScrollPane pane = new JScrollPane(table); JOptionPane.showMessageDialog(null, pane, Localization.lang("Journal list preview"), JOptionPane.INFORMATION_MESSAGE); }); browseNew.addActionListener(e -> { Path old = null; if (!newNameTf.getText().isEmpty()) { old = Paths.get(newNameTf.getText()); } String name = FileDialogs.getNewFile(frame, old.toFile(), null, JFileChooser.SAVE_DIALOG, false); if (name != null) { newNameTf.setText(name); newFile.setSelected(true); } }); browseOld.addActionListener(e -> { Path old = null; if (!personalFile.getText().isEmpty()) { old = Paths.get(personalFile.getText()); } String name = FileDialogs.getNewFile(frame, old.toFile(), null, JFileChooser.OPEN_DIALOG, false); if (name != null) { personalFile.setText(name); oldFile.setSelected(true); oldFile.setEnabled(true); setupUserTable(); } }); ok.addActionListener(e -> { if (readyToClose()) { storeSettings(); dialog.dispose(); } }); Action cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; cancel.addActionListener(cancelAction); add.addActionListener(tableModel); remove.addActionListener(tableModel); addExt.addActionListener(e -> { externals.add(new ExternalFileEntry()); buildExternalsPanel(); }); // Key bindings: ActionMap am = getActionMap(); InputMap im = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelAction); int xSize = getPreferredSize().width; dialog.setSize(xSize + 10, 700); }
From source file:net.sf.jhylafax.AbstractFaxDialog.java
protected void addDateControls() { dateNowRadionButton = new JRadioButton(); dateNowRadionButton.setSelected(true); dateLabel = builder.append("", dateNowRadionButton); builder.nextLine();/*from www . jav a 2 s . c om*/ dateLaterRadionButton = new JRadioButton(); dateModel = new SpinnerDateModel(); final JSpinner dateSpinner = new JSpinner(dateModel); dateSpinner.setEnabled(false); dateLaterRadionButton.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { dateSpinner.setEnabled(dateLaterRadionButton.isSelected()); } }); builder.append("", dateLaterRadionButton, dateSpinner); builder.nextLine(); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(dateNowRadionButton); buttonGroup.add(dateLaterRadionButton); }
From source file:com.floreantpos.ui.OrderFilterPanel.java
private void createPaymentStatusFilterPanel() { btnFilterByOpenStatus = new POSToggleButton(PaymentStatusFilter.OPEN.toString()); btnFilterByPaidStatus = new POSToggleButton(PaymentStatusFilter.PAID.toString()); btnFilterByUnPaidStatus = new POSToggleButton(PaymentStatusFilter.CLOSED.toString()); final ButtonGroup paymentGroup = new ButtonGroup(); paymentGroup.add(btnFilterByOpenStatus); paymentGroup.add(btnFilterByPaidStatus); paymentGroup.add(btnFilterByUnPaidStatus); PaymentStatusFilter paymentStatusFilter = TerminalConfig.getPaymentStatusFilter(); switch (paymentStatusFilter) { case OPEN:/*from w w w .jav a 2s.c o m*/ btnFilterByOpenStatus.setSelected(true); break; case PAID: btnFilterByPaidStatus.setSelected(true); break; case CLOSED: btnFilterByUnPaidStatus.setSelected(true); break; } ActionListener psFilterHandler = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String actionCommand = e.getActionCommand(); if (actionCommand.equals("CLOSED") && !Application.getCurrentUser().hasPermission(UserPermission.VIEW_ALL_CLOSE_TICKETS)) { String password = PasswordEntryDialog.show(Application.getPosWindow(), "Please enter privileged password"); if (StringUtils.isEmpty(password)) { updateButton(); return; } User user2 = UserDAO.getInstance().findUserBySecretKey(password); if (user2 == null) { POSMessageDialog.showError(Application.getPosWindow(), "No user found with that secret key"); updateButton(); return; } else { if (!user2.hasPermission(UserPermission.VIEW_ALL_CLOSE_TICKETS)) { POSMessageDialog.showError(Application.getPosWindow(), "No permission"); updateButton(); return; } } } String filter = actionCommand.replaceAll("\\s", "_"); //$NON-NLS-1$ //$NON-NLS-2$ TerminalConfig.setPaymentStatusFilter(filter); ticketList.updateTicketList(); ticketLists.updateButtonStatus(); } }; btnFilterByOpenStatus.addActionListener(psFilterHandler); btnFilterByPaidStatus.addActionListener(psFilterHandler); btnFilterByUnPaidStatus.addActionListener(psFilterHandler); JPanel filterByPaymentStatusPanel = new JPanel(new MigLayout("", "fill, grow", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ filterByPaymentStatusPanel.setBorder(new TitledBorder(Messages.getString("SwitchboardView.3"))); //$NON-NLS-1$ filterByPaymentStatusPanel.add(btnFilterByOpenStatus); filterByPaymentStatusPanel.add(btnFilterByPaidStatus); filterByPaymentStatusPanel.add(btnFilterByUnPaidStatus); getContentPane().add(filterByPaymentStatusPanel); }
From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java
private JMenu createViewMenu() { JMenu viewMenu = new JMenu("View"); viewMenu.setMnemonic('v'); JMenu lnfMenu = new JMenu("Look and Feel"); lnfMenu.setMnemonic('f'); ButtonGroup lnfGroup = new ButtonGroup(); LookAndFeelInfo lnfs[] = UIManager.getInstalledLookAndFeels(); String lnfCurrentName = null; LookAndFeel lnfCurrent = UIManager.getLookAndFeel(); if (lnfCurrent != null) { lnfCurrentName = lnfCurrent.getClass().getName(); }/*from w w w . ja v a 2 s . c o m*/ UISwitcher switcher = new UISwitcher(); for (int i = 0; i < lnfs.length; i++) { JRadioButtonMenuItem lnfItem = new JRadioButtonMenuItem(lnfs[i].getName()); lnfItem.addActionListener(switcher); lnfItem.setActionCommand(lnfs[i].getClassName()); lnfGroup.add(lnfItem); lnfMenu.add(lnfItem); if (lnfs[i].getClassName().equals(lnfCurrentName)) { lnfGroup.setSelected(lnfItem.getModel(), true); } } viewMenu.add(lnfMenu); return viewMenu; }
From source file:canreg.client.gui.dataentry.ImportView.java
/** * Creates new form ImportView//from w w w. j a va 2 s.c o m */ public ImportView() { initComponents(); previewPanel.setVisible(false); globalToolBox = CanRegClientApp.getApplication().getGlobalToolBox(); changeTab(0); // Add a listener for changing the active tab ChangeListener tabbedPaneChangeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { initializeVariableMappingTab(); changeTab(tabbedPane.getSelectedIndex()); } }; // And add the listener to the tabbedPane tabbedPane.addChangeListener(tabbedPaneChangeListener); localSettings = CanRegClientApp.getApplication().getLocalSettings(); path = localSettings.getProperty("import_path"); if (path == null) { chooser = new JFileChooser(); } else { chooser = new JFileChooser(path); } // Group the radiobuttons ButtonGroup discrepanciesButtonGroup = new ButtonGroup(); // Add to the button group discrepanciesButtonGroup.add(rejectRadioButton); discrepanciesButtonGroup.add(updateRadioButton); discrepanciesButtonGroup.add(overwriteRadioButton); // Get the system description doc = CanRegClientApp.getApplication().getDatabseDescription(); variablesInDB = canreg.common.Tools.getVariableListElements(doc, Globals.NAMESPACE); // get the available charsets SortedMap<String, Charset> charsets = Charset.availableCharsets(); charsetsComboBox.setModel(new javax.swing.DefaultComboBoxModel(charsets.values().toArray())); // set the default mapping charsetsComboBox.setSelectedItem(globalToolBox.getStandardCharset()); // initializeVariableMappingTab(); }