Java Code Examples for javax.swing.JCheckBox#addActionListener()
The following examples show how to use
javax.swing.JCheckBox#addActionListener() .
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: BasicFindPanel.java From constellation with Apache License 2.0 | 6 votes |
private void updateComboBox() { dropDownPanel.removeAll(); resetComboBox(); selectAll.setEnabled(attributes.size() > 0); for (Attribute a : attributes) { JCheckBox attrCheckbox = new JCheckBox(a.getName()); attrCheckbox.addActionListener(e -> { JCheckBox temp = (JCheckBox) e.getSource(); checkBoxValueChanged(temp.getText(), temp.isSelected()); }); dropDownPanel.add(attrCheckbox); } selectAll.setSelected(true); toggleCheckAll(true); }
Example 2
Source File: XactDataPane.java From audiveris with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates a new {@code XactDataPane} object. * * @param title pane title * @param parent parent pane if any * @param model underlying model (cannot be null) */ public XactDataPane (String title, XactDataPane parent, Param<E> model) { this.parent = parent; if (model == null) { throw new IllegalArgumentException("Null model for pane '" + title + "'"); } this.model = model; this.title = title; separator = new JLabel(title); separator.setHorizontalAlignment(SwingConstants.LEFT); separator.setEnabled(false); selBox = new JCheckBox(); selBox.addActionListener(this); }
Example 3
Source File: JCheckBoxBuilder.java From triplea with GNU General Public License v3.0 | 6 votes |
/** Builds the swing component. */ public JCheckBox build() { final JCheckBox checkBox = new JCheckBox(Strings.nullToEmpty(label)); checkBox.setSelected( Optional.ofNullable(settingPersistence) .map(SettingPersistence::getSetting) .orElse(isSelected)); checkBox.addActionListener( e -> { Optional.ofNullable(settingPersistence) .ifPresent(s -> s.saveSetting(checkBox.isSelected())); Optional.ofNullable(actionListener).ifPresent(l -> l.accept(checkBox.isSelected())); }); return checkBox; }
Example 4
Source File: ASHRenderingUI.java From thunderstorm with GNU General Public License v3.0 | 6 votes |
@Override public JPanel getOptionsPanel() { JPanel panel = super.getOptionsPanel(); JTextField shiftsTextField = new JTextField("", 20); parameters.registerComponent(shifts, shiftsTextField); panel.add(new JLabel("Lateral shifts:"), GridBagHelper.leftCol()); panel.add(shiftsTextField, GridBagHelper.rightCol()); final JTextField zShiftsTextField = new JTextField("", 20); parameters.registerComponent(zShifts, zShiftsTextField); final JLabel zShiftsLabel = new JLabel("Axial shifts:"); panel.add(zShiftsLabel, GridBagHelper.leftCol()); panel.add(zShiftsTextField, GridBagHelper.rightCol()); final JCheckBox threeDCheckBox = (JCheckBox) parameters.getRegisteredComponent(threeD); threeDCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { zShiftsLabel.setEnabled(threeDCheckBox.isSelected()); zShiftsTextField.setEnabled(threeDCheckBox.isSelected()); } }); parameters.loadPrefs(); return panel; }
Example 5
Source File: JCheckBoxExample.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 6 votes |
public static void main(String[] args) { JFrame frame = new JFrame("JCheckBox Example"); check = new JCheckBox("Check here ", new ImageIcon("C:/Users/BEEP/Pictures/eclipse-debugger-continuar.png")); check2 = new JCheckBox("I'm a mirror"); frame.getContentPane().add(check); frame.getContentPane().setLayout(new FlowLayout()); frame.getContentPane().add(check2); frame.pack(); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); check.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { check2.setSelected(((JCheckBox)event.getSource()).isSelected()); } }); }
Example 6
Source File: DebugPanel.java From dkpro-jwpl with Apache License 2.0 | 6 votes |
private void createStatsOutputSettings() { statsOutputCheckBox = new JCheckBox( "Activate Article Information Output"); statsOutputCheckBox.setBounds(10, 80, 250, 25); statsOutputCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { boolean flag = !controller.isStatsOutputEnabled(); controller.setEnableStatsOutput(flag); } }); this.add(statsOutputCheckBox); }
Example 7
Source File: GenericPanelBuilder.java From Ardulink-2 with Apache License 2.0 | 5 votes |
private static JComponent createCheckBox(final ConfigAttribute attribute) { final JCheckBox checkBox = new JCheckBox(); checkBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { attribute.setValue(Boolean.valueOf(checkBox.isSelected())); } }); return setState(checkBox, attribute); }
Example 8
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 9
Source File: ComponentPreviewPainter.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Creates the main frame for <code>this</code> sample. */ public ComponentPreviewPainter() { super("Component preview painter"); this.setLayout(new BorderLayout()); // Create panel with custom painting logic - simple // diagonal fill. JPanel samplePanel = new JPanel() { @Override protected void paintComponent(Graphics g) { Graphics2D graphics = (Graphics2D) g.create(); graphics.setPaint(new GradientPaint(0, 0, new Color(100, 100, 255), getWidth(), getHeight(), new Color(255, 100, 100))); graphics.fillRect(0, 0, getWidth(), getHeight()); graphics.dispose(); } }; samplePanel.setPreferredSize(new Dimension(800, 400)); samplePanel.setSize(this.getPreferredSize()); samplePanel.setMinimumSize(this.getPreferredSize()); final JScrollPane scrollPane = new JScrollPane(samplePanel); this.add(scrollPane, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox hasPreview = new JCheckBox("scroll has preview"); hasPreview.addActionListener((ActionEvent e) -> SwingUtilities.invokeLater(() -> { SubstanceCortex.ComponentOrParentScope.setComponentPreviewPainter(scrollPane, hasPreview.isSelected() ? new DefaultPreviewPainter() : null); invalidate(); })); controls.add(hasPreview); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
Example 10
Source File: SetWidgetVisible.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Creates the main frame for <code>this</code> sample. */ public SetWidgetVisible() { super("Set widget visible"); this.setLayout(new BorderLayout()); // create sample menu bar with two menus JMenuBar jmb = new JMenuBar(); JMenu menu = new JMenu("menu"); menu.add(new JMenuItem("test item 1")); menu.add(new JMenuItem("test item 2")); menu.add(new JMenuItem("test item 3")); menu.addSeparator(); menu.add(new JMenuItem("test menu item 4")); menu.add(new JMenuItem("test menu item 5")); menu.add(new JMenuItem("test menu item 6")); jmb.add(menu); JMenu menu2 = new JMenu("big"); for (int i = 0; i < 35; i++) menu2.add(new JMenuItem("menu item " + i)); jmb.add(menu2); this.setJMenuBar(jmb); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox showMenuSearchPanels = new JCheckBox("Show menu search panels"); showMenuSearchPanels.setSelected(false); showMenuSearchPanels.addActionListener((ActionEvent e) -> SwingUtilities.invokeLater( () -> SubstanceCortex.WindowScope.setWidgetVisible(SetWidgetVisible.this, showMenuSearchPanels.isSelected(), SubstanceWidgetType.MENU_SEARCH))); controls.add(showMenuSearchPanels); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
Example 11
Source File: FmtOptions.java From netbeans with Apache License 2.0 | 5 votes |
private void addListener( JComponent jc ) { if ( jc instanceof JTextField ) { JTextField field = (JTextField)jc; field.addActionListener(this); field.getDocument().addDocumentListener(this); } else if ( jc instanceof JCheckBox ) { JCheckBox checkBox = (JCheckBox)jc; checkBox.addActionListener(this); } else if ( jc instanceof JComboBox) { JComboBox cb = (JComboBox)jc; cb.addActionListener(this); } }
Example 12
Source File: CommonMembersPanel.java From netbeans with Apache License 2.0 | 5 votes |
protected final void initialize(JComboBox targetsComboBox, JCheckBox duplicates) { this.targetsComboBox = targetsComboBox; this.duplicates = duplicates; duplicates.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateTargetsModel(); } }); updateTargetsModel(); }
Example 13
Source File: MaterialsTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public MaterialsTab(final Program program) { super(program, TabsMaterials.get().materials(), Images.TOOL_MATERIALS.getIcon(), true); //Category: Asteroid //Category: Material ListenerClass listener = new ListenerClass(); JFixedToolBar jToolBarLeft = new JFixedToolBar(); jOwners = new JComboBox<>(); jOwners.setActionCommand(MaterialsAction.SELECTED.name()); jOwners.addActionListener(listener); jToolBarLeft.addComboBox(jOwners, 200); jPiMaterial = new JCheckBox(TabsMaterials.get().includePI()); jPiMaterial.setActionCommand(MaterialsAction.SELECTED.name()); jPiMaterial.addActionListener(listener); jToolBarLeft.add(jPiMaterial); jToolBarLeft.addSpace(10); jToolBarLeft.addSeparator(); jExport = new JButton(GuiShared.get().export(), Images.DIALOG_CSV_EXPORT.getIcon()); jExport.setActionCommand(MaterialsAction.EXPORT.name()); jExport.addActionListener(listener); jToolBarLeft.addButton(jExport); JFixedToolBar jToolBarRight = new JFixedToolBar(); jCollapse = new JButton(TabsMaterials.get().collapse(), Images.MISC_COLLAPSED.getIcon()); jCollapse.setActionCommand(MaterialsAction.COLLAPSE.name()); jCollapse.addActionListener(listener); jToolBarRight.addButton(jCollapse); jExpand = new JButton(TabsMaterials.get().expand(), Images.MISC_EXPANDED.getIcon()); jExpand.setActionCommand(MaterialsAction.EXPAND.name()); jExpand.addActionListener(listener); jToolBarRight.addButton(jExpand); //Table Format tableFormat = new EnumTableFormatAdaptor<>(MaterialTableFormat.class); //Backend eventList = EventListManager.create(); //Separator eventList.getReadWriteLock().readLock().lock(); separatorList = new SeparatorList<>(eventList, new MaterialSeparatorComparator(), 1, Integer.MAX_VALUE); eventList.getReadWriteLock().readLock().unlock(); //Table Model tableModel = EventModels.createTableModel(separatorList, tableFormat); //Table jTable = new JSeparatorTable(program, tableModel, separatorList); jTable.setSeparatorRenderer(new MaterialsSeparatorTableCell(jTable, separatorList)); jTable.setSeparatorEditor(new MaterialsSeparatorTableCell(jTable, separatorList)); PaddingTableCellRenderer.install(jTable, 3); //Selection Model selectionModel = EventModels.createSelectionModel(separatorList); selectionModel.setSelectionMode(ListSelection.MULTIPLE_INTERVAL_SELECTION_DEFENSIVE); jTable.setSelectionModel(selectionModel); //Listeners installTable(jTable, NAME); //Scroll jTableScroll = new JScrollPane(jTable); //Menu installMenu(program, new MaterialTableMenu(), jTable, Material.class); List<EnumTableColumn<Material>> enumColumns = new ArrayList<>(); enumColumns.addAll(Arrays.asList(MaterialExtenedTableFormat.values())); enumColumns.addAll(Arrays.asList(MaterialTableFormat.values())); exportDialog = new ExportDialog<>(program.getMainWindow().getFrame(), NAME, null, new MaterialsFilterControl(), Collections.singletonList(eventList), enumColumns); layout.setHorizontalGroup( layout.createParallelGroup() .addGroup(layout.createSequentialGroup() .addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Integer.MAX_VALUE) .addGap(0) .addComponent(jToolBarRight) ) .addComponent(jTableScroll, 0, 0, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createSequentialGroup() .addGroup(layout.createParallelGroup() .addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(jToolBarRight, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) ) .addComponent(jTableScroll, 0, 0, Short.MAX_VALUE) ); }
Example 14
Source File: MultiGradientTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private JCheckBox createCheck(JPanel panel, String name) { JCheckBox cb = new JCheckBox(name); cb.addActionListener(this); panel.add(cb); return cb; }
Example 15
Source File: SilentPeriodPanel.java From VanetSim with GNU General Public License v3.0 | 4 votes |
/** * Constructor, creating GUI items. */ public SilentPeriodPanel(){ setLayout(new GridBagLayout()); // global layout settings GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.PAGE_START; c.weightx = 0.5; c.gridx = 0; c.gridy = 0; c.gridheight = 1; c.gridwidth = 2; c.gridwidth = 1; c.insets = new Insets(5,5,5,5); c.gridx = 0; silentPeriodDurationLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.duration")); //$NON-NLS-1$ ++c.gridy; add(silentPeriodDurationLabel_,c); silentPeriodDuration_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); silentPeriodDuration_.setValue(3000); silentPeriodDuration_.setPreferredSize(new Dimension(60,20)); c.gridx = 1; silentPeriodDuration_.addFocusListener(this); add(silentPeriodDuration_,c); c.gridx = 0; silentPeriodFrequencyLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.frequency")); //$NON-NLS-1$ ++c.gridy; add(silentPeriodFrequencyLabel_,c); silentPeriodFrequency_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); silentPeriodFrequency_.setValue(10000); silentPeriodFrequency_.setPreferredSize(new Dimension(60,20)); c.gridx = 1; silentPeriodFrequency_.addFocusListener(this); add(silentPeriodFrequency_,c); c.gridx = 0; enableSilentPeriodsLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.enable")); //$NON-NLS-1$ ++c.gridy; add(enableSilentPeriodsLabel_,c); enableSilentPeriods_ = new JCheckBox(); enableSilentPeriods_.setSelected(false); enableSilentPeriods_.setActionCommand("enableSilentPeriods"); //$NON-NLS-1$ c.gridx = 1; enableSilentPeriods_.addFocusListener(this); add(enableSilentPeriods_,c); enableSilentPeriods_.addActionListener(this); //to consume the rest of the space c.weighty = 1.0; ++c.gridy; JPanel space = new JPanel(); space.setOpaque(false); add(space, c); }
Example 16
Source File: PageSetupDialog.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected void init( final GuiContext guiContext ) { messages = new ResourceBundleSupport( Locale.getDefault(), MESSAGES, ObjectUtilities .getClassLoader( PageSetupDialog.class ) ); this.guiContext = guiContext; final RevalidateListener revalidateListener = new RevalidateListener(); previewPane = new PageFormatPreviewPane(); pageFormatBox = new JComboBox( new DefaultComboBoxModel( PageFormatFactory.getInstance().getPageFormats() ) ); pageHeightField = new JTextField(); pageHeightField.setColumns( 5 ); pageHeightField.getDocument().addDocumentListener( revalidateListener ); pageWidthField = new JTextField(); pageWidthField.setColumns( 5 ); pageWidthField.getDocument().addDocumentListener( revalidateListener ); landscapeModeBox = new JCheckBox(); landscapeModeBox.addActionListener( new OrientationChangeListener() ); portraitModeBox = new JCheckBox(); portraitModeBox.addActionListener( new OrientationChangeListener() ); preDefinedPageSizeBox = new JCheckBox(); preDefinedPageSizeBox.addChangeListener( new PageSizeCheckBoxSelectionAction() ); userDefinedPageSizeBox = new JCheckBox(); userDefinedPageSizeBox.addChangeListener( new PageSizeCheckBoxSelectionAction() ); final ButtonGroup pageSizeGroup = new ButtonGroup(); pageSizeGroup.add( preDefinedPageSizeBox ); pageSizeGroup.add( userDefinedPageSizeBox ); spanHorizontalField = new JTextField(); spanHorizontalField.setColumns( 5 ); spanHorizontalField.getDocument().addDocumentListener( revalidateListener ); spanVerticalField = new JTextField(); spanVerticalField.setColumns( 5 ); spanVerticalField.getDocument().addDocumentListener( revalidateListener ); marginTopField = new JTextField(); marginTopField.setColumns( 5 ); marginTopField.getDocument().addDocumentListener( revalidateListener ); marginLeftField = new JTextField(); marginLeftField.setColumns( 5 ); marginLeftField.getDocument().addDocumentListener( revalidateListener ); marginBottomField = new JTextField(); marginBottomField.setColumns( 5 ); marginBottomField.getDocument().addDocumentListener( revalidateListener ); marginRightField = new JTextField(); marginRightField.setColumns( 5 ); marginRightField.getDocument().addDocumentListener( revalidateListener ); final ButtonGroup orientationGroup = new ButtonGroup(); orientationGroup.add( portraitModeBox ); orientationGroup.add( landscapeModeBox ); pageFormatBox.addActionListener( new PageSizeSelectionAction() ); setDefaultCloseOperation( DISPOSE_ON_CLOSE ); super.init(); }
Example 17
Source File: TableProperties.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Constructs a MonitorPropsDialog class. * @param title The name of the specified model * @param table the table to configure * @param desktop the main desktop. */ public TableProperties(String title, JTable table, MainDesktopPane desktop) { // Use JInternalFrame constructor super(title + " Properties", false, true); // Initialize data members this.model = table.getColumnModel(); // Prepare content pane JPanel mainPane = new JPanel(); mainPane.setLayout(new BorderLayout()); mainPane.setBorder(MainDesktopPane.newEmptyBorder()); setContentPane(mainPane); // Create column pane JPanel columnPane = new JPanel(new GridLayout(0, 1)); columnPane.setBorder(new MarsPanelBorder()); // Create a checkbox for each column in the model TableModel dataModel = table.getModel(); for(int i = 0; i < dataModel.getColumnCount(); i++) { String name = dataModel.getColumnName(i); JCheckBox column = new JCheckBox(name); column.setSelected(false); column.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { columnSelected(event); } } ); columnButtons.add(column); columnPane.add(column); } // Selected if column is visible Enumeration<?> en = model.getColumns(); while(en.hasMoreElements()) { int selected = ((TableColumn)en.nextElement()).getModelIndex(); JCheckBox columnButton = columnButtons.get(selected); columnButton.setSelected(true); } mainPane.add(columnPane, BorderLayout.CENTER); setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); pack(); desktop.add(this); // // Add to its own tab pane // if (desktop.getMainScene() != null) // desktop.add(this); // //desktop.getMainScene().getDesktops().get(0).add(this); // else // desktop.add(this); }
Example 18
Source File: Assistant.java From Dayon with GNU General Public License v3.0 | 4 votes |
private Action createComressionConfigurationAction() { final Action configure = new AbstractAction() { @Override public void actionPerformed(ActionEvent ev) { JFrame compressionFrame = (JFrame) SwingUtilities.getRoot((Component) ev.getSource()); final JPanel pane = new JPanel(); pane.setLayout(new GridLayout(4, 2, 10, 10)); final JLabel methodLbl = new JLabel(Babylon.translate("compression.method")); // testing only: final JComboBox<CompressionMethod> methodCb = new JComboBox<>(CompressionMethod.values()); final JComboBox<CompressionMethod> methodCb = new JComboBox<>(Stream.of(CompressionMethod.values()).filter(e -> !e.equals(CompressionMethod.NONE)).toArray(CompressionMethod[]::new)); methodCb.setSelectedItem(compressorEngineConfiguration.getMethod()); pane.add(methodLbl); pane.add(methodCb); final JLabel useCacheLbl = new JLabel(Babylon.translate("compression.cache.usage")); final JCheckBox useCacheCb = new JCheckBox(); useCacheCb.setSelected(compressorEngineConfiguration.useCache()); pane.add(useCacheLbl); pane.add(useCacheCb); final JLabel maxSizeLbl = new JLabel(Babylon.translate("compression.cache.max")); maxSizeLbl.setToolTipText(Babylon.translate("compression.cache.max.tooltip")); final JTextField maxSizeTf = new JTextField(String.valueOf(compressorEngineConfiguration.getCacheMaxSize())); pane.add(maxSizeLbl); pane.add(maxSizeTf); final JLabel purgeSizeLbl = new JLabel(Babylon.translate("compression.cache.purge")); purgeSizeLbl.setToolTipText(Babylon.translate("compression.cache.purge.tooltip")); final JTextField purgeSizeTf = new JTextField(String.valueOf(compressorEngineConfiguration.getCachePurgeSize())); pane.add(purgeSizeLbl); pane.add(purgeSizeTf); useCacheCb.addActionListener(ev1 -> { maxSizeLbl.setEnabled(useCacheCb.isSelected()); maxSizeTf.setEnabled(useCacheCb.isSelected()); purgeSizeLbl.setEnabled(useCacheCb.isSelected()); purgeSizeTf.setEnabled(useCacheCb.isSelected()); }); maxSizeLbl.setEnabled(useCacheCb.isSelected()); maxSizeTf.setEnabled(useCacheCb.isSelected()); purgeSizeLbl.setEnabled(useCacheCb.isSelected()); purgeSizeTf.setEnabled(useCacheCb.isSelected()); final boolean ok = DialogFactory.showOkCancel(compressionFrame, Babylon.translate("compression.settings"), pane, () -> { final String max = maxSizeTf.getText(); if (max.isEmpty()) { return Babylon.translate("compression.cache.max.msg1"); } final int maxValue; try { maxValue = Integer.parseInt(max); } catch (NumberFormatException ex) { return Babylon.translate("compression.cache.max.msg2"); } if (maxValue <= 0) { return Babylon.translate("compression.cache.max.msg3"); } return validatePurgeValue(purgeSizeTf, maxValue); }); if (ok) { final CompressorEngineConfiguration newCompressorEngineConfiguration = new CompressorEngineConfiguration((CompressionMethod) methodCb.getSelectedItem(), useCacheCb.isSelected(), Integer.parseInt(maxSizeTf.getText()), Integer.parseInt(purgeSizeTf.getText())); if (!newCompressorEngineConfiguration.equals(compressorEngineConfiguration)) { compressorEngineConfiguration = newCompressorEngineConfiguration; compressorEngineConfiguration.persist(); sendCompressorConfiguration(compressorEngineConfiguration); } } } }; configure.putValue(Action.NAME, "configureCompression"); configure.putValue(Action.SHORT_DESCRIPTION, Babylon.translate("compression.settings.msg")); configure.putValue(Action.SMALL_ICON, ImageUtilities.getOrCreateIcon(ImageNames.COMPRESSION_SETTINGS)); return configure; }
Example 19
Source File: AppearancePanel.java From importer-exporter with Apache License 2.0 | 4 votes |
private void initGui() { overwriteCheck = new JCheckBox(); noTexturesCheck = new JCheckBox(); generateUniqueCheck = new JCheckBox(); exportAll = new JRadioButton(); noExport = new JRadioButton(); ButtonGroup expAppRadio = new ButtonGroup(); expAppRadio.add(noExport); expAppRadio.add(exportAll); pathLabel = new JLabel(); pathText = new JTextField(); browseButton = new JButton(); useBuckets = new JCheckBox(); DecimalFormat bucketsFormat = new DecimalFormat("########"); bucketsFormat.setMaximumIntegerDigits(8); bucketsFormat.setMinimumIntegerDigits(1); noOfBuckets = new JFormattedTextField(bucketsFormat); PopupMenuDecorator.getInstance().decorate(pathText, noOfBuckets); browseButton.addActionListener(e -> { String path = browseFile(Language.I18N.getString("pref.export.appearance.label.absPath"), pathText.getText()); if (!path.isEmpty()) pathText.setText(path); }); setLayout(new GridBagLayout()); { exportBlock = new JPanel(); add(exportBlock, GuiUtil.setConstraints(0,0,1.0,0.0,GridBagConstraints.BOTH,5,0,5,0)); exportBlock.setBorder(BorderFactory.createTitledBorder("")); exportBlock.setLayout(new GridBagLayout()); { exportAll.setIconTextGap(10); noTexturesCheck.setIconTextGap(10); noExport.setIconTextGap(10); overwriteCheck.setIconTextGap(10); generateUniqueCheck.setIconTextGap(10); int lmargin = (int) (exportAll.getPreferredSize().getWidth()) + 11; { exportBlock.add(exportAll, GuiUtil.setConstraints(0, 0, 0, 1, GridBagConstraints.BOTH, 0, 5, 0, 5)); exportBlock.add(overwriteCheck, GuiUtil.setConstraints(0, 1, 1, 1, GridBagConstraints.BOTH, 0, lmargin, 0, 5)); exportBlock.add(generateUniqueCheck, GuiUtil.setConstraints(0, 2, 1, 1, GridBagConstraints.BOTH, 0, lmargin, 0, 5)); exportBlock.add(noTexturesCheck, GuiUtil.setConstraints(0, 3, 1, 1, GridBagConstraints.BOTH, 0, lmargin, 0, 5)); exportBlock.add(noExport, GuiUtil.setConstraints(0, 4, 0, 1, GridBagConstraints.BOTH, 0, 5, 0, 5)); } } pathBlock = new JPanel(); add(pathBlock, GuiUtil.setConstraints(0,1,1.0,0.0,GridBagConstraints.BOTH,5,0,5,0)); pathBlock.setBorder(BorderFactory.createTitledBorder("")); pathBlock.setLayout(new GridBagLayout()); { pathBlock.add(pathLabel, GuiUtil.setConstraints(0, 0, 0, 0, GridBagConstraints.BOTH, 0, 5, 0, 5)); pathBlock.add(pathText, GuiUtil.setConstraints(1, 0, 1, 1, GridBagConstraints.BOTH, 0, 5, 0, 5)); pathBlock.add(browseButton, GuiUtil.setConstraints(2, 0, 0, 1, GridBagConstraints.BOTH, 0, 5, 0, 5)); Box box = Box.createHorizontalBox(); box.add(useBuckets); box.add(Box.createHorizontalStrut(5)); box.add(noOfBuckets); useBuckets.setIconTextGap(10); pathBlock.add(box, GuiUtil.setConstraints(0, 1, 2, 1, 0, 0, GridBagConstraints.BOTH, 5, 5, 5, 5)); } } noExport.addActionListener(e -> setEnabledTextureExport()); exportAll.addActionListener(e -> setEnabledTextureExport()); overwriteCheck.addActionListener(e -> {if (overwriteCheck.isSelected()) noTexturesCheck.setSelected(false); }); noTexturesCheck.addActionListener(e -> {if (noTexturesCheck.isSelected()) overwriteCheck.setSelected(false); }); useBuckets.addActionListener(e -> noOfBuckets.setEnabled(useBuckets.isSelected())); noOfBuckets.addPropertyChangeListener(evt -> { if (((Number)noOfBuckets.getValue()).intValue() < 0) noOfBuckets.setValue(-((Number)noOfBuckets.getValue()).intValue()); }); }
Example 20
Source File: KsTplTextEditor.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Override protected void addCustomComponents(@Nonnull final JPanel panel, @Nonnull final GridBagConstraints gbdata) { final JButton buttonClipboardText = new JButton(ICON_PLANTUML); buttonClipboardText.setName("BUTTON.PLANTUML"); buttonClipboardText.setToolTipText("Copy formed PlantUML script to clipboard"); buttonClipboardText.addActionListener((ActionEvent e) -> { Toolkit.getDefaultToolkit().getSystemClipboard() .setContents(new StringSelection(preprocessEditorText(editor.getText())), null); }); checkBoxGroupTopics = new JCheckBox("Group topics ", this.modeGroupTopics); checkBoxGroupTopics.setName(PROPERTY_TOPICS_GROUP); checkBoxGroupTopics.setToolTipText("Group all topics on scheme together"); checkBoxGroupTopics.addActionListener((x) -> { this.onConfigCheckboxChange(checkBoxGroupTopics); }); checkBoxGroupStores = new JCheckBox("Group stores ", this.modeGroupStores); checkBoxGroupStores.setName(PROPERTY_STORE_GROUP); checkBoxGroupStores.setToolTipText("Group all stores on scheme together"); checkBoxGroupStores.addActionListener((x) -> { this.onConfigCheckboxChange(checkBoxGroupStores); }); checkBoxOrtho = new JCheckBox("Orthogonal lines ", this.modeOrtho); checkBoxOrtho.setName(PROPERTY_ORTHOGONAL); checkBoxOrtho.setToolTipText("Orthogonal connector lines"); checkBoxOrtho.addActionListener((x) -> { this.onConfigCheckboxChange(checkBoxOrtho); }); checkBoxHorizontal = new JCheckBox("Horizontal layout ", this.modeHoriz); checkBoxHorizontal.setName(PROPERTY_LAYOUT_HORIZ); checkBoxHorizontal.setToolTipText("Horizontal layouting of components"); checkBoxHorizontal.addActionListener((x) -> { this.onConfigCheckboxChange(checkBoxHorizontal); }); panel.add(buttonClipboardText, gbdata); panel.add(checkBoxGroupTopics, gbdata); panel.add(checkBoxGroupStores, gbdata); panel.add(checkBoxOrtho, gbdata); panel.add(checkBoxHorizontal, gbdata); }