List of usage examples for javax.swing JRadioButton JRadioButton
public JRadioButton(String text)
From source file:JXButtonPanel.java
private JXButtonPanel createRadioJXButtonPanel() { JXButtonPanel panel = new JXButtonPanel(); panel.setLayout(new GridLayout(0, 1)); JRadioButton one = new JRadioButton("One"); panel.add(one);//from w w w. ja va2 s . c o m radioGroup.add(one); JRadioButton two = new JRadioButton("Two"); panel.add(two); radioGroup.add(two); JRadioButton three = new JRadioButton("Three"); panel.add(three); radioGroup.add(three); JRadioButton four = new JRadioButton("Four"); panel.add(four); radioGroup.add(four); one.setSelected(true); panel.setBorder(BorderFactory.createTitledBorder("JXButtonPanel")); return panel; }
From source file:PickTest.java
private void addRadioButton(JPanel panel, ButtonGroup bg, String ownerName, String buttonName, boolean selected) { JRadioButton item;//from w w w. ja va2s. co m item = new JRadioButton(buttonName); item.setName(ownerName); item.addActionListener(this); if (selected) { item.setSelected(true); } panel.add(item); bg.add(item); }
From source file:com.projity.pm.graphic.chart.ChartLegend.java
void initControls() { chartInfo.setAxisPanel(new AxisPanel(chartInfo)); filterComboBox = new TransformComboBox(null, MenuActionConstants.ACTION_CHOOSE_FILTER, TransformComboBoxModel.FILTER); filterComboBox.setView(ViewConfiguration.getView(MenuActionConstants.ACTION_CHARTS)); filterComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (chartInfo.isRestoring()) return; TransformComboBox combo = (TransformComboBox) e.getSource(); CommonTransformFactory factory = (CommonTransformFactory) combo.getSelectedItem(); ((TransformComboBoxModel) combo.getModel()).changeTransform(factory); }//w w w.jav a2 s .com }); initTree(); Object[] fields = getFields(false); workTraces = getListInstance(false); tracesList = workTraces; // start off work tracesScrollPane = new JScrollPane(workTraces); workTraces.setVisibleRowCount(Environment.getStandAlone() ? HasTimeDistributedData.tracesCount : HasTimeDistributedData.serverTracesCount); // final ViewTransformer transformer=ViewConfiguration.getView(MenuActionConstants.ACTION_CHARTS).getTransform(); // final ResourceInTeamFilter hiddenFilter=(ResourceInTeamFilter)transformer.getHiddenFilter(); // teamResources= new JCheckBox(Messages.getString("Text.ShowTeamResourcesOnly")); // teamResources.addItemListener(new ItemListener() { // public void itemStateChanged(ItemEvent e) { // hiddenFilter.setFilterTeam(e.getStateChange() == ItemEvent.SELECTED); // transformer.update(); // } // }); // teamResources.setSelected(hiddenFilter.isFilterTeam()); if (simple) { chartInfo.setTraces(fields); tree.getSelectionModel().setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION); // allow only 1 for histogram selectedOnTop = new JCheckBox(Messages.getString("Text.ShowSelectedOnTop")); //$NON-NLS-1$ selectedOnTop.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { chartInfo.setSelectedOnTop(e.getStateChange() == ItemEvent.SELECTED); Object[] traces = getFields(false); chartInfo.setTraces(traces); workTraces = getListInstance(false); tracesScrollPane.getViewport().add(workTraces); workTraces.setVisibleRowCount(Environment.getStandAlone() ? HasTimeDistributedData.tracesCount : HasTimeDistributedData.serverTracesCount); } }); selectedOnTop.setSelected(chartInfo.isSelectedOnTop()); // start off as histogram return; } costTraces = getListInstance(true); cumulative = new JCheckBox(Messages.getString("Text.Cumulative")); //$NON-NLS-1$ cumulative.setSelected(chartInfo.isCumulative()); // start off as histogram cumulative.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { chartInfo.setCumulative(e.getStateChange() == ItemEvent.SELECTED); } }); histogram = new JCheckBox(Messages.getString("Text.Histogram")); //$NON-NLS-1$ histogram.setSelected(chartInfo.isHistogram()); // start off as histogram histogram.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean histogramSelected = e.getStateChange() == ItemEvent.SELECTED; chartInfo.setHistogram(histogramSelected); if (histogramSelected) { workTraces.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); // allow only 1 for histogram costTraces.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); // allow only 1 for histogram } else { workTraces.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // allow many costTraces.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // allow only 1 for histogram } } }); work = new JRadioButton(Messages.getString("Text.work")); //$NON-NLS-1$ work.setSelected(chartInfo.isWork()); cost = new JRadioButton(Messages.getString("Text.cost")); //$NON-NLS-1$ ItemListener costWork = new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean isCost = e.getSource() == cost; chartInfo.setWork(!isCost); tracesList = isCost ? costTraces : workTraces; tracesScrollPane.getViewport().add(tracesList); if (!chartInfo.isRestoring()) chartInfo.setTraces(tracesList.getSelectedValues()); } }; cost.addItemListener(costWork); work.addItemListener(costWork); ButtonGroup group = new ButtonGroup(); group.add(cost); group.add(work); // by default, always select first item chartInfo.setTraces(new Object[] { fields[0] }); }
From source file:de.adv_online.aaa.profiltool.ProfilDialog.java
private Component createMainTab() { String s;//from w ww . j a v a 2 s . c o m String appSchemaStr; s = options.parameter("appSchemaName"); if (s != null && s.trim().length() > 0) appSchemaStr = s.trim(); else appSchemaStr = ""; String mart; s = options.parameter(paramProfilClass, "Modellart"); if (s != null && s.trim().length() > 0) mart = s.trim(); else mart = ""; String profil; s = options.parameter(paramProfilClass, "Profil"); if (s != null && s.trim().length() > 0) profil = s.trim(); else profil = ""; String quelle; s = options.parameter(paramProfilClass, "Quelle"); if (s != null && s.trim().length() > 0) quelle = s.trim(); else quelle = "Neu_Minimal"; String ziel; s = options.parameter(paramProfilClass, "Ziel"); if (s != null && s.trim().length() > 0) ziel = s.trim(); else ziel = "Datei"; String pfadStr; s = options.parameter(paramProfilClass, "Verzeichnis"); if (s == null || s.trim().length() == 0) pfadStr = ""; else { File f = new File(s.trim()); if (f.exists()) pfadStr = f.getAbsolutePath(); else pfadStr = ""; } String mdlDirStr = eap; final JPanel topPanel = new JPanel(); final JPanel topInnerPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 30, 5)); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS)); topPanel.setBorder(BorderFactory.createEmptyBorder(15, 20, 15, 10)); // Anwendungsschema appSchemaField = new JTextField(35); appSchemaField.setText(appSchemaStr); appSchemaFieldLabel = new JLabel("Name des zu prozessierenden Anwendungsschemas:"); Box asBox = Box.createVerticalBox(); asBox.add(appSchemaFieldLabel); asBox.add(appSchemaField); modellartField = new JTextField(10); modellartField.setText(mart); modellartFieldLabel = new JLabel("Modellart:"); asBox.add(modellartFieldLabel); asBox.add(modellartField); profilField = new JTextField(10); profilField.setText(profil); profilFieldLabel = new JLabel("Profilkennung:"); asBox.add(profilFieldLabel); asBox.add(profilField); topInnerPanel.add(asBox); topPanel.add(topInnerPanel); // Quelle Box quelleBox = Box.createVerticalBox(); final JPanel quellePanel = new JPanel(new GridLayout(4, 1)); quelleGroup = new ButtonGroup(); rbq3ap = new JRadioButton("3ap-Datei"); quellePanel.add(rbq3ap); if (quelle.equals("Datei")) rbq3ap.setSelected(true); rbq3ap.setActionCommand("Datei"); quelleGroup.add(rbq3ap); rbqtv = new JRadioButton("'AAA:Profile' Tagged Values in Modell"); quellePanel.add(rbqtv); if (quelle.equals("Modell")) rbqtv.setSelected(true); rbqtv.setActionCommand("Modell"); quelleGroup.add(rbqtv); rbqmin = new JRadioButton("Neues Minimalprofil erzeugen"); quellePanel.add(rbqmin); if (quelle.equals("Neu_Minimal")) rbqmin.setSelected(true); rbqmin.setActionCommand("Neu_Minimal"); quelleGroup.add(rbqmin); rbqmax = new JRadioButton("Neues Maximalprofil erzeugen"); quellePanel.add(rbqmax); if (quelle.equals("Neu_Maximal")) rbqmax.setSelected(true); rbqmax.setActionCommand("Neu_Maximal"); quelleGroup.add(rbqmax); quelleBorder = new TitledBorder(new LineBorder(Color.black), "Quelle der Profildefinition", TitledBorder.LEFT, TitledBorder.TOP); quellePanel.setBorder(quelleBorder); quelleBox.add(quellePanel); Box zielBox = Box.createVerticalBox(); final JPanel zielPanel = new JPanel(new GridLayout(4, 1)); zielGroup = new ButtonGroup(); rbz3ap = new JRadioButton("3ap-Datei"); zielPanel.add(rbz3ap); if (ziel.equals("Datei")) rbz3ap.setSelected(true); rbz3ap.setActionCommand("Datei"); zielGroup.add(rbz3ap); rbztv = new JRadioButton("'AAA:Profile' Tagged Values in Modell"); zielPanel.add(rbztv); if (ziel.equals("Modell")) rbztv.setSelected(true); rbztv.setActionCommand("Modell"); zielGroup.add(rbztv); rbzbeide = new JRadioButton("Beides"); zielPanel.add(rbzbeide); if (ziel.equals("DateiModell")) rbzbeide.setSelected(true); rbzbeide.setActionCommand("DateiModell"); zielGroup.add(rbzbeide); rbzdel = new JRadioButton("Profilkennung wird aus Modell entfernt"); zielPanel.add(rbzdel); if (ziel.equals("Ohne")) rbzdel.setSelected(true); rbzdel.setActionCommand("Ohne"); zielGroup.add(rbzdel); zielBorder = new TitledBorder(new LineBorder(Color.black), "Ziel der Profildefinition", TitledBorder.LEFT, TitledBorder.TOP); zielPanel.setBorder(zielBorder); zielBox.add(zielPanel); // Pfadangaben Box pfadBox = Box.createVerticalBox(); final JPanel pfadInnerPanel = new JPanel(); Box skBox = Box.createVerticalBox(); pfadFieldLabel = new JLabel("Pfad in dem 3ap-Dateien liegen/geschrieben werden:"); skBox.add(pfadFieldLabel); pfadField = new JTextField(40); pfadField.setText(pfadStr); skBox.add(pfadField); mdlDirFieldLabel = new JLabel("Pfad zum Modell:"); skBox.add(mdlDirFieldLabel); mdlDirField = new JTextField(40); mdlDirField.setText(mdlDirStr); skBox.add(mdlDirField); pfadInnerPanel.add(skBox); pfadBox.add(pfadInnerPanel); final JPanel pfadPanel = new JPanel(); pfadPanel.add(pfadBox); pfadPanel.setBorder( new TitledBorder(new LineBorder(Color.black), "Pfadangaben", TitledBorder.LEFT, TitledBorder.TOP)); // Zusammenstellung Box fileBox = Box.createVerticalBox(); fileBox.add(topPanel); fileBox.add(quellePanel); fileBox.add(zielPanel); fileBox.add(pfadPanel); JPanel panel = new JPanel(new BorderLayout()); panel.add(fileBox, BorderLayout.NORTH); if (profil.isEmpty()) { setModellartOnly = true; disableProfileElements(); } // Listen for changes in the profilkennung profilField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { upd(); } public void removeUpdate(DocumentEvent e) { upd(); } public void insertUpdate(DocumentEvent e) { upd(); } public void upd() { if (!setModellartOnly && profilField.getText().isEmpty()) { setModellartOnly = true; disableProfileElements(); } else if (setModellartOnly && !profilField.getText().isEmpty()) { setModellartOnly = false; enableProfileElements(); } } }); return panel; }
From source file:org.fhcrc.cpl.viewer.quant.gui.QuantitationReviewer.java
/** * Initialize all GUI components and display the UI *//*from w w w. j a v a2s .c o m*/ protected void initGUI() { settingsCLM = new ProteinQuantChartsCLM(false); setTitle("Qurate"); try { setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif"))); } catch (Exception e) { } try { Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewer.xml", this); assert null != contentPanel; } catch (Exception x) { ApplicationContext.errorMessage("error creating dialog", x); throw new RuntimeException(x); } //Menu openFileAction = new OpenFileAction(this); createChartsAction = new CreateChartsAction(); filterPepXMLAction = new FilterPepXMLAction(this); proteinSummaryAction = new ProteinSummaryAction(this); try { JMenuBar jmenu = (JMenuBar) Localizer.getSwingEngine(this) .render("org/fhcrc/cpl/viewer/quant/gui/QuantitationReviewerMenu.xml"); for (int i = 0; i < jmenu.getMenuCount(); i++) jmenu.getMenu(i).getPopupMenu().setLightWeightPopupEnabled(false); this.setJMenuBar(jmenu); } catch (Exception x) { ApplicationContext.errorMessage(TextProvider.getText("ERROR_LOADING_MENUS"), x); throw new RuntimeException(x); } //Global stuff setSize(fullWidth, fullHeight); setContentPane(contentPanel); ListenerHelper helper = new ListenerHelper(this); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(5, 5, 5, 5); gbc.weighty = 1; gbc.weightx = 1; leftPanel.setLayout(new GridBagLayout()); leftPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); //Properties panel stuff propertiesTable = new QuantEvent.QuantEventPropertiesTable(); propertiesScrollPane = new JScrollPane(); propertiesScrollPane.setViewportView(propertiesTable); propertiesScrollPane.setMinimumSize(new Dimension(propertiesWidth, propertiesHeight)); //event summary table; disembodied eventSummaryTable = new QuantEventsSummaryTable(); eventSummaryTable.setVisible(true); ListSelectionModel tableSelectionModel = eventSummaryTable.getSelectionModel(); tableSelectionModel.addListSelectionListener(new EventSummaryTableListSelectionHandler()); JScrollPane eventSummaryScrollPane = new JScrollPane(); eventSummaryScrollPane.setViewportView(eventSummaryTable); eventSummaryScrollPane.setSize(propertiesWidth, propertiesHeight); eventSummaryFrame = new Frame("All Events"); eventSummaryFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { eventSummaryFrame.setVisible(false); } }); eventSummaryFrame.setSize(950, 450); eventSummaryFrame.add(eventSummaryScrollPane); //fields related to navigation navigationPanel = new JPanel(); backButton = new JButton("<"); backButton.setToolTipText("Previous Event"); backButton.setMaximumSize(new Dimension(50, 30)); backButton.setEnabled(false); forwardButton = new JButton(">"); forwardButton.setToolTipText("Next Event"); forwardButton.setMaximumSize(new Dimension(50, 30)); forwardButton.setEnabled(false); showEventSummaryButton = new JButton("Show All"); showEventSummaryButton.setToolTipText("Show all events in a table"); showEventSummaryButton.setEnabled(false); helper.addListener(backButton, "buttonBack_actionPerformed"); helper.addListener(forwardButton, "buttonForward_actionPerformed"); helper.addListener(showEventSummaryButton, "buttonShowEventSummary_actionPerformed"); gbc.fill = GridBagConstraints.NONE; gbc.gridwidth = GridBagConstraints.RELATIVE; gbc.anchor = GridBagConstraints.WEST; navigationPanel.add(backButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; navigationPanel.add(forwardButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; navigationPanel.add(showEventSummaryButton, gbc); gbc.fill = GridBagConstraints.BOTH; navigationPanel.setBorder(BorderFactory.createTitledBorder("Event")); gbc.anchor = GridBagConstraints.PAGE_START; //Fields related to curation of events curationPanel = new JPanel(); curationPanel.setLayout(new GridBagLayout()); curationPanel.setBorder(BorderFactory.createTitledBorder("Curation")); //Quantitation curation JPanel quantCurationPanel = new JPanel(); quantCurationPanel.setLayout(new GridBagLayout()); quantCurationPanel.setBorder(BorderFactory.createTitledBorder("Quantitation")); quantCurationButtonGroup = new ButtonGroup(); JRadioButton unknownRadioButton = new JRadioButton("?"); JRadioButton goodRadioButton = new JRadioButton("Good"); JRadioButton badRadioButton = new JRadioButton("Bad"); onePeakRatioRadioButton = new JRadioButton("1-Peak"); unknownRadioButton.setEnabled(false); goodRadioButton.setEnabled(false); badRadioButton.setEnabled(false); onePeakRatioRadioButton.setEnabled(false); quantCurationButtonGroup.add(unknownRadioButton); quantCurationButtonGroup.add(goodRadioButton); quantCurationButtonGroup.add(badRadioButton); quantCurationButtonGroup.add(onePeakRatioRadioButton); unknownRadioButtonModel = unknownRadioButton.getModel(); goodRadioButtonModel = goodRadioButton.getModel(); badRadioButtonModel = badRadioButton.getModel(); onePeakRadioButtonModel = onePeakRatioRadioButton.getModel(); helper.addListener(unknownRadioButton, "buttonCuration_actionPerformed"); helper.addListener(goodRadioButton, "buttonCuration_actionPerformed"); helper.addListener(badRadioButton, "buttonCuration_actionPerformed"); helper.addListener(onePeakRadioButtonModel, "buttonCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; quantCurationPanel.add(unknownRadioButton, gbc); quantCurationPanel.add(badRadioButton, gbc); quantCurationPanel.add(goodRadioButton, gbc); quantCurationPanel.add(onePeakRatioRadioButton, gbc); gbc.anchor = GridBagConstraints.PAGE_START; //ID curation JPanel idCurationPanel = new JPanel(); idCurationPanel.setLayout(new GridBagLayout()); idCurationPanel.setBorder(BorderFactory.createTitledBorder("ID")); idCurationButtonGroup = new ButtonGroup(); JRadioButton idUnknownRadioButton = new JRadioButton("?"); JRadioButton idGoodRadioButton = new JRadioButton("Good"); JRadioButton idBadRadioButton = new JRadioButton("Bad"); idUnknownRadioButton.setEnabled(false); idGoodRadioButton.setEnabled(false); idBadRadioButton.setEnabled(false); idCurationButtonGroup.add(idUnknownRadioButton); idCurationButtonGroup.add(idGoodRadioButton); idCurationButtonGroup.add(idBadRadioButton); idUnknownRadioButtonModel = idUnknownRadioButton.getModel(); idGoodRadioButtonModel = idGoodRadioButton.getModel(); idBadRadioButtonModel = idBadRadioButton.getModel(); helper.addListener(idUnknownRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idGoodRadioButton, "buttonIDCuration_actionPerformed"); helper.addListener(idBadRadioButton, "buttonIDCuration_actionPerformed"); gbc.anchor = GridBagConstraints.WEST; idCurationPanel.add(idUnknownRadioButton, gbc); idCurationPanel.add(idBadRadioButton, gbc); idCurationPanel.add(idGoodRadioButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; curationPanel.add(quantCurationPanel, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; curationPanel.add(idCurationPanel, gbc); //curation comment commentTextField = new JTextField(); commentTextField.setToolTipText("Comment on this event"); //saves after every keypress. Would be more efficient to save when navigating away or saving to file commentTextField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (quantEvents == null) return; QuantEvent quantEvent = quantEvents.get(displayedEventIndex); //save the comment, being careful about tabs and new lines quantEvent.setComment(commentTextField.getText().replace("\t", " ").replace("\n", " ")); } public void keyTyped(KeyEvent e) { } public void keyPressed(KeyEvent e) { } }); curationPanel.add(commentTextField, gbc); assessmentPanel = new JPanel(); assessmentPanel.setLayout(new GridBagLayout()); assessmentPanel.setBorder(BorderFactory.createTitledBorder("Algorithmic Assessment")); assessmentTypeTextField = new JTextField(); assessmentTypeTextField.setEditable(false); assessmentPanel.add(assessmentTypeTextField, gbc); assessmentDescTextField = new JTextField(); assessmentDescTextField.setEditable(false); assessmentPanel.add(assessmentDescTextField, gbc); //Theoretical peak distribution gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; theoreticalPeaksPanel = new JPanel(); theoreticalPeaksPanel.setBorder(BorderFactory.createTitledBorder("Theoretical Peaks")); theoreticalPeaksPanel.setLayout(new GridBagLayout()); theoreticalPeaksPanel.setMinimumSize(new Dimension(leftPanelWidth - 10, theoreticalPeaksPanelHeight)); theoreticalPeaksPanel.setMaximumSize(new Dimension(1200, theoreticalPeaksPanelHeight)); showTheoreticalPeaks(); //Add everything to the left panel gbc.insets = new Insets(0, 5, 0, 5); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; leftPanel.addComponentListener(new LeftPanelResizeListener()); gbc.weighty = 10; gbc.fill = GridBagConstraints.VERTICAL; leftPanel.add(propertiesScrollPane, gbc); gbc.fill = GridBagConstraints.NONE; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_END; gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(assessmentPanel, gbc); leftPanel.add(theoreticalPeaksPanel, gbc); gbc.fill = GridBagConstraints.HORIZONTAL; leftPanel.add(curationPanel, gbc); leftPanel.add(navigationPanel, gbc); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1; gbc.anchor = GridBagConstraints.PAGE_START; //Chart display multiChartDisplay = new TabbedMultiChartDisplayPanel(); multiChartDisplay.setResizeDelayMS(0); rightPanel.addComponentListener(new RightPanelResizeListener()); rightPanel.add(multiChartDisplay, gbc); //status message messageLabel.setBackground(Color.WHITE); messageLabel.setFont(Font.decode("verdana plain 12")); messageLabel.setText(" "); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); //paranoia. Sometimes it seems Qurate doesn't exit when you close every window addWindowStateListener(new WindowStateListener() { public void windowStateChanged(WindowEvent e) { if (e.getNewState() == WindowEvent.WINDOW_CLOSED) { dispose(); System.exit(0); } } }); }
From source file:com.diversityarrays.kdxplore.trials.SampleGroupExportDialog.java
public SampleGroupExportDialog(Window owner, String title, Trial trial, KdxploreDatabase kdxploreDatabase, DeviceType deviceType, DeviceIdentifier devid, SampleGroup sampleGroup, Set<Integer> excludeTheseTraitIds, Map<Integer, Trait> allTraitIds, Set<Integer> excludeThesePlotIds) { super(owner, title, ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setGlassPane(backgroundRunner.getBlockingPane()); this.allTraits = allTraitIds; this.trial = trial; this.kdxploreDatabase = kdxploreDatabase; this.sampleGroup = sampleGroup; this.excludeTheseTraitIds = excludeTheseTraitIds; this.excludeThesePlotIds = excludeThesePlotIds; String deviceName = devid == null ? "Unknown_" + deviceType.name() : devid.getDeviceName(); if (DeviceType.FOR_SCORING.equals(deviceType)) { if (!Check.isEmpty(sampleGroup.getOperatorName())) { deviceName = sampleGroup.getOperatorName(); }/*from w w w.j ava2 s . com*/ } File directory = KdxplorePreferences.getInstance().getOutputDirectory(); if (directory == null) { directory = new File(System.getProperty("user.home")); } String filename = Util.getTimestampedOutputFileName(trial.getTrialName(), deviceName); File outfile = new File(directory, filename); filepathText.setText(outfile.getPath()); filepathText.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateButtons(); } @Override public void insertUpdate(DocumentEvent e) { updateButtons(); } @Override public void changedUpdate(DocumentEvent e) { updateButtons(); } }); updateButtons(); boolean developer = RunMode.getRunMode().isDeveloper(); oldKdsmartOption.setForeground(Color.BLUE); oldKdsmartOption.setToolTipText("For ElapsedDays value compatiblity with older versions of KDSmart"); Box exportForOptionsBox = Box.createHorizontalBox(); for (JComponent comp : exportForOptions) { if (developer || comp != oldKdsmartOption) { exportForOptionsBox.add(comp); } } Map<JRadioButton, OutputOption> optionByRb = new HashMap<>(); ActionListener rbListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectedOutputOption = optionByRb.get(e.getSource()); boolean enb = selectedOutputOption.exportFor != null; for (JComponent comp : exportForOptions) { if (comp == wantMediaFilesOption) { comp.setEnabled(enb && selectedOutputOption.supportsMediaFiles()); } else if (comp == kdsmartVersion3option) { comp.setEnabled(enb && selectedOutputOption.usesWorkPackage()); } else { comp.setEnabled(enb); } } } }; boolean anySamplesForIndividuals = true; try { anySamplesForIndividuals = kdxploreDatabase.getAnySamplesForIndividuals(sampleGroup); } catch (IOException e) { Shared.Log.w("SampleGroupExportDialog", "getAnySamplesForIndividuals", e); } ButtonGroup bg = new ButtonGroup(); Box radioButtons = Box.createHorizontalBox(); List<OutputOption> options = new ArrayList<>(); Collections.addAll(options, OutputOption.values()); if (!anySamplesForIndividuals) { // No relevant samples so don't bother offering the option. options.remove(OutputOption.CSV_FULL); } for (OutputOption oo : options) { if (!developer && OutputOption.JSON == oo) { continue; } JRadioButton rb = new JRadioButton(oo.displayName); if (OutputOption.KDX == oo) { kdxExportButton = rb; } if (OutputOption.ZIP == oo) { zipExportButton = rb; } rb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportExclusionBox.selectAndDeactivateButtons( kdxExportButton.isSelected() || zipExportButton.isSelected()); } }); if (OutputOption.JSON == oo) { rb.setForeground(Color.BLUE); rb.setToolTipText("Developer Only"); } bg.add(rb); optionByRb.put(rb, oo); radioButtons.add(rb); rb.addActionListener(rbListener); if (bg.getButtonCount() == 1) { rb.doClick(); } } Box additionalOptionsBox = Box.createHorizontalBox(); additionalOptionsBox.add(this.wantMediaFilesOption); additionalOptionsBox.add(this.kdsmartVersion3option); dbVersionLabel.setToolTipText(TTT_DATABASE_VERSION_FOR_EXPORT); databaseVersionChoices.setToolTipText(TTT_DATABASE_VERSION_FOR_EXPORT); JPanel panel = new JPanel(); GBH gbh = new GBH(panel); int y = 0; gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Output File:"); gbh.add(1, y, 1, 1, GBH.HORZ, 1, 1, GBH.CENTER, filepathText); gbh.add(2, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(browseFileAction)); ++y; gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Options:"); gbh.add(1, y, 2, 1, GBH.HORZ, 1, 1, GBH.CENTER, radioButtons); ++y; gbh.add(0, y, 3, 1, GBH.HORZ, 1, 1, GBH.CENTER, exportExclusionBox); ++y; gbh.add(0, y, 3, 1, GBH.HORZ, 1, 1, GBH.CENTER, additionalOptionsBox); ++y; gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, dbVersionLabel); gbh.add(1, y, 2, 1, GBH.HORZ, 1, 1, GBH.CENTER, BoxBuilder.horizontal().add(databaseVersionChoices).get()); gbh.add(1, y, 2, 1, GBH.HORZ, 1, 1, GBH.CENTER, exportForOptionsBox); ++y; Box buttons = Box.createHorizontalBox(); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(cancelAction)); buttons.add(new JButton(exportAction)); buttons.add(new JButton(exportAndCloseAction)); Container cp = getContentPane(); cp.add(panel, BorderLayout.CENTER); cp.add(buttons, BorderLayout.SOUTH); pack(); }
From source file:components.DialogDemo.java
/** Creates the panel shown by the second tab. */ private JPanel createFeatureDialogBox() { final int numButtons = 5; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); JButton showItButton = null;//w w w . j ava 2 s.co m final String pickOneCommand = "pickone"; final String textEnteredCommand = "textfield"; final String nonAutoCommand = "nonautooption"; final String customOptionCommand = "customoption"; final String nonModalCommand = "nonmodal"; radioButtons[0] = new JRadioButton("Pick one of several choices"); radioButtons[0].setActionCommand(pickOneCommand); radioButtons[1] = new JRadioButton("Enter some text"); radioButtons[1].setActionCommand(textEnteredCommand); radioButtons[2] = new JRadioButton("Non-auto-closing dialog"); radioButtons[2].setActionCommand(nonAutoCommand); radioButtons[3] = new JRadioButton("Input-validating dialog " + "(with custom message area)"); radioButtons[3].setActionCommand(customOptionCommand); radioButtons[4] = new JRadioButton("Non-modal dialog"); radioButtons[4].setActionCommand(nonModalCommand); 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(); //pick one of many if (command == pickOneCommand) { Object[] possibilities = { "ham", "spam", "yam" }; String s = (String) JOptionPane.showInputDialog(frame, "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog", JOptionPane.PLAIN_MESSAGE, icon, possibilities, "ham"); //If a string was returned, say so. if ((s != null) && (s.length() > 0)) { setLabel("Green eggs and... " + s + "!"); return; } //If you're here, the return value was null/empty. setLabel("Come on, finish the sentence!"); //text input } else if (command == textEnteredCommand) { String s = (String) JOptionPane.showInputDialog(frame, "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog", JOptionPane.PLAIN_MESSAGE, icon, null, "ham"); //If a string was returned, say so. if ((s != null) && (s.length() > 0)) { setLabel("Green eggs and... " + s + "!"); return; } //If you're here, the return value was null/empty. setLabel("Come on, finish the sentence!"); //non-auto-closing dialog } else if (command == nonAutoCommand) { final JOptionPane optionPane = new JOptionPane( "The only way to close this dialog is by\n" + "pressing one of the following buttons.\n" + "Do you understand?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); //You can't use pane.createDialog() because that //method sets up the JDialog with a property change //listener that automatically closes the window //when a button is clicked. final JDialog dialog = new JDialog(frame, "Click a button", true); dialog.setContentPane(optionPane); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { setLabel("Thwarted user attempt to close window."); } }); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop))) { //If you were going to check something //before closing the window, you'd do //it here. dialog.setVisible(false); } } }); dialog.pack(); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); int value = ((Integer) optionPane.getValue()).intValue(); if (value == JOptionPane.YES_OPTION) { setLabel("Good."); } else if (value == JOptionPane.NO_OPTION) { setLabel("Try using the window decorations " + "to close the non-auto-closing dialog. " + "You can't!"); } else { setLabel("Window unavoidably closed (ESC?)."); } //non-auto-closing dialog with custom message area //NOTE: if you don't intend to check the input, //then just use showInputDialog instead. } else if (command == customOptionCommand) { customDialog.setLocationRelativeTo(frame); customDialog.setVisible(true); String s = customDialog.getValidatedText(); if (s != null) { //The text is valid. setLabel("Congratulations! " + "You entered \"" + s + "\"."); } //non-modal dialog } else if (command == nonModalCommand) { //Create the dialog. final JDialog dialog = new JDialog(frame, "A Non-Modal Dialog"); //Add contents to it. It must have a close button, //since some L&Fs (notably Java/Metal) don't provide one //in the window decorations for dialogs. JLabel label = new JLabel("<html><p align=center>" + "This is a non-modal dialog.<br>" + "You can have one or more of these up<br>" + "and still use the main window."); label.setHorizontalAlignment(JLabel.CENTER); Font font = label.getFont(); label.setFont(label.getFont().deriveFont(font.PLAIN, 14.0f)); JButton closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); dialog.dispose(); } }); JPanel closePanel = new JPanel(); closePanel.setLayout(new BoxLayout(closePanel, BoxLayout.LINE_AXIS)); closePanel.add(Box.createHorizontalGlue()); closePanel.add(closeButton); closePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(label, BorderLayout.CENTER); contentPane.add(closePanel, BorderLayout.PAGE_END); contentPane.setOpaque(true); dialog.setContentPane(contentPane); //Show it. dialog.setSize(new Dimension(300, 150)); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); } } }); return createPane(moreDialogDesc + ":", radioButtons, showItButton); }
From source file:it.ventuland.ytd.ui.GUIClient.java
private void addComponentsToPane(final Container pane) { this.panel = new JPanel(); this.panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; ActionManager lActionManager = new ActionManager(); dlm = new DefaultListModel<String>(); this.urllist = new JList<String>(dlm); // TODO maybe we add a button to remove added URLs from list? //this.userlist.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION ); this.urllist.setFocusable(false); textarea = new JTextArea(2, 2); textarea.setEditable(true);/* ww w . j a v a 2s . c o m*/ textarea.setFocusable(false); JScrollPane leftscrollpane = new JScrollPane(this.urllist); JScrollPane rightscrollpane = new JScrollPane(textarea); this.middlepane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftscrollpane, rightscrollpane); this.middlepane.setOneTouchExpandable(true); this.middlepane.setDividerLocation(150); Dimension minimumSize = new Dimension(25, 25); leftscrollpane.setMinimumSize(minimumSize); rightscrollpane.setMinimumSize(minimumSize); this.directorybutton = new JButton("", createImageIcon("images/open.png", "")); gbc.gridx = 0; gbc.gridy = 0; this.directorybutton.addActionListener(lActionManager); this.panel.add(this.directorybutton, gbc); this.saveconfigcheckbox = new JCheckBox("Save config"); this.saveconfigcheckbox.setSelected(false); this.panel.add(this.saveconfigcheckbox); this.saveconfigcheckbox.setEnabled(false); // TODO check if initial download directory exists // assume that at least the users homedir exists String shomedir = System.getProperty("user.home").concat(File.separator); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 2; gbc.fill = GridBagConstraints.HORIZONTAL; this.directorytextfield = new JTextField(shomedir, 20 + (mIsDebug ? 48 : 0)); this.directorytextfield.setEnabled(false); this.directorytextfield.setFocusable(true); this.directorytextfield.addActionListener(lActionManager); this.panel.add(this.directorytextfield, gbc); JLabel dirhint = new JLabel("Download to folder:"); gbc.gridx = 0; gbc.gridy = 1; this.panel.add(dirhint, gbc); this.middlepane.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width / 3, Toolkit.getDefaultToolkit().getScreenSize().height / 4 + (mIsDebug ? 200 : 0))); gbc.gridx = 0; gbc.gridy = 3; gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 2; gbc.weightx = 2; gbc.gridwidth = 2; this.panel.add(this.middlepane, gbc); // radio buttons for resolution to download mVideoResolutionBtnGrp = new ButtonGroup(); JPanel lRadioPanel = new JPanel(new GridLayout(1, 0)); List<Object> lVidQ = mAppContext.getList("youtube-downloader.video-quality"); JRadioButton lRadioButton = null; for (Object obj : lVidQ) { String lQuality = (String) obj; String lToolTip = mAppContext.getString("youtube-downloader.video-quality." + lQuality + ".tooltip"); boolean lSelected = mAppContext .getBoolean("youtube-downloader.video-quality." + lQuality + ".selected"); boolean lEnabled = mAppContext.getBoolean("youtube-downloader.video-quality." + lQuality + ".enabled"); lRadioButton = new JRadioButton(lQuality); lRadioButton.setName(lQuality); lRadioButton.setActionCommand(lQuality.toLowerCase()); lRadioButton.addActionListener(lActionManager); lRadioButton.setToolTipText(lToolTip); lRadioButton.setSelected(lSelected); lRadioButton.setEnabled(lEnabled); mVideoResolutionBtnGrp.add(lRadioButton); lRadioPanel.add(lRadioButton); } gbc.gridx = 1; gbc.gridy = 0; gbc.gridheight = 0; gbc.gridwidth = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.NORTHEAST; this.panel.add(lRadioPanel, gbc); // radio buttons for video format to download mVideoQualityBtnGrp = new ButtonGroup(); lRadioPanel = new JPanel(new GridLayout(1, 0)); save3dcheckbox = new JCheckBox("3D"); save3dcheckbox.setToolTipText("stereoscopic video"); save3dcheckbox.setSelected(false); save3dcheckbox.setEnabled(true); lRadioPanel.add(save3dcheckbox); List<Object> lVidR = mAppContext.getList("youtube-downloader.video-resolution"); lRadioButton = null; for (Object obj : lVidR) { String lResolution = (String) obj; String lToolTip = mAppContext .getString("youtube-downloader.video-resolution." + lResolution + ".tooltip"); boolean lSelected = mAppContext .getBoolean("youtube-downloader.video-resolution." + lResolution + ".selected"); boolean lEnabled = mAppContext .getBoolean("youtube-downloader.video-resolution." + lResolution + ".enabled"); lRadioButton = new JRadioButton(lResolution); lRadioButton.setName(lResolution); lRadioButton.setActionCommand(lResolution.toLowerCase()); lRadioButton.addActionListener(lActionManager); lRadioButton.setToolTipText(lToolTip); lRadioButton.setSelected(lSelected); lRadioButton.setEnabled(lEnabled); mVideoQualityBtnGrp.add(lRadioButton); lRadioPanel.add(lRadioButton); } gbc.gridx = 1; gbc.gridy = 1; gbc.gridheight = 0; gbc.gridwidth = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.NORTHEAST; this.panel.add(lRadioPanel, gbc); JLabel hint = new JLabel("Type, paste or drag'n drop a YouTube video address:"); gbc.fill = 0; gbc.gridwidth = 0; gbc.gridheight = 1; gbc.weightx = 0; gbc.weighty = 0; gbc.gridx = 0; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; this.panel.add(hint, gbc); textinputfield = new JTextField(20); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 2; textinputfield.setEnabled(true); textinputfield.setFocusable(true); textinputfield.addActionListener(lActionManager); textinputfield.getDocument().addDocumentListener(new UrlInsertListener()); this.panel.add(textinputfield, gbc); this.quitbutton = new JButton("", createImageIcon("images/exit.png", "")); gbc.gridx = 2; gbc.gridy = 5; gbc.gridwidth = 0; this.quitbutton.addActionListener(lActionManager); this.quitbutton.setActionCommand("quit"); this.quitbutton.setToolTipText("Exit."); this.panel.add(this.quitbutton, gbc); pane.add(this.panel); addWindowListener(new GUIWindowAdapter()); this.setDropTarget(new DropTarget(this, new DragDropListener())); textarea.setTransferHandler(null); // otherwise the dropped text would be inserted }
From source file:DialogDemo.java
/** Creates the panel shown by the second tab. */ private JPanel createFeatureDialogBox() { final int numButtons = 5; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); JButton showItButton = null;/*from w ww .j a v a2 s .co m*/ final String pickOneCommand = "pickone"; final String textEnteredCommand = "textfield"; final String nonAutoCommand = "nonautooption"; final String customOptionCommand = "customoption"; final String nonModalCommand = "nonmodal"; radioButtons[0] = new JRadioButton("Pick one of several choices"); radioButtons[0].setActionCommand(pickOneCommand); radioButtons[1] = new JRadioButton("Enter some text"); radioButtons[1].setActionCommand(textEnteredCommand); radioButtons[2] = new JRadioButton("Non-auto-closing dialog"); radioButtons[2].setActionCommand(nonAutoCommand); radioButtons[3] = new JRadioButton("Input-validating dialog " + "(with custom message area)"); radioButtons[3].setActionCommand(customOptionCommand); radioButtons[4] = new JRadioButton("Non-modal dialog"); radioButtons[4].setActionCommand(nonModalCommand); 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(); // pick one of many if (command == pickOneCommand) { Object[] possibilities = { "ham", "spam", "yam" }; String s = (String) JOptionPane.showInputDialog(frame, "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog", JOptionPane.PLAIN_MESSAGE, icon, possibilities, "ham"); // If a string was returned, say so. if ((s != null) && (s.length() > 0)) { setLabel("Green eggs and... " + s + "!"); return; } // If you're here, the return value was null/empty. setLabel("Come on, finish the sentence!"); // text input } else if (command == textEnteredCommand) { String s = (String) JOptionPane.showInputDialog(frame, "Complete the sentence:\n" + "\"Green eggs and...\"", "Customized Dialog", JOptionPane.PLAIN_MESSAGE, icon, null, "ham"); // If a string was returned, say so. if ((s != null) && (s.length() > 0)) { setLabel("Green eggs and... " + s + "!"); return; } // If you're here, the return value was null/empty. setLabel("Come on, finish the sentence!"); // non-auto-closing dialog } else if (command == nonAutoCommand) { final JOptionPane optionPane = new JOptionPane( "The only way to close this dialog is by\n" + "pressing one of the following buttons.\n" + "Do you understand?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); // You can't use pane.createDialog() because that // method sets up the JDialog with a property change // listener that automatically closes the window // when a button is clicked. final JDialog dialog = new JDialog(frame, "Click a button", true); dialog.setContentPane(optionPane); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { setLabel("Thwarted user attempt to close window."); } }); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (JOptionPane.VALUE_PROPERTY.equals(prop))) { // If you were going to check something // before closing the window, you'd do // it here. dialog.setVisible(false); } } }); dialog.pack(); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); int value = ((Integer) optionPane.getValue()).intValue(); if (value == JOptionPane.YES_OPTION) { setLabel("Good."); } else if (value == JOptionPane.NO_OPTION) { setLabel("Try using the window decorations " + "to close the non-auto-closing dialog. " + "You can't!"); } else { setLabel("Window unavoidably closed (ESC?)."); } // non-auto-closing dialog with custom message area // NOTE: if you don't intend to check the input, // then just use showInputDialog instead. } else if (command == customOptionCommand) { customDialog.setLocationRelativeTo(frame); customDialog.setVisible(true); String s = customDialog.getValidatedText(); if (s != null) { // The text is valid. setLabel("Congratulations! " + "You entered \"" + s + "\"."); } // non-modal dialog } else if (command == nonModalCommand) { // Create the dialog. final JDialog dialog = new JDialog(frame, "A Non-Modal Dialog"); // Add contents to it. It must have a close button, // since some L&Fs (notably Java/Metal) don't provide one // in the window decorations for dialogs. JLabel label = new JLabel("<html><p align=center>" + "This is a non-modal dialog.<br>" + "You can have one or more of these up<br>" + "and still use the main window."); label.setHorizontalAlignment(JLabel.CENTER); Font font = label.getFont(); label.setFont(label.getFont().deriveFont(font.PLAIN, 14.0f)); JButton closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); dialog.dispose(); } }); JPanel closePanel = new JPanel(); closePanel.setLayout(new BoxLayout(closePanel, BoxLayout.LINE_AXIS)); closePanel.add(Box.createHorizontalGlue()); closePanel.add(closeButton); closePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel contentPane = new JPanel(new BorderLayout()); contentPane.add(label, BorderLayout.CENTER); contentPane.add(closePanel, BorderLayout.PAGE_END); contentPane.setOpaque(true); dialog.setContentPane(contentPane); // Show it. dialog.setSize(new Dimension(300, 150)); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); } } }); return createPane(moreDialogDesc + ":", radioButtons, showItButton); }
From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java
public void addRadioButton(int x, int y, String text, String toolTipText, String[] bValues, int defaultIndex, JPanel panel, ActionListener l) { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS)); GridBagConstraints c = new GridBagConstraints(); c.gridx = x;// ww w .j a v a 2 s . com c.gridy = y; ButtonGroup group = new ButtonGroup(); p.setToolTipText(toolTipText); p.add(new JLabel(text)); rButtons = new JRadioButton[bValues.length]; for (int i = 0; i < bValues.length; i++) { rButtons[i] = new JRadioButton(bValues[i]); rButtons[i].setName(bValues[i]); rButtons[i].addActionListener(l); rButtons[i].setActionCommand(bValues[i]); p.add(rButtons[i]); group.add(rButtons[i]); if (defaultIndex == i) rButtons[i].setSelected(true); } panel.add(p, c); }