Java Code Examples for javax.swing.JCheckBox#setEnabled()
The following examples show how to use
javax.swing.JCheckBox#setEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringCheckbox.java From pdfxtk with Apache License 2.0 | 7 votes |
public void create(PropertiesPanel panel) { panel.container.add(Awt.newComponent(), Awt.constraints(false)); JCheckBox cb = new JCheckBox(label, initialState); cb.setEnabled(enabled); cb.setForeground(required ? PropertiesPanel.REQUIRED : PropertiesPanel.NON_REQUIRED); panel.valuecmps.put(key, cb); panel.container.add(cb, Awt.constraints(true)); }
Example 2
Source File: SettingsFrame.java From FoxTelem with GNU General Public License v3.0 | 6 votes |
private JCheckBox addCheckBoxRow(String name, String tip, boolean value, JPanel parent) { JCheckBox checkBox = new JCheckBox(name); checkBox.setEnabled(true); checkBox.addItemListener(this); checkBox.setToolTipText(tip); parent.add(checkBox); if (value) checkBox.setSelected(true); else checkBox.setSelected(false); return checkBox; }
Example 3
Source File: EquipChoicePanel.java From megamek with GNU General Public License v2.0 | 6 votes |
@Override public void setEnabled(boolean enabled) { cbArmorKit.setEnabled(enabled); if (enabled) { armorStateChanged(); } else { fldDivisor.setEnabled(enabled); chEncumber.setEnabled(enabled); chSpaceSuit.setEnabled(enabled); chDEST.setEnabled(enabled); chSneakCamo.setEnabled(enabled); chSneakIR.setEnabled(enabled); chSneakECM.setEnabled(enabled); } for (JCheckBox spec : chSpecs) { spec.setEnabled(enabled); } }
Example 4
Source File: EquipmentEditor.java From gcs with Mozilla Public License 2.0 | 6 votes |
private void createSecondLineFields(Container parent) { boolean isContainer = mRow.canHaveChildren(); JPanel wrapper = new JPanel(new ColumnLayout((isContainer ? 4 : 6) + (showEquipmentState() ? 1 : 0))); if (!isContainer) { mQtyField = createIntegerNumberField(parent, wrapper, I18n.Text("Quantity"), mRow.getQuantity(), I18n.Text("The number of this equipment present"), 9); } mTechLevelField = createField(isContainer ? parent : wrapper, wrapper, I18n.Text("Tech Level"), mRow.getTechLevel(), I18n.Text("The first Tech Level this equipment is available at"), 3); mLegalityClassField = createField(wrapper, wrapper, I18n.Text("Legality Class"), mRow.getLegalityClass(), I18n.Text("The legality class of this equipment"), 3); if (showEquipmentState()) { mEquippedCheckBox = new JCheckBox(I18n.Text("Equipped")); mEquippedCheckBox.setSelected(mRow.isEquipped()); UIUtilities.setToPreferredSizeOnly(mEquippedCheckBox); mEquippedCheckBox.setEnabled(mIsEditable); mEquippedCheckBox.setToolTipText(Text.wrapPlainTextForToolTip(I18n.Text("Items that are not equipped do not apply any features they may normally contribute to the character."))); wrapper.add(mEquippedCheckBox); } wrapper.add(new JPanel()); parent.add(wrapper); }
Example 5
Source File: MuleModulesCheckBoxList.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
public Component getListCellRendererComponent( JList<? extends JCheckBox> list, JCheckBox value, int index, boolean isSelected, boolean cellHasFocus) { JCheckBox checkbox = value; //Drawing checkbox, change the appearance here /* checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground()); checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground()); */ checkbox.setEnabled(isEnabled()); checkbox.setFont(getFont()); checkbox.setFocusPainted(false); checkbox.setBorderPainted(true); checkbox.setBorder(isSelected ? UIManager .getBorder("List.focusCellHighlightBorder") : noFocusBorder); return checkbox; }
Example 6
Source File: ControlPanel.java From openvisualtraceroute with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void setEnabled(final boolean enable) { for (final JCheckBox check : _packets.values()) { check.setEnabled(enable); } _hostIpTextField.setEnabled(enable); _allPortCheck.setEnabled(enable); _capturePeriod.setEnabled(enable); _filterLengthTF.setEnabled(enable && _filterPacketLengthCheck.isSelected()); _filterPacketLengthCheck.setEnabled(enable); _portTF.setEnabled(enable && !_allPortCheck.isSelected()); if (enable) { _captureButton.setToolTipText(Resources.getLabel("capture.packet.start")); _captureButton.setIcon(GO_IMG); } else { _captureButton.setToolTipText(Resources.getLabel("cancel.button")); _captureButton.setIcon(Resources.getImageIcon("over.png")); } }
Example 7
Source File: ComponentController.java From swingsane with Apache License 2.0 | 5 votes |
private void updateBatchScanCheckBox(boolean enabled, boolean selected) { JCheckBox batchScanCheckBox = components.getBatchScanCheckBox(); batchScanCheckBox.setEnabled(enabled); batchScanCheckBox.setSelected(selected); if (enabled && selected) { components.getPagesToScanSpinner().setEnabled(false); } else { components.getPagesToScanSpinner().setEnabled(true); } }
Example 8
Source File: EditLayoutSpacePanel.java From netbeans with Apache License 2.0 | 5 votes |
private static void initGapValues(EditableGap eg, JComboBox sizeCombo, JCheckBox resCheckBox) { if (eg != null) { String selected = null; String[] defaultNames = eg.getPaddingDisplayNames(); if (eg.canHaveDefaultValue() && defaultNames != null) { sizeCombo.setModel(new DefaultComboBoxModel(defaultNames)); if (eg.definedSize == LayoutConstants.NOT_EXPLICITLY_DEFINED) { LayoutConstants.PaddingType[] defaultTypes = eg.getPossiblePaddingTypes(); if (eg.paddingType == null || defaultTypes == null || defaultTypes.length == 0) { selected = defaultNames[0]; } else { for (int i=0; i < defaultTypes.length; i++) { if (eg.paddingType == defaultTypes[i]) { selected = defaultNames[i]; break; } } } } } if (selected == null) { selected = Integer.toString(eg.definedSize); } sizeCombo.setSelectedItem(selected); resCheckBox.setSelected(eg.resizing); } else { sizeCombo.setSelectedItem(NbBundle.getMessage(EditLayoutSpacePanel.class, "VALUE_NoEmptySpace")); // NOI18N sizeCombo.setEnabled(false); resCheckBox.setEnabled(false); } }
Example 9
Source File: RoleSetPage.java From ganttproject with GNU General Public License v3.0 | 5 votes |
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { final RoleSet roleSet = (RoleSet) value; final JCheckBox result = new JCheckBox(myI18n.getRoleSetDisplayName(roleSet), roleSet.isEnabled()); if (isTheOnlyEnabled(roleSet)) { result.setEnabled(false); } result.setToolTipText(createTooltipText(roleSet)); return result; }
Example 10
Source File: CheckBoxList.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public Component getListCellRendererComponent(JList<? extends E> list, E value, int index, boolean isSelected, boolean cellHasFocus) { JCheckBox checkbox = (JCheckBox) value; checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground()); checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground()); checkbox.setEnabled(isEnabled()); checkbox.setFont(getFont()); checkbox.setFocusPainted(false); checkbox.setBorderPainted(true); checkbox.setBorder(isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); return checkbox; }
Example 11
Source File: ElkPreferencesPanel.java From elk-reasoner with Apache License 2.0 | 5 votes |
@Override public void initialise() throws Exception { setLayout(new BorderLayout()); PreferencesLayoutPanel panel = new PreferencesLayoutPanel(); add(panel, BorderLayout.NORTH); ElkPreferences prefs = new ElkPreferences().load(); panel.addGroup("Number of worker threads"); numberOfWorkersModel_ = new SpinnerNumberModel(prefs.numberOfWorkers, 1, 999, 1); JComponent spinner = new JSpinner(numberOfWorkersModel_); spinner.setMaximumSize(spinner.getPreferredSize()); spinner.setToolTipText( "The number of threads that ELK can use for performing parallel computations"); panel.addGroupComponent(spinner); incrementalCheckbox_ = new JCheckBox("Incremental reasoning", prefs.incrementalMode); incrementalCheckbox_.setToolTipText( "If checked, ELK tries to recompute only the results caused by the changes in the ontology"); panel.addGroupComponent(incrementalCheckbox_); syncCheckbox_ = new JCheckBox("Auto-syncronization", prefs.autoSynchronization); syncCheckbox_.setToolTipText( "If checked, ELK will always be in sync with the ontology (requires reasoner restart)"); syncCheckbox_.setEnabled(incrementalCheckbox_.isSelected()); incrementalCheckbox_.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { syncCheckbox_.setEnabled(incrementalCheckbox_.isSelected()); } }); panel.addGroupComponent(syncCheckbox_); }
Example 12
Source File: SpacecraftFrame.java From FoxTelem with GNU General Public License v3.0 | 5 votes |
private JCheckBox addCheckBoxRow(String name, String tip, boolean value, JPanel parent) { JPanel box = new JPanel(); box.setLayout(new FlowLayout(FlowLayout.LEFT)); JCheckBox checkBox = new JCheckBox(name); checkBox.setEnabled(true); checkBox.addItemListener(this); checkBox.setToolTipText(tip); box.add(checkBox); parent.add(box); if (value) checkBox.setSelected(true); else checkBox.setSelected(false); return checkBox; }
Example 13
Source File: TransferMaskDialog.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private static JCheckBox createCeckbox(final JPanel panel, boolean enabled) { JCheckBox checkBox = new JCheckBox(); checkBox.setHorizontalAlignment(SwingConstants.CENTER); checkBox.setEnabled(enabled); panel.add(checkBox); return checkBox; }
Example 14
Source File: PayloadMessageConfig.java From ISO8583 with GNU General Public License v3.0 | 4 votes |
private GuiPayloadField(FieldVO fieldVO, FieldVO superfieldVO, String superFieldBitNum) { this.isSubfield = (superfieldVO != null); this.superFieldVO = superfieldVO; this.fieldVO = fieldVO.getInstanceCopy(); this.fieldVO.setFieldList(new ArrayList<FieldVO>()); if (isSubfield) { superFieldVO.getFieldList().add(this.fieldVO); } else { messageVO.getFieldList().add(this.fieldVO); } ckBox = new JCheckBox(); txtType = new JTextField(); txtLength = new JTextField(); txtValue = new JTextField(); subfieldList = new ArrayList<GuiPayloadField>(); lblFieldNum = new JLabel(superFieldBitNum +"["+ fieldVO.getBitNum().toString() +"]"); lblFieldName = new JLabel(fieldVO.getName()); lblType = new JLabel(fieldVO.getType().toString()); lblDynamic = new JLabel(); lblDynamic.setIcon(new ImageIcon(PnlGuiPayload.class.getResource("/org/adelbs/iso8583/resource/search.png"))); lblDynamic.setToolTipText(fieldVO.getDynaCondition()); lineNum = numLines; numLines++; ckBox.setBounds(10, 10 + (lineNum * 25), 22, 22); lblFieldNum.setBounds(40, 10 + (lineNum * 25), 60, 22); lblFieldName.setBounds(100, 10 + (lineNum * 25), 100, 22); lblType.setBounds(490, 10 + (lineNum * 25), 100, 22); lblDynamic.setBounds(620, 10 + (lineNum * 25), 50, 22); if (fieldVO.getType() == TypeEnum.ALPHANUMERIC) { txtValue.setBounds(210, 10 + (lineNum * 25), 260, 22); } else if (fieldVO.getType() == TypeEnum.TLV) { txtType.setBounds(210, 10 + (lineNum * 25), 80, 22); txtLength.setBounds(300, 10 + (lineNum * 25), 80, 22); txtValue.setBounds(390, 10 + (lineNum * 25), 80, 22); pnlFields.add(txtType); pnlFields.add(txtLength); } pnlFields.add(ckBox); pnlFields.add(lblFieldNum); pnlFields.add(lblFieldName); //Remove TypeLabel and TextField when we have SubFields. //Parent field has its value created by its subfields if(fieldVO.getFieldList().size() == 0 || fieldVO.getType() == TypeEnum.TLV){ pnlFields.add(txtValue); pnlFields.add(lblType); } txtType.addKeyListener(saveFieldPayloadAction); txtLength.addKeyListener(saveFieldPayloadAction); txtValue.addKeyListener(saveFieldPayloadAction); if (!fieldVO.getDynaCondition().equals("") && !fieldVO.getDynaCondition().equals("true")) pnlFields.add(lblDynamic); if (fieldVO.getDynaCondition().equals("true")) { ckBox.setSelected(true); ckBox.setEnabled(false); ckBoxClick(ckBox); setEnabled(true, false); } else { ckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ckBoxClick((JCheckBox) e.getSource()); saveFieldValue(); } }); setEnabled(false, isSubfield); } }
Example 15
Source File: MineralStandardUPbRatioViewNotEditable.java From ET_Redux with Apache License 2.0 | 4 votes |
/** * * * @param valueModel */ public MineralStandardUPbRatioViewNotEditable ( ValueModel valueModel) { super( valueModel); initTextBoxes( false ); JCheckBox measuredCheckBox = new JCheckBox(// "", ((MineralStandardUPbRatioModel) valueModel).isMeasured() ); measuredCheckBox.setEnabled( false ); measuredCheckBox.setFont(ReduxConstants.sansSerif_12_Bold ); measuredCheckBox.setSize( 25, AbstractValueModelView.PANEL_HEIGHT ); measuredCheckBox.setLocation( this.uncertaintyTextBox.getX() + this.uncertaintyTextBox.getWidth() + 25, 0 ); this.add( measuredCheckBox ); this.setSize( this.getWidth(), this.getHeight() ); }
Example 16
Source File: SizeChangedDialog.java From ramus with GNU General Public License v3.0 | 4 votes |
/** * Create the dialog. */ public SizeChangedDialog(JDialog jDialog) { super(jDialog, true); setTitle(ResourceLoader.getString("resize_dialog_title")); setBounds(100, 100, 450, 300); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); gbl_contentPanel.columnWidths = new int[]{0, 0}; gbl_contentPanel.rowHeights = new int[]{0, 0, 0}; gbl_contentPanel.columnWeights = new double[]{0.0, Double.MIN_VALUE}; gbl_contentPanel.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE}; contentPanel.setLayout(gbl_contentPanel); { updateZoom = new JCheckBox(ResourceLoader.getString("Update_zoom")); updateZoom.setSelected(true); updateZoom.setEnabled(false); GridBagConstraints gbc_updateZoom = new GridBagConstraints(); gbc_updateZoom.anchor = GridBagConstraints.WEST; gbc_updateZoom.insets = new Insets(0, 0, 5, 0); gbc_updateZoom.gridx = 0; gbc_updateZoom.gridy = 0; contentPanel.add(updateZoom, gbc_updateZoom); } { updateFonts = new JCheckBox(ResourceLoader.getString("Update_fonts")); updateFonts.setSelected(true); GridBagConstraints gbc_updateFonts = new GridBagConstraints(); gbc_updateFonts.anchor = GridBagConstraints.WEST; gbc_updateFonts.gridx = 0; gbc_updateFonts.gridy = 1; contentPanel.add(updateFonts, gbc_updateFonts); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton(ResourceLoader.getString("ok")); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setVisible(false); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } } }
Example 17
Source File: FixDuplicateImportStmts.java From netbeans with Apache License 2.0 | 4 votes |
private void initComponentsMore(ImportData importData, boolean removeUnusedImports) { contentPanel.setLayout(new GridBagLayout()); contentPanel.setBackground(UIManager.getColor("Table.background")); //NOI18N jScrollPane1.setBorder(UIManager.getBorder("ScrollPane.border")); //NOI18N jScrollPane1.getVerticalScrollBar().setUnitIncrement(new JLabel("X").getPreferredSize().height); jScrollPane1.getVerticalScrollBar().setBlockIncrement(new JLabel("X").getPreferredSize().height * 10); int numberOfItems = importData.getItems().size(); if (numberOfItems > 0) { int row = 0; combos = new JComboBox[numberOfItems]; Font monoSpaced = new Font("Monospaced", Font.PLAIN, new JLabel().getFont().getSize()); FocusListener focusListener = new FocusListener() { @Override public void focusGained(FocusEvent e) { Component c = e.getComponent(); Rectangle r = c.getBounds(); contentPanel.scrollRectToVisible(r); } @Override public void focusLost(FocusEvent arg0) { } }; for (int i = 0; i < numberOfItems; i++) { DataItem dataItem = importData.getItems().get(i); combos[i] = createComboBox(dataItem, monoSpaced, focusListener); JLabel lblSimpleName = new JLabel(dataItem.getTypeName()); lblSimpleName.setOpaque(false); lblSimpleName.setFont(monoSpaced); lblSimpleName.setLabelFor(combos[i]); contentPanel.add(lblSimpleName, new GridBagConstraints(0, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 5, 2, 5), 0, 0)); contentPanel.add(combos[i], new GridBagConstraints(1, row++, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 5, 2, 5), 0, 0)); } contentPanel.add(new JLabel(), new GridBagConstraints(2, row, 2, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); Dimension d = contentPanel.getPreferredSize(); d.height = getRowHeight() * Math.min(combos.length, 6); jScrollPane1.getViewport().setPreferredSize(d); } else { contentPanel.add( new JLabel(getBundleString("FixDupImportStmts_NothingToFix")), new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(20, 20, 20, 20), 0, 0)); } // load localized text into widgets: lblTitle.setText(getBundleString("FixDupImportStmts_IntroLbl")); //NOI18N lblHeader.setText(getBundleString("FixDupImportStmts_Header")); //NOI18N checkUnusedImports = new JCheckBox(); Mnemonics.setLocalizedText(checkUnusedImports, getBundleString("FixDupImportStmts_UnusedImports")); //NOI18N bottomPanel.add(checkUnusedImports, BorderLayout.WEST); checkUnusedImports.setEnabled(true); checkUnusedImports.setSelected(removeUnusedImports); }
Example 18
Source File: ListFrame.java From JavaMainRepo with Apache License 2.0 | 4 votes |
public ListFrame(String title) { super(title); SpringLayout slPane = new SpringLayout(); contentPanel.setLayout(slPane); // Description panel animalDescriptionLabels = new LinkedList<JLabel>(); animalDataLabels = new LinkedList<JLabel>(); // GridLayout for panel animalPlanet = new JPanel(); animalPlanet.setBackground(LIGHT_GREY); animalPlanet.setLayout(new GridLayout(8, 2, 5, 5)); // Adding the description fields for (int i = 0; i < 8; i++) { JLabel newDesc = new JLabel(); if (i < 6) { newDesc.setFont(DEFAULT_FONT); } else { newDesc.setFont(BOLD_FONT); } animalDescriptionLabels.add(newDesc); animalPlanet.add(newDesc); JLabel newData = new JLabel(); if (i < 6) { newData.setFont(DEFAULT_FONT); } else { newData.setFont(BOLD_FONT); } animalDataLabels.add(newData); animalPlanet.add(newData); } slPane.putConstraint(SpringLayout.WEST, animalPlanet, 0, SpringLayout.WEST, contentPanel); slPane.putConstraint(SpringLayout.EAST, animalPlanet, 0, SpringLayout.EAST, contentPanel); contentPanel.add(animalPlanet); // Delete button and check box btnDelete = new JButton("Delete"); btnDelete.setEnabled(false); btnDelete.setBackground(SOMETHING_REDISH); slPane.putConstraint(SpringLayout.NORTH, btnDelete, 5, SpringLayout.SOUTH, animalPlanet); slPane.putConstraint(SpringLayout.WEST, btnDelete, 0, SpringLayout.WEST, contentPanel); contentPanel.add(btnDelete); cbDelete = new JCheckBox("Enable Deletion"); cbDelete.setBackground(NOT_LIGHT_GREY); slPane.putConstraint(SpringLayout.NORTH, cbDelete, 5, SpringLayout.SOUTH, animalPlanet); slPane.putConstraint(SpringLayout.WEST, cbDelete, 5, SpringLayout.EAST, btnDelete); contentPanel.add(cbDelete); btnDeleteAll = new JButton("Delete All"); btnDeleteAll.setEnabled(false); btnDeleteAll.setBackground(SOMETHING_REDISH); slPane.putConstraint(SpringLayout.NORTH, btnDeleteAll, 5, SpringLayout.SOUTH, animalPlanet); slPane.putConstraint(SpringLayout.EAST, btnDeleteAll, 0, SpringLayout.EAST, contentPanel); contentPanel.add(btnDeleteAll); cbDeleteAll = new JCheckBox("Enable Complete Anihilation"); cbDeleteAll.setBackground(NOT_LIGHT_GREY); cbDeleteAll.setEnabled(false); slPane.putConstraint(SpringLayout.NORTH, cbDeleteAll, 5, SpringLayout.SOUTH, animalPlanet); slPane.putConstraint(SpringLayout.EAST, cbDeleteAll, -5, SpringLayout.WEST, btnDeleteAll); contentPanel.add(cbDeleteAll); // Selection list animalScrollPane = new JScrollPane(); if (ZooData.getAnimalListSize() > 0) { animalList = new JList<String>(ZooData.getAnimalListNames()); } else { animalList = new JList<String>(new String[] { "Empty" }); setEmptyDescription(); } animalList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); animalList.setBackground(LIGHT_GREY); animalScrollPane.setViewportView(animalList); slPane.putConstraint(SpringLayout.NORTH, animalScrollPane, 5, SpringLayout.SOUTH, btnDelete); slPane.putConstraint(SpringLayout.WEST, animalScrollPane, 0, SpringLayout.WEST, contentPanel); slPane.putConstraint(SpringLayout.EAST, animalScrollPane, 0, SpringLayout.EAST, contentPanel); slPane.putConstraint(SpringLayout.SOUTH, animalScrollPane, 0, SpringLayout.SOUTH, contentPanel); contentPanel.add(animalScrollPane); }
Example 19
Source File: PeakResolverSetupDialog.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
/** * This function add all the additional components for this dialog over the original * ParameterSetupDialog. */ @Override protected void addDialogComponents() { super.addDialogComponents(); final PeakList[] peakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists(); // Elements of panel. preview = new JCheckBox("Show preview"); preview.addActionListener(this); preview.setHorizontalAlignment(SwingConstants.CENTER); preview.setEnabled(peakLists.length > 0); // Preview panel. final JPanel previewPanel = new JPanel(new BorderLayout()); previewPanel.add(new JSeparator(), BorderLayout.NORTH); previewPanel.add(preview, BorderLayout.CENTER); previewPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH); // Feature list combo-box. comboPeakList = new JComboBox<PeakList>(); comboPeakList.setFont(COMBO_FONT); for (final PeakList peakList : peakLists) { if (peakList.getNumberOfRawDataFiles() == 1) { comboPeakList.addItem(peakList); } } comboPeakList.addActionListener(this); // Peaks combo box. comboPeak = new JComboBox<PeakListRow>(); comboPeak.setFont(COMBO_FONT); comboPeak.setRenderer(new PeakPreviewComboRenderer()); comboPeak.setPreferredSize( new Dimension(PREFERRED_PEAK_COMBO_WIDTH, comboPeak.getPreferredSize().height)); pnlLabelsFields = GUIUtils.makeTablePanel(2, 2, new JComponent[] {new JLabel("Feature list"), comboPeakList, new JLabel("Chromatogram"), comboPeak}); // Put all together. pnlVisible = new JPanel(new BorderLayout()); pnlVisible.add(previewPanel, BorderLayout.NORTH); // TIC plot. ticPlot = new TICPlot(this); ticPlot.setMinimumSize(MINIMUM_TIC_DIMENSIONS); // Tool bar. final TICToolBar toolBar = new TICToolBar(ticPlot); toolBar.getComponentAtIndex(0).setVisible(false); // Panel for XYPlot. pnlPlotXY = new JPanel(new BorderLayout()); pnlPlotXY.setBackground(Color.white); pnlPlotXY.add(ticPlot, BorderLayout.CENTER); pnlPlotXY.add(toolBar, BorderLayout.EAST); GUIUtils.addMarginAndBorder(pnlPlotXY, 10); mainPanel.add(pnlVisible, 0, getNumberOfParameters() + 3, 2, 1, 0, 0, GridBagConstraints.HORIZONTAL); // Layout and position. updateBounds(); }
Example 20
Source File: ProductChooser.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
ProductChooser(Window parent, String title, int buttonMask, String helpID, Product[] products) { super(parent, title, buttonMask, helpID); TableLayout layout = new TableLayout(1); layout.setTableFill(TableLayout.Fill.BOTH); layout.setRowWeightY(0, 1.0); layout.setRowWeightY(1, 0.0); layout.setTableWeightX(1.0); JPanel panel = new JPanel(layout); ProductListModel listModel = new ProductListModel(); selectAll = new JCheckBox("Select all"); selectNone = new JCheckBox("Select none", true); selectNone.setEnabled(false); productsList = new CheckBoxList(listModel); productsList.setCellRenderer(new ProductListCellRenderer()); productsList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { final int length = productsList.getCheckBoxListSelectedIndices().length; if (length == 0) { selectNone.setSelected(true); selectAll.setSelected(false); } else if (length == productsList.getModel().getSize()) { selectAll.setSelected(true); selectNone.setSelected(false); } else { selectAll.setSelected(false); selectNone.setSelected(false); } selectAll.setEnabled(!selectAll.isSelected()); selectNone.setEnabled(!selectNone.isSelected()); } }); for (Product product : products) { listModel.addElement(product); } panel.add(new JScrollPane(productsList)); panel.add(createButtonsPanel()); setContent(panel); }