List of usage examples for javax.swing ButtonGroup add
public void add(AbstractButton b)
From source file:com.t3.macro.api.functions.input.ColumnPanel.java
/** Creates a group of radio buttons. */ public JComponent createRadioControl(VarSpec vs) { int listIndex = vs.optionValues.getNumeric("SELECT"); if (listIndex < 0 || listIndex >= vs.valueList.size()) listIndex = 0;/*ww w. j a va 2s . c o m*/ ButtonGroup bg = new ButtonGroup(); Box box = (vs.optionValues.optionEquals("ORIENT", "H")) ? Box.createHorizontalBox() : Box.createVerticalBox(); // If the prompt is suppressed by SPAN=TRUE, use it as the border title String title = ""; if (vs.optionValues.optionEquals("SPAN", "TRUE")) title = vs.prompt; box.setBorder(new TitledBorder(new EtchedBorder(), title)); int radioCount = 0; for (String value : vs.valueList) { JRadioButton radio = new JRadioButton(value, false); bg.add(radio); box.add(radio); if (listIndex == radioCount) radio.setSelected(true); radioCount++; } return box; }
From source file:com.digitalgeneralists.assurance.ui.MainWindow.java
private void initializeComponent() { if (!this.initialized) { logger.info("Initializing the main window."); if (AssuranceUtils.getPlatform() == Platform.MAC) { System.setProperty("apple.laf.useScreenMenuBar", "true"); com.apple.eawt.Application macApplication = com.apple.eawt.Application.getApplication(); MacApplicationAdapter macAdapter = new MacApplicationAdapter(this); macApplication.addApplicationListener(macAdapter); macApplication.setEnabledPreferencesMenu(true); }//from w ww . ja va2s . c o m this.setTitle(Application.applicationShortName); this.setDefaultCloseOperation(EXIT_ON_CLOSE); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); this.topArea = new JTabbedPane(); this.scanLaunchPanel.setPreferredSize(new Dimension(600, 150)); this.scanHistoryPanel.setPreferredSize(new Dimension(600, 150)); this.topArea.addTab("Scan", this.scanLaunchPanel); this.topArea.addTab("History", this.scanHistoryPanel); this.resultsPanel.setPreferredSize(new Dimension(600, 400)); this.topArea.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { resultsPanel.resetPanel(); // NOTE: This isn't ideal. It feels brittle. if (topArea.getSelectedIndex() == viewHistoryMenuItemIndex) { viewHistoryMenuItem.setSelected(true); } else { viewScanMenuItem.setSelected(true); } } }); GridBagConstraints topPanelConstraints = new GridBagConstraints(); topPanelConstraints.anchor = GridBagConstraints.NORTH; topPanelConstraints.fill = GridBagConstraints.BOTH; topPanelConstraints.gridx = 0; topPanelConstraints.gridy = 0; topPanelConstraints.weightx = 1.0; topPanelConstraints.weighty = 0.33; topPanelConstraints.gridheight = 1; topPanelConstraints.gridwidth = 1; topPanelConstraints.insets = new Insets(0, 0, 0, 0); this.getContentPane().add(this.topArea, topPanelConstraints); GridBagConstraints resultsPanelConstraints = new GridBagConstraints(); resultsPanelConstraints.anchor = GridBagConstraints.SOUTH; resultsPanelConstraints.fill = GridBagConstraints.BOTH; resultsPanelConstraints.gridx = 0; resultsPanelConstraints.gridy = 1; resultsPanelConstraints.weightx = 1.0; resultsPanelConstraints.weighty = 0.67; resultsPanelConstraints.gridheight = 1; resultsPanelConstraints.gridwidth = 1; resultsPanelConstraints.insets = new Insets(0, 0, 0, 0); this.getContentPane().add(this.resultsPanel, resultsPanelConstraints); this.applicationDelegate.addEventObserver(ScanStartedEvent.class, this); this.applicationDelegate.addEventObserver(ScanCompletedEvent.class, this); this.applicationDelegate.addEventObserver(SetScanDefinitionMenuStateEvent.class, this); this.applicationDelegate.addEventObserver(SetScanResultsMenuStateEvent.class, this); this.applicationDelegate.addEventObserver(ApplicationConfigurationLoadedEvent.class, this); JMenu menu; JMenuItem menuItem; menuBar = new JMenuBar(); StringBuilder accessiblityLabel = new StringBuilder(128); if (AssuranceUtils.getPlatform() != Platform.MAC) { menu = new JMenu(Application.applicationShortName); menu.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Actions for ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.quitApplicationMenuLabel, KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Close the ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.quitApplicationAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.aboutApplicationMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription( accessiblityLabel.append("Display information about this version of ") .append(Application.applicationShortName).append(".").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.aboutApplicationAction); menu.add(menuItem); } menu = new JMenu("Scan"); menu.setMnemonic(KeyEvent.VK_S); menu.getAccessibleContext().setAccessibleDescription("Actions for file scans"); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.newScanDefinitonMenuLabel, KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Create a new scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.newScanDefinitonAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.deleteScanDefinitonMenuLabel, KeyEvent.VK_D); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Delete the selected scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.deleteScanDefinitonAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.scanMenuLabel, KeyEvent.VK_S); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Launch a scan using the selected scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.scanAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.scanAndMergeMenuLabel, KeyEvent.VK_M); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription( "Launch a scan using the selected scan definition and merge the results"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.scanAndMergeAction); menu.add(menuItem); menu = new JMenu("Results"); menu.setMnemonic(KeyEvent.VK_R); menu.getAccessibleContext().setAccessibleDescription("Actions for scan results"); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.replaceSourceMenuLabel, KeyEvent.VK_O); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Replace the source file with the target file"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.replaceSourceAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.replaceTargetMenuLabel, KeyEvent.VK_T); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Replace the target file with the source file"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.replaceTargetAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.sourceAttributesMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription("View the source file attributes"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.sourceAttributesAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.targetAttributesMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription("View the target file attributes"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.targetAttributesAction); menu.add(menuItem); menu = new JMenu("View"); menu.setMnemonic(KeyEvent.VK_V); menu.getAccessibleContext().setAccessibleDescription( accessiblityLabel.append("Views within ").append(Application.applicationShortName).toString()); accessiblityLabel.setLength(0); menuBar.add(menu); ButtonGroup group = new ButtonGroup(); this.viewScanMenuItem = new JRadioButtonMenuItem(MainWindow.viewScanMenuLabel); this.viewScanMenuItem.addActionListener(this); this.viewScanMenuItem.setActionCommand(AssuranceActions.viewScanAction); this.viewScanMenuItem.setSelected(true); group.add(this.viewScanMenuItem); menu.add(this.viewScanMenuItem); this.viewHistoryMenuItem = new JRadioButtonMenuItem(MainWindow.viewHistoryMenuLabel); this.viewHistoryMenuItem.addActionListener(this); this.viewHistoryMenuItem.setActionCommand(AssuranceActions.viewHistoryAction); this.viewHistoryMenuItem.setSelected(true); group.add(this.viewHistoryMenuItem); menu.add(this.viewHistoryMenuItem); if (AssuranceUtils.getPlatform() != Platform.MAC) { menu = new JMenu("Tools"); menu.getAccessibleContext() .setAccessibleDescription(accessiblityLabel.append("Additional actions for ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.settingsMenuLabel, KeyEvent.VK_COMMA); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription(accessiblityLabel.append("Change settings for the ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.displaySettingsAction); menu.add(menuItem); } this.setJMenuBar(menuBar); this.initialized = true; } }
From source file:edu.ucla.stat.SOCR.analyses.gui.AnovaTwoWay.java
protected void setMappingPanel() { listIndex = new int[dataTable.getColumnCount()]; for (int j = 0; j < listIndex.length; j++) listIndex[j] = 1;//w ww . j av a 2 s . com bPanel = new JPanel(new BorderLayout()); bPanel.add(mappingPanel, BorderLayout.CENTER); mappingPanel.add(mappingInnerPanel, BorderLayout.CENTER); addButton1.addActionListener(this); addButton2.addActionListener(this); removeButton1.addActionListener(this); removeButton2.addActionListener(this); lModel1 = new DefaultListModel(); lModel2 = new DefaultListModel(); lModel3 = new DefaultListModel(); int cellWidth = 10; listAdded = new JList(lModel1); listAdded.setSelectedIndex(0); listDepRemoved = new JList(lModel2); listIndepRemoved = new JList(lModel3); paintTable(listIndex); listAdded.setFixedCellWidth(cellWidth); listDepRemoved.setFixedCellWidth(cellWidth); listIndepRemoved.setFixedCellWidth(cellWidth); dependentPane = new JScrollPane(listDepRemoved); FIRST_BUTTON_LABEL = "DEPENDENT"; SECOND_BUTTON_LABEL = "INDEPENDENT"; depLabel = new JLabel(FIRST_BUTTON_LABEL); indLabel = new JLabel(SECOND_BUTTON_LABEL); tools1.add(depLabel); tools2.add(indLabel); tools1.add(addButton1); tools1.add(removeButton1); tools2.add(addButton2); tools2.add(removeButton2); tools1.setFloatable(false); tools2.setFloatable(false); // JPanel choicesPanel = new JPanel(); choicesPanel.setLayout(new BoxLayout(choicesPanel, BoxLayout.Y_AXIS)); interactionOnSwitch = new JRadioButton("On"); interactionOnSwitch.addActionListener(this); interactionOnSwitch.setActionCommand(INTERACTIONON); interactionOnSwitch.setSelected(false); interactionOn = false; interactionOffSwitch = new JRadioButton("Off"); interactionOffSwitch.addActionListener(this); interactionOffSwitch.setActionCommand(INTERACTIONOFF); interactionOffSwitch.setSelected(true); ButtonGroup group = new ButtonGroup(); group.add(interactionOnSwitch); group.add(interactionOffSwitch); choicesPanel.add(new JLabel("Turn the interaction:")); choicesPanel.add(interactionOnSwitch); choicesPanel.add(interactionOffSwitch); choicesPanel.setPreferredSize(new Dimension(200, 100)); JPanel emptyPanel = new JPanel(); //mappingInnerPanel.setBackground(Color.RED); mappingInnerPanel.add(new JScrollPane(listAdded)); mappingInnerPanel.add(tools1); mappingInnerPanel.add(dependentPane); // mappingInnerPanel.add(emptyPanel); mappingInnerPanel.add(choicesPanel); mappingInnerPanel.add(tools2); mappingInnerPanel.add(new JScrollPane(listIndepRemoved)); //listIndepRemoved.setBackground(Color.GREEN); }
From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java
private JPanel createMaskingPanel(JFreeChart chart) { JPanel wrap = new JPanel(new BorderLayout()); JPanel maskingPanel = new JPanel(new GridLayout(1, 1)); maskingPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); //Horizontal group JPanel managePanel = new JPanel(new BorderLayout()); managePanel.setBorder(//from w ww . ja v a 2s .com BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Region of Interests")); JPanel inner = new JPanel(new LCBLayout(6)); inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); inner.add(new JLabel("Select Region")); roiCombo = new JComboBox(panel.getMasks().toArray()); // colourScaleCombo.setMaximumRowCount(7); roiCombo.setActionCommand(CHANGE_ROI_COMMAND); roiCombo.addActionListener(this); roiCombo.setSelectedIndex(-1); inner.add(roiCombo); inner.add(new JLabel()); inner.add(new JLabel("or create")); JPanel createNewPanel = new JPanel(new GridLayout(1, 2)); newRectangleButton = new JButton("New Rectangle"); newRectangleButton.setActionCommand(CREATE_NEW_RECT_REGION_COMMAND); newRectangleButton.addActionListener(this); newEllipseButton = new JButton("New Ellipse"); newEllipseButton.setActionCommand(CREATE_NEW_ELLIPSE_REGION_COMMAND); newEllipseButton.addActionListener(this); createNewPanel.add(newRectangleButton); createNewPanel.add(newEllipseButton); inner.add(createNewPanel); inner.add(new JLabel()); JPanel editPanel = new JPanel(new BorderLayout()); editPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Edit the Region")); JPanel editInner = new JPanel(new LCBLayout(6)); editInner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); editInner.add(new JLabel("Name")); roiName = new JTextField(10); // colourScaleCombo.setMaximumRowCount(7); roiName.setActionCommand(CHANGE_ROI_NAME_COMMAND); roiName.addActionListener(this); editInner.add(roiName); editInner.add(new JLabel()); editInner.add(new JLabel("Usage")); ButtonGroup buttonGroup = new ButtonGroup(); JPanel radioPanel = new JPanel(new GridLayout(1, 2)); inclusiveRadio = new JRadioButton("inclusive"); inclusiveRadio.setActionCommand(USE_INCLUSIVE_COMMAND); inclusiveRadio.addActionListener(this); buttonGroup.add(inclusiveRadio); radioPanel.add(inclusiveRadio); exclusiveRadio = new JRadioButton("exclusive"); exclusiveRadio.setActionCommand(USE_EXCLUSIVE_COMMAND); exclusiveRadio.addActionListener(this); buttonGroup.add(exclusiveRadio); radioPanel.add(exclusiveRadio); editInner.add(radioPanel); editInner.add(new JLabel()); editInner.add(new JLabel("Shape")); // ButtonGroup shapeGroup = new ButtonGroup(); // JPanel shapePanel = new JPanel(new GridLayout(1, 2)); // rectangleRadio = new JRadioButton("rectangle"); // rectangleRadio.setActionCommand(CHOOSE_RECTANGLE_SHAPE_COMMAND); // rectangleRadio.addActionListener(this); // shapeGroup.add(rectangleRadio); // shapePanel.add(rectangleRadio); // ellipseRadio = new JRadioButton("ellipse"); // ellipseRadio.setActionCommand(CHOOSE_ELLIPSE_SHAPE_COMMAND); // ellipseRadio.addActionListener(this); // shapeGroup.add(ellipseRadio); // shapePanel.add(ellipseRadio); // editInner.add(shapePanel); shapeLabel = new JLabel(); editInner.add(shapeLabel); editInner.add(new JLabel()); editInner.add(new JLabel("X Range")); JPanel xRangePanel = new JPanel(new GridLayout(1, 2)); JPanel xMinPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); xMinPanel.add(new JLabel("min: ")); xMin = new JTextField(10); // xMin.setActionCommand(CHANGE_XMIN_COMMAND); // xMin.addActionListener(this); xMin.addKeyListener(this); xMinPanel.add(xMin); xRangePanel.add(xMinPanel); JPanel xMaxPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); xMaxPanel.add(new JLabel("max: ")); xMax = new JTextField(10); // xMax.setActionCommand(CHANGE_XMAX_COMMAND); xMax.addKeyListener(this); xMaxPanel.add(xMax); xRangePanel.add(xMaxPanel); editInner.add(xRangePanel); editInner.add(new JLabel()); editInner.add(new JLabel("Y Range")); JPanel yRangePanel = new JPanel(new GridLayout(1, 2)); JPanel yMinPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); yMinPanel.add(new JLabel("min: ")); yMin = new JTextField(10); // yMin.setActionCommand(CHANGE_YMIN_COMMAND); // yMin.addActionListener(this); yMin.addKeyListener(this); yMinPanel.add(yMin); yRangePanel.add(yMinPanel); JPanel yMaxPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); yMaxPanel.add(new JLabel("max: ")); yMax = new JTextField(10); // yMax.setActionCommand(CHANGE_YMAX_COMMAND); // yMax.addActionListener(this); yMax.addKeyListener(this); yMaxPanel.add(yMax); yRangePanel.add(yMaxPanel); editInner.add(yRangePanel); editInner.add(new JLabel()); editInner.add(new JLabel()); JPanel applyPanel = new JPanel(new GridLayout(1, 2)); deleteButton = new JButton("Remove"); deleteButton.setEnabled(false); deleteButton.setActionCommand(REMOVE_CHANGE_ACTION); deleteButton.addActionListener(this); applyPanel.add(deleteButton); applyPanel.add(new JLabel()); applyButton = new JButton("Apply"); applyButton.setEnabled(false); applyButton.setActionCommand(APPLY_CHANGE_ACTION); applyButton.addActionListener(this); applyPanel.add(applyButton); editInner.add(applyPanel); editInner.add(new JLabel()); // inner.add(new JLabel("X Range")); // inner.add(inclusiveRadio); // exclusiveRadio = new JRadioButton("exclusive"); // exclusiveRadio.setActionCommand(USE_EXCLUSIVE_COMMAND); // exclusiveRadio.addActionListener(this); // inner.add(exclusiveRadio); editPanel.add(editInner, BorderLayout.NORTH); managePanel.add(editPanel, BorderLayout.SOUTH); managePanel.add(inner, BorderLayout.NORTH); maskingPanel.add(managePanel); wrap.setName("ROI"); wrap.add(maskingPanel, BorderLayout.NORTH); return wrap; }
From source file:net.sf.jabref.gui.preftabs.TableColumnsTab.java
/** * Customization of external program paths. * * @param prefs a <code>JabRefPreferences</code> value *//*www. j a v a 2s . c om*/ public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) { this.prefs = prefs; this.frame = frame; setLayout(new BorderLayout()); TableModel tm = new AbstractTableModel() { @Override public int getRowCount() { return rowCount; } @Override public int getColumnCount() { return 2; } @Override public Object getValueAt(int row, int column) { int internalRow = row; if (internalRow == 0) { return column == 0 ? InternalBibtexFields.NUMBER_COL : String.valueOf(ncWidth); } internalRow--; if (internalRow >= tableRows.size()) { return ""; } Object rowContent = tableRows.get(internalRow); if (rowContent == null) { return ""; } TableRow tr = (TableRow) rowContent; // Only two columns if (column == 0) { return tr.getName(); } else { return tr.getLength() > 0 ? Integer.toString(tr.getLength()) : ""; } } @Override public String getColumnName(int col) { return col == 0 ? Localization.lang("Field name") : Localization.lang("Column width"); } @Override public Class<?> getColumnClass(int column) { if (column == 0) { return String.class; } return Integer.class; } @Override public boolean isCellEditable(int row, int col) { return !((row == 0) && (col == 0)); } @Override public void setValueAt(Object value, int row, int col) { tableChanged = true; // Make sure the vector is long enough. while (row >= tableRows.size()) { tableRows.add(new TableRow("", -1)); } if ((row == 0) && (col == 1)) { ncWidth = Integer.parseInt(value.toString()); return; } TableRow rowContent = tableRows.get(row - 1); if (col == 0) { rowContent.setName(value.toString()); if ("".equals(getValueAt(row, 1))) { setValueAt(String.valueOf(BibtexSingleField.DEFAULT_FIELD_LENGTH), row, 1); } } else { if (value == null) { rowContent.setLength(-1); } else { rowContent.setLength(Integer.parseInt(value.toString())); } } } }; colSetup = new JTable(tm); TableColumnModel cm = colSetup.getColumnModel(); cm.getColumn(0).setPreferredWidth(140); cm.getColumn(1).setPreferredWidth(80); FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:pref", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); JPanel pan = new JPanel(); JPanel tabPanel = new JPanel(); tabPanel.setLayout(new BorderLayout()); JScrollPane sp = new JScrollPane(colSetup, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200)); sp.setMinimumSize(new Dimension(250, 300)); tabPanel.add(sp, BorderLayout.CENTER); JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL); toolBar.setFloatable(false); AddRowAction addRow = new AddRowAction(); DeleteRowAction deleteRow = new DeleteRowAction(); MoveRowUpAction moveUp = new MoveRowUpAction(); MoveRowDownAction moveDown = new MoveRowDownAction(); toolBar.setBorder(null); toolBar.add(addRow); toolBar.add(deleteRow); toolBar.addSeparator(); toolBar.add(moveUp); toolBar.add(moveDown); tabPanel.add(toolBar, BorderLayout.EAST); fileColumn = new JCheckBox(Localization.lang("Show file column")); urlColumn = new JCheckBox(Localization.lang("Show URL/DOI column")); preferUrl = new JRadioButton(Localization.lang("Show URL first")); preferDoi = new JRadioButton(Localization.lang("Show DOI first")); ButtonGroup preferUrlDoiGroup = new ButtonGroup(); preferUrlDoiGroup.add(preferUrl); preferUrlDoiGroup.add(preferDoi); urlColumn.addChangeListener(arg0 -> { preferUrl.setEnabled(urlColumn.isSelected()); preferDoi.setEnabled(urlColumn.isSelected()); }); arxivColumn = new JCheckBox(Localization.lang("Show ArXiv column")); Collection<ExternalFileType> fileTypes = ExternalFileTypes.getInstance().getExternalFileTypeSelection(); String[] fileTypeNames = new String[fileTypes.size()]; int i = 0; for (ExternalFileType fileType : fileTypes) { fileTypeNames[i++] = fileType.getName(); } listOfFileColumns = new JList<>(fileTypeNames); JScrollPane listOfFileColumnsScrollPane = new JScrollPane(listOfFileColumns); listOfFileColumns.setVisibleRowCount(3); extraFileColumns = new JCheckBox(Localization.lang("Show extra columns")); extraFileColumns.addChangeListener(arg0 -> listOfFileColumns.setEnabled(extraFileColumns.isSelected())); /*** begin: special table columns and special fields ***/ JButton helpButton = new HelpAction(Localization.lang("Help on special fields"), HelpFile.SPECIAL_FIELDS) .getHelpButton(); rankingColumn = new JCheckBox(Localization.lang("Show rank")); qualityColumn = new JCheckBox(Localization.lang("Show quality")); priorityColumn = new JCheckBox(Localization.lang("Show priority")); relevanceColumn = new JCheckBox(Localization.lang("Show relevance")); printedColumn = new JCheckBox(Localization.lang("Show printed status")); readStatusColumn = new JCheckBox(Localization.lang("Show read status")); // "sync keywords" and "write special" fields may be configured mutually exclusive only // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter does not make sense) // To avoid confusion, we opted to make the setting mutually exclusive syncKeywords = new JRadioButton(Localization.lang("Synchronize with keywords")); writeSpecialFields = new JRadioButton( Localization.lang("Write values of special fields as separate fields to BibTeX")); ButtonGroup group = new ButtonGroup(); group.add(syncKeywords); group.add(writeSpecialFields); specialFieldsEnabled = new JCheckBox(Localization.lang("Enable special fields")); specialFieldsEnabled.addChangeListener(event -> { boolean isEnabled = specialFieldsEnabled.isSelected(); rankingColumn.setEnabled(isEnabled); qualityColumn.setEnabled(isEnabled); priorityColumn.setEnabled(isEnabled); relevanceColumn.setEnabled(isEnabled); printedColumn.setEnabled(isEnabled); readStatusColumn.setEnabled(isEnabled); syncKeywords.setEnabled(isEnabled); writeSpecialFields.setEnabled(isEnabled); }); builder.appendSeparator(Localization.lang("Special table columns")); builder.nextLine(); builder.append(pan); DefaultFormBuilder specialTableColumnsBuilder = new DefaultFormBuilder( new FormLayout("8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow", "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref, pref")); CellConstraints cc = new CellConstraints(); specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3)); specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2)); specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 3, 2)); specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 4, 2)); specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 5, 2)); specialTableColumnsBuilder.add(printedColumn, cc.xyw(2, 6, 2)); specialTableColumnsBuilder.add(readStatusColumn, cc.xyw(2, 7, 2)); specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 10, 2)); specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 11, 2)); specialTableColumnsBuilder.add(helpButton, cc.xyw(1, 12, 2)); specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2)); specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 2, 2)); specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 3)); specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 4)); specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 5, 2)); specialTableColumnsBuilder.add(extraFileColumns, cc.xyw(5, 6, 2)); specialTableColumnsBuilder.add(listOfFileColumnsScrollPane, cc.xywh(5, 7, 2, 6)); builder.append(specialTableColumnsBuilder.getPanel()); builder.nextLine(); /*** end: special table columns and special fields ***/ builder.appendSeparator(Localization.lang("Entry table columns")); builder.nextLine(); builder.append(pan); builder.append(tabPanel); builder.nextLine(); builder.append(pan); JButton buttonWidth = new JButton(new UpdateWidthsAction()); JButton buttonOrder = new JButton(new UpdateOrderAction()); builder.append(buttonWidth); builder.nextLine(); builder.append(pan); builder.append(buttonOrder); builder.nextLine(); builder.append(pan); builder.nextLine(); pan = builder.getPanel(); pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(pan, BorderLayout.CENTER); }
From source file:apidemo.PanScrollZoomDemo.java
/** * Creates the toolbar./* w w w . j av a2 s .c o m*/ * * @return the toolbar. */ private JToolBar createToolbar() { final JToolBar toolbar = new JToolBar(); final ButtonGroup groupedButtons = new ButtonGroup(); // ACTION_CMD_PAN this.panButton = new JToggleButton(); prepareButton(this.panButton, ACTION_CMD_PAN, " Pan ", "Pan mode"); groupedButtons.add(this.panButton); toolbar.add(this.panButton); // ACTION_CMD_ZOOM_BOX this.zoomButton = new JToggleButton(); prepareButton(this.zoomButton, ACTION_CMD_ZOOM_BOX, " Zoom ", "Zoom mode"); groupedButtons.add(this.zoomButton); this.zoomButton.setSelected(true); // no other makes sense after startup toolbar.add(this.zoomButton); // end of toggle-button group for select/pan/zoom-box toolbar.addSeparator(); // ACTION_CMD_ZOOM_IN this.zoomInButton = new JButton(); prepareButton(this.zoomInButton, ACTION_CMD_ZOOM_IN, " + ", "Zoom in"); toolbar.add(this.zoomInButton); // ACTION_CMD_ZOOM_OUT this.zoomOutButton = new JButton(); prepareButton(this.zoomOutButton, ACTION_CMD_ZOOM_OUT, " - ", "Zoom out"); toolbar.add(this.zoomOutButton); // ACTION_CMD_ZOOM_TO_FIT this.fitButton = new JButton(); prepareButton(this.fitButton, ACTION_CMD_ZOOM_TO_FIT, " Fit ", "Fit all"); toolbar.add(this.fitButton); toolbar.addSeparator(); this.scrollBar = new JScrollBar(JScrollBar.HORIZONTAL); // int ht = (int) zoomButton.getPreferredSize().getHeight(); // scrollBar.setPreferredSize(new Dimension(0, ht)); this.scrollBar.setModel(new DefaultBoundedRangeModel()); toolbar.add(this.scrollBar); this.zoomOutButton.setEnabled(false); this.fitButton.setEnabled(false); this.scrollBar.setEnabled(false); toolbar.setFloatable(false); return toolbar; }
From source file:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java
/** * Returns the panel for the work flow./* w w w . java 2 s . c o m*/ * * @return the panel for the work flow */ private JComponent createWorkflow() { JPanel workflowPanel = new JPanel(new GridLayout(1, 3)); listModelMajor2 = new DefaultListModel(); listModelMajor3 = new DefaultListModel(); listModelSupplement1 = new DefaultListModel(); listModelSupplement2 = new DefaultListModel(); listModelSupplement3 = new DefaultListModel(); listPluginMajor2 = new JList(listModelMajor2); listPluginMajor3 = new JList(listModelMajor3); listPluginSupplement1 = new JList(listModelSupplement1); listPluginSupplement2 = new JList(listModelSupplement2); listPluginSupplement3 = new JList(listModelSupplement3); // phase1 JPanel phasePanel = new JPanel(new GridLayout(1, 1)); phasePanel.setBorder(BorderFactory.createTitledBorder("Phase1. Plain Text Processing")); JPanel listPanel = new JPanel(new GridLayout(1, 1)); listPanel.setBorder(BorderFactory.createTitledBorder("Supplement Plug-in")); JScrollPane scroll = new JScrollPane(); scroll.setViewportView(listPluginSupplement1); listPanel.add(scroll); phasePanel.add(listPanel); workflowPanel.add(phasePanel); // phase2 phasePanel = new JPanel(new GridLayout(1, 2)); phasePanel.setBorder(BorderFactory.createTitledBorder("Phase2. Morphological Analysis")); listPanel = new JPanel(new GridLayout(1, 1)); listPanel.setBorder(BorderFactory.createTitledBorder("Major Plug-in")); scroll = new JScrollPane(); scroll.setViewportView(listPluginMajor2); listPanel.add(scroll); phasePanel.add(listPanel); listPanel = new JPanel(new GridLayout(1, 1)); listPanel.setBorder(BorderFactory.createTitledBorder("Supplement Plug-in")); scroll = new JScrollPane(); scroll.setViewportView(listPluginSupplement2); listPanel.add(scroll); phasePanel.add(listPanel); workflowPanel.add(phasePanel); // phase3 phasePanel = new JPanel(new GridLayout(1, 2)); phasePanel.setBorder(BorderFactory.createTitledBorder("Phase3. Part Of Speech Tagging")); listPanel = new JPanel(new GridLayout(1, 1)); listPanel.setBorder(BorderFactory.createTitledBorder("Major Plug-in")); scroll = new JScrollPane(); scroll.setViewportView(listPluginMajor3); listPanel.add(scroll); phasePanel.add(listPanel); listPanel = new JPanel(new GridLayout(1, 1)); listPanel.setBorder(BorderFactory.createTitledBorder("Supplement Plug-in")); scroll = new JScrollPane(); scroll.setViewportView(listPluginSupplement3); listPanel.add(scroll); phasePanel.add(listPanel); workflowPanel.add(phasePanel); ///////////////////////////////////////////////////////////////////////////////////// JPanel controlPanel = new JPanel(new GridLayout(4, 1)); controlPanel.setBorder(BorderFactory.createTitledBorder("Workflow Control")); buttonActivate = new JButton("Activate the workflow"); buttonAnalysis = new JButton("Analyze Text"); buttonReset = new JButton("Close the workflow"); JPanel threadPanel = new JPanel(new GridLayout(1, 1)); radioMultiThread = new JRadioButton("Mutli-thread Mode", true); radioSingleThread = new JRadioButton("Single-thread Mode", false); threadPanel.setBorder(BorderFactory.createTitledBorder("Thread Mode")); threadPanel.add(radioMultiThread); threadPanel.add(radioSingleThread); ButtonGroup groupThread = new ButtonGroup(); groupThread.add(radioMultiThread); groupThread.add(radioSingleThread); controlPanel.add(threadPanel); controlPanel.add(buttonActivate); controlPanel.add(buttonAnalysis); controlPanel.add(buttonReset); buttonAnalysis.setEnabled(false); buttonReset.setEnabled(false); ///////////////////////////////////////////////////////////////////////////////////// JPanel pluginInfoPanel = new JPanel(new GridLayout(1, 1)); pluginInfoPanel.setBorder(BorderFactory.createTitledBorder("Plug-in Information")); areaPluginInfo = new JTextArea(); areaPluginInfo.setLineWrap(true); scroll = new JScrollPane(); scroll.setViewportView(areaPluginInfo); pluginInfoPanel.add(scroll); JPanel infoPanel = new JPanel(new GridLayout(1, 2)); infoPanel.add(pluginInfoPanel); infoPanel.add(controlPanel); JPanel panel = new JPanel(new GridLayout(2, 1)); workflowPanel.setBorder(BorderFactory.createTitledBorder("HanNanum Workflow")); panel.add(workflowPanel); panel.add(infoPanel); return panel; }
From source file:JModem.java
/** Finish the initializations. */ private void finishConstructor() { // Create the textarea with a JScrollpane wrapping it. // Install it in Centre of the TextArea. theTextArea = new MyTextArea(20, 80); getContentPane().add(new JScrollPane(theTextArea), BorderLayout.CENTER); plainFont = new Font("courier", Font.PLAIN, 13); theTextArea.setFont(plainFont);/* ww w . ja va 2s . c om*/ xferFileNameTF.setFont(plainFont); theModel.populateComboBox(); portsComboBox.setSelectedIndex(0); // Load up the baud rate combo box for (int i = 0; i < baudot.length; i++) { baudComboBox.addItem(Integer.toString(baudot[i])); } baudComboBox.setSelectedIndex(0); // Load up the System Type combo box for (int i = 0; i < sysTypes.length; i++) { sysTypeComboBox.addItem(sysTypes[i]); } sysTypeComboBox.setSelectedIndex(0); // put radio buttons into groups to enforce single-selection ButtonGroup b1 = new ButtonGroup(); b1.add(d7RadioButton); b1.add(d8RadioButton); ButtonGroup b2 = new ButtonGroup(); b2.add(pNoneRadioButton); b2.add(pEvenRadioButton); b2.add(pOddRadioButton); ButtonGroup b3 = new ButtonGroup(); b3.add(sendRadioButton); b3.add(recvRadioButton); ButtonGroup b4 = new ButtonGroup(); b4.add(xferModeTextRadioButton); b4.add(xferModeBinRadioButton); xferModeBinRadioButton.setEnabled(true); }
From source file:com.mirth.connect.connectors.doc.DocumentWriter.java
private void initComponents() { setBackground(UIConstants.BACKGROUND_COLOR); outputLabel = new JLabel("Output:"); ButtonGroup outputButtonGroup = new ButtonGroup(); outputFileRadioButton = new MirthRadioButton("File"); outputFileRadioButton.setBackground(getBackground()); outputFileRadioButton.setToolTipText("Write the contents to a file."); outputFileRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { updateFileEnabled(true);/*from w ww .j a v a2 s. c om*/ } }); outputButtonGroup.add(outputFileRadioButton); outputAttachmentRadioButton = new MirthRadioButton("Attachment"); outputAttachmentRadioButton.setBackground(getBackground()); outputAttachmentRadioButton.setToolTipText( "<html>Write the contents to an attachment. The destination's response message will contain the<br>attachment Id and can be used in subsequent connectors to include the attachment.</html>"); outputAttachmentRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { updateFileEnabled(false); } }); outputButtonGroup.add(outputAttachmentRadioButton); outputBothRadioButton = new MirthRadioButton("Both"); outputBothRadioButton.setBackground(getBackground()); outputBothRadioButton.setToolTipText( "<html>Write the contents to a file and an attachment. The destination's response message will contain<br>the attachment Id and can be used in subsequent connectors to include the attachment.</html>"); outputBothRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { updateFileEnabled(true); } }); outputButtonGroup.add(outputBothRadioButton); directoryLabel = new JLabel("Directory:"); directoryField = new MirthTextField(); directoryField.setToolTipText("The directory (folder) where the generated file should be written."); testConnectionButton = new JButton("Test Write"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { testConnection(); } }); fileNameLabel = new JLabel("File Name:"); fileNameField = new MirthTextField(); fileNameField.setToolTipText("The file name to give to the generated file."); documentTypeLabel = new JLabel("Document Type:"); ButtonGroup documentTypeButtonGroup = new ButtonGroup(); documentTypePDFRadio = new MirthRadioButton("PDF"); documentTypePDFRadio.setBackground(getBackground()); documentTypePDFRadio.setToolTipText("The type of document to be created for each message."); documentTypePDFRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { documentTypePDFRadioActionPerformed(); } }); documentTypeButtonGroup.add(documentTypePDFRadio); documentTypeRTFRadio = new MirthRadioButton("RTF"); documentTypeRTFRadio.setBackground(getBackground()); documentTypeRTFRadio.setToolTipText("The type of document to be created for each message."); documentTypeRTFRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { documentTypeRTFRadioActionPerformed(); } }); documentTypeButtonGroup.add(documentTypeRTFRadio); encryptedLabel = new JLabel("Encrypted:"); ButtonGroup encryptedButtonGroup = new ButtonGroup(); encryptedYesRadio = new MirthRadioButton("Yes"); encryptedYesRadio.setBackground(getBackground()); encryptedYesRadio.setToolTipText( "If Document Type PDF is selected, generated documents can optionally be encrypted."); encryptedYesRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { encryptedYesActionPerformed(); } }); encryptedButtonGroup.add(encryptedYesRadio); encryptedNoRadio = new MirthRadioButton("No"); encryptedNoRadio.setBackground(getBackground()); encryptedNoRadio.setToolTipText( "If Document Type PDF is selected, generated documents can optionally be encrypted."); encryptedNoRadio.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { encryptedNoActionPerformed(); } }); encryptedButtonGroup.add(encryptedNoRadio); passwordLabel = new JLabel("Password:"); passwordField = new MirthPasswordField(); passwordField.setToolTipText( "If Encrypted Yes is selected, enter the password to be used to later view the document here."); pageSizeLabel = new JLabel("Page Size:"); pageSizeXLabel = new JLabel(""); DocumentListener pageSizeDocumentListener = new DocumentListener() { @Override public void removeUpdate(DocumentEvent evt) { updatePageSizeComboBox(); } @Override public void insertUpdate(DocumentEvent evt) { updatePageSizeComboBox(); } @Override public void changedUpdate(DocumentEvent evt) { updatePageSizeComboBox(); } }; pageSizeWidthField = new MirthTextField(); pageSizeWidthField.getDocument().addDocumentListener(pageSizeDocumentListener); pageSizeWidthField.setToolTipText( "<html>The width of the page. The units for the width<br/>are determined by the drop-down menu to the right.<br/>When rendering PDFs, a minimum of 26mm is enforced.</html>"); pageSizeHeightField = new MirthTextField(); pageSizeHeightField.getDocument().addDocumentListener(pageSizeDocumentListener); pageSizeHeightField.setToolTipText( "<html>The height of the page. The units for the height<br/>are determined by the drop-down menu to the right.<br/>When rendering PDFs, a minimum of 26mm is enforced.</html>"); pageSizeUnitComboBox = new MirthComboBox<Unit>(); pageSizeUnitComboBox.setModel(new DefaultComboBoxModel<Unit>(Unit.values())); pageSizeUnitComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { updatePageSizeComboBox(); } }); pageSizeUnitComboBox.setToolTipText("The units to use for the page width and height."); pageSizeComboBox = new MirthComboBox<PageSize>(); pageSizeComboBox.setModel(new DefaultComboBoxModel<PageSize>( ArrayUtils.subarray(PageSize.values(), 0, PageSize.values().length - 1))); pageSizeComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { pageSizeComboBoxActionPerformed(); } }); pageSizeComboBox.setToolTipText("Select a standard page size to use, or enter a custom page size."); templateLabel = new JLabel("HTML Template:"); templateTextArea = new MirthRTextScrollPane(ContextType.DESTINATION_DISPATCHER, false, SyntaxConstants.SYNTAX_STYLE_HTML, false); templateTextArea.setBorder(BorderFactory.createEtchedBorder()); }
From source file:org.broad.igv.peaks.PeakTrackMenu.java
public void addDisplayModeItems() { addSeparator();//from w w w.j ava 2 s.c o m ButtonGroup group = new ButtonGroup(); Track.DisplayMode displayMode = track.getDisplayMode(); JRadioButtonMenuItem m1 = new JRadioButtonMenuItem("Compressed"); m1.setSelected(displayMode == Track.DisplayMode.COLLAPSED); m1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { track.setDisplayMode(Track.DisplayMode.COLLAPSED); IGV.getInstance().doRefresh(); } }); JRadioButtonMenuItem m3 = new JRadioButtonMenuItem("Time Series"); m3.setSelected(displayMode == Track.DisplayMode.EXPANDED); m3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { track.setDisplayMode(Track.DisplayMode.EXPANDED); IGV.getInstance().doRefresh(); } }); add(m1); add(m3); group.add(m1); group.add(m3); }