List of usage examples for javax.swing JCheckBox isSelected
public boolean isSelected()
From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java
public void search() { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, "State: " + state); if (state == QUERY_STATE.WAITING_FOR_RESULTS) { Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, "Prunning query"); pruneQuery();/*from www .j a va2s . com*/ return; } this.jButtonDownload.setEnabled(false); lastQueryExecuted = jTextFieldQuery.getText(); lastQueryKeywords = jCheckBoxKeywords.isSelected(); lastQueryAdvanced = false; HashMap<String, Boolean> plugins = new HashMap<String, Boolean>(); boolean isSelectedPlugins = false; for (JCheckBox box : this.ranges) { plugins.put(box.getText(), box.isSelected()); isSelectedPlugins = isSelectedPlugins || box.isSelected(); } if (!isSelectedPlugins) { JOptionPane.showMessageDialog(this, "Please select a source to search", "Missing data source", JOptionPane.INFORMATION_MESSAGE); } else { basicSearch = true; searchTree.search(lastQueryExecuted, lastQueryKeywords, plugins); state = QUERY_STATE.WAITING_FOR_RESULTS; jButtonSearch.setText("Cancel"); cleanThumbnails(); QueryHistorySupport.getInstance().saveQueryHistory(); } }
From source file:pt.ua.dicoogle.rGUI.client.windows.MainWindow.java
private void AdvancedSearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AdvancedSearchButtonActionPerformed lastQueryExecuted = getAdvancedQuery(); lastQueryAdvanced = true;//from w ww. j av a2s . c o m HashMap<String, Boolean> plugins = new HashMap<String, Boolean>(); for (JCheckBox box : this.ranges) { plugins.put(box.getText(), box.isSelected()); } searchTree.search(lastQueryExecuted, true, plugins); cleanThumbnails(); }
From source file:rita.ui.component.DialogSelectEnemies.java
private void enablePositionOptions(boolean enable) { if (!enable) { canSelectPosition = false;//from ww w.j a v a 2 s .c om for (Component comp : positionComponents) { comp.setEnabled(false); } } else { canSelectPosition = true; buttonPos.setEnabled(true); for (Component compPanel : panelSelectRobots.getComponents()) { JPanel parent = (JPanel) compPanel; // para cada panel la primer componente es el check y el segundo // es el boton JCheckBox check = (JCheckBox) parent.getComponent(0); if (check.isSelected()) { JButton button = (JButton) parent.getComponent(1); button.setEnabled(true); } } } }
From source file:ro.nextreports.designer.NextReports.java
public static void showStartDialog(boolean test) { JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS)); final JCheckBox chk = new JCheckBox(I18NSupport.getString("start.panel.show.startup"), true); bottomPanel.add(chk);/*w ww. j a va 2 s.c o m*/ bottomPanel.add(Box.createHorizontalGlue()); String start = ReporterPreferencesManager.getInstance() .loadParameter(ReporterPreferencesManager.SHOW_AT_STARTUP + "_" + ReleaseInfo.getVersion()); if (test && "false".equals(start)) { return; } HelpMovieAction helpAction = new HelpMovieAction(); VistaButton buttonHelp = new VistaButton(helpAction, I18NSupport.getString("start.panel.help")); ImportAction importAction = new ImportAction(); VistaButton buttonImport = new VistaButton(importAction, I18NSupport.getString("start.panel.import")); AddDataSourceAction dataSourceAction = new AddDataSourceAction(); VistaButton buttonDataSource = new VistaButton(dataSourceAction, I18NSupport.getString("start.panel.datasource")); WizardAction wizardAction = new WizardAction(Globals.getMainFrame().getQueryBuilderPanel().getTree()); VistaButton buttonWizard = new VistaButton(wizardAction, I18NSupport.getString("start.panel.wizard")); List<VistaButton> list = new ArrayList<VistaButton>(); list.add(buttonHelp); list.add(buttonImport); list.add(buttonDataSource); list.add(buttonWizard); VistaDialogContent content = new VistaDialogContent(list, I18NSupport.getString("start.panel.title"), I18NSupport.getString("start.panel.subtitle")); VistaDialog dialog = new VistaDialog(content, bottomPanel, Globals.getMainFrame(), true) { private static final long serialVersionUID = 1L; @Override protected void beforeDispose() { String show = chk.isSelected() ? "true" : "false"; ReporterPreferencesManager.getInstance().storeParameter( ReporterPreferencesManager.SHOW_AT_STARTUP + "_" + ReleaseInfo.getVersion(), show); } }; dialog.setTitle(I18NSupport.getString("menu.startup")); dialog.selectButton(buttonHelp); dialog.setDispose(true); dialog.setEscapeOption(true); dialog.pack(); dialog.setResizable(false); Show.centrateComponent(Globals.getMainFrame(), dialog); dialog.setVisible(true); }
From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java
private void initUI() { setLayout(new GridBagLayout()); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); components = new ArrayList<JComponent>(); checks = new ArrayList<JCheckBox>(); int size = paramList.size(); boolean shouldExpand = false; boolean needScroll = false; for (int i = 0; i < size; i++) { final int pos = i; final QueryParameter param = paramList.get(i); if (param.isHidden()) { components.add(null);//from w ww .j a v a2s . c o m checks.add(null); initHiddenParameterValues(param); continue; } String source = param.getSource(); String defaultSource = param.getDefaultSource(); if ((defaultSource != null) && !defaultSource.trim().equals("")) { try { param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param)); } catch (NextSqlException e) { Show.error(e); } } final JComponent component; int anchor = GridBagConstraints.WEST; double y = 0.0; int expand = GridBagConstraints.HORIZONTAL; if ((source != null) && !source.equals("")) { List<IdName> values = new ArrayList<IdName>(); try { if (param.isManualSource()) { if (!param.isDependent()) { values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy()); } } else { int index = source.indexOf("."); int index2 = source.lastIndexOf("."); String tableName = source.substring(0, index); String columnName; String shownColumnName = null; if (index == index2) { columnName = source.substring(index + 1); } else { columnName = source.substring(index + 1, index2); shownColumnName = source.substring(index2 + 1); } values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName, columnName, shownColumnName, param.getOrderBy()); } } catch (NextSqlException e) { error = true; Show.error(e); } catch (InvalidSqlException e) { String m = I18NSupport.getString("source.dialog.valid"); Show.info(m + " : \"select <exp1> , <exp2> from ...\""); } if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) { component = new JComboBox(); final JComboBox combo = (JComboBox) component; combo.setRenderer(new IdNameRenderer()); combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --"); for (int j = 0, len = values.size(); j < len; j++) { combo.addItem(values.get(j)); } combo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { IdName in = null; if (combo.getSelectedIndex() > 0) { in = (IdName) combo.getSelectedItem(); } parameterSelection(pos, in); } } }); AutoCompleteDecorator.decorate(combo); needScroll = false; } else { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; DefaultListModel model = new DefaultListModel(); for (int j = 0, len = values.size(); j < len; j++) { model.addElement(values.get(j)); } List srcList = Arrays.asList(model.toArray()); component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } // needed for saved parameters on rerun protected void onSetRight() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getDestinationElements().toArray(); if (values.length == 0) { values = new Object[] { ParameterUtil.NULL }; } parameterSelection(pos, values); } } }; ((ListSelectionPanel) component).setListSize(scrListDim); ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(), new IdNameComparator(param.getOrderBy())); shouldExpand = true; } } else { if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; ; component = new ListAddPanel(param) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getElements().toArray(); parameterSelection(pos, values); } } }; } else { needScroll = false; if (param.getValueClassName().equals("java.util.Date")) { component = new JXDatePicker(); ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("date".equals(e.getPropertyName())) { parameterSelection(pos, ((JXDatePicker) component).getDate()); } } }); // hack to fix bug with big popup button JButton popupButton = (JButton) component.getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.sql.Timestamp") || param.getValueClassName().equals("java.sql.Time")) { component = new JDateTimePicker() { protected void onChange() { parameterSelection(pos, getDate()); } }; // hack to fix bug with big popup button JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker()) .getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.lang.Boolean")) { component = new JCheckBox(); ((JCheckBox) component).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); parameterSelection(pos, selected); } }); } else { component = new JTextField(25); ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void insertUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void removeUpdate(DocumentEvent e) { updateFromTextField(e); } private void updateFromTextField(DocumentEvent e) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { Object value = null; try { if ("".equals(((JTextField) component).getText().trim())) { value = null; } else { value = ParameterUtil.getParameterValueFromString( param.getValueClassName(), ((JTextField) component).getText()); } parameterSelection(pos, value); } catch (Exception e) { e.printStackTrace(); LOG.error(e.getMessage(), e); } } }); } }); } } } components.add(component); final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore")); checks.add(cb); final JLabel label = new JLabel(getRuntimeParameterName(param)); panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); final JComponent addComponent; if (needScroll) { JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scr.setPreferredSize(listDim); addComponent = scr; } else { addComponent = component; } panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand, new Insets(5, 0, 5, 5), 0, 0)); int checkAnchor = GridBagConstraints.WEST; if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) { checkAnchor = GridBagConstraints.NORTHWEST; } if (Globals.getParametersIgnore()) { panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); } cb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (cb.isSelected()) { if (addComponent instanceof JScrollPane) { component.setEnabled(false); } label.setEnabled(false); addComponent.setEnabled(false); param.setIgnore(true); } else { if (addComponent instanceof JScrollPane) { component.setEnabled(true); } label.setEnabled(true); addComponent.setEnabled(true); param.setIgnore(false); } } }); } // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter) // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here for (int i = 0; i < size; i++) { final QueryParameter param = paramList.get(i); if (param.isHidden()) { populateDependentParameters(param, false); } } if (!shouldExpand) { panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrPanel.setPreferredSize(scrDim); scrPanel.setMinimumSize(scrDim); add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); setParameterValues(parametersValues); setParameterIgnore(parametersIgnore); }
From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.components.DropDownButton.java
private void init(boolean searchFieldEnabled) { setIcon(ImageResourceHelper/* ww w . j a v a2 s . c o m*/ .loadImage("/sk/stuba/fiit/kvasnicka/topologyvisual/resources/files/arrow_down.gif")); setHorizontalTextPosition(JButton.LEFT); setFocusPainted(false); addActionListener(this); mainPanel.setLayout(new BorderLayout()); JPanel northPanel = new JPanel(new BorderLayout()); if (searchFieldEnabled) { addSearchField(northPanel); } final JCheckBox chSelectAll = new JCheckBox("All"); chSelectAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectAll(chSelectAll.isSelected()); } }); chSelectAll.setAlignmentX(LEFT_ALIGNMENT); northPanel.add(chSelectAll, BorderLayout.CENTER); northPanel.setAlignmentX(LEFT_ALIGNMENT); northPanel.setBackground(Color.red); mainPanel.add(northPanel, BorderLayout.NORTH); checkPanel.setLayout(new BoxLayout(checkPanel, BoxLayout.PAGE_AXIS)); scrollPane.setViewportView(checkPanel); scrollPane.setPreferredSize(new Dimension(200, 100)); mainPanel.add(scrollPane, BorderLayout.CENTER); popup.add(mainPanel); popup.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { fireDropDownHiddenEvent(new DropDownHiddenEvent(this, getSelectedCheckBoxItems())); } @Override public void popupMenuCanceled(PopupMenuEvent e) { } }); }
From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.components.DropDownButton.java
/** * returns labels of all selected JCheckBoxMenuItem * * @return//from w w w . j a va 2 s . co m */ public List<String> getSelectedCheckBoxItems() { List<String> list = new LinkedList<String>(); for (JCheckBox item : checkBoxMenuItems) { if (item.isSelected()) { list.add(item.getText()); } } return list; }
From source file:storybook.model.EntityUtil.java
public static List<JCheckBox> createPersonCheckBoxes(MainFrame mainFrame, List<JCheckBox> cbl, ActionListener comp) {//from w ww .j av a 2 s .co m List<JCheckBox> list = new ArrayList<>(); BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); PersonDAOImpl dao = new PersonDAOImpl(session); for (JCheckBox cb : cbl) { if (cb.isSelected()) { Category category = (Category) cb.getClientProperty(SbConstants.ComponentName.CB_CATEGORY); List<Person> persons = dao.findByCategory(category); for (Person person : persons) { JCheckBox cbPerson = new JCheckBox(person.getFullNameAbbr()); cbPerson.setOpaque(false); cbPerson.putClientProperty(SbConstants.ComponentName.CB_PERSON, person); cbPerson.addActionListener(comp); list.add(cbPerson); } } } model.commit(); return list; }
From source file:uk.nhs.cfh.dsp.srth.expression.repository.actions.core.PurgeExpressionRepositoryAction.java
public void actionPerformed(ActionEvent e) { JPanel innerPanel = new JPanel(new BorderLayout()); JXLabel label = new JXLabel("This action will delete all unique expressions stored in the database. " + "This usually renders the transitive closure table useless. " + "Do you really want to continue?"); label.setLineWrap(true);//from ww w. j a v a2 s .c o m label.setMaxLineSpan(300); innerPanel.add(label, BorderLayout.CENTER); // add a checkbox that controls if transitive closure table is purged JCheckBox purgeTCTableCheckBox = new JCheckBox("Purge Transitive Closure table"); innerPanel.add(purgeTCTableCheckBox, BorderLayout.SOUTH); int choice = JOptionPane.showConfirmDialog(applicationService.getFrameView().getActiveFrame(), innerPanel, "Confirm deletion", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.YES_OPTION) { PurgeExpressionRepositoryTask task = new PurgeExpressionRepositoryTask( applicationService.getActiveApplication()); applicationService.getActiveApplication().getContext().getTaskService().execute(task); // purge tc table if purgeTCTable is true if (purgeTCTableCheckBox.isSelected()) { PurgeTCTableTask tcTableTask = new PurgeTCTableTask(applicationService, expressionSubsumptionRelationshipDAO); applicationService.getActiveApplication().getContext().getTaskService().execute(tcTableTask); } } }
From source file:uk.nhs.cfh.dsp.yasb.searchpanel.SearchPanel.java
/** * Creates the control panel./*from w ww . j ava2 s . c o m*/ */ private synchronized void createControlPanel() { // set controls for rendering concept ids and labels in a collapsible pane controlsPane = new JXCollapsiblePane(new GridLayout(0, 1)); controlsPane.setName("controlsPane"); final JComboBox conceptTypeBox = new JComboBox(ConceptType.values()); // set default value to UNKNOWN, which will return all types conceptTypeBox.setSelectedItem(ConceptType.UNKNOWN); conceptTypeBox.setAction(new AbstractAction() { public void actionPerformed(ActionEvent e) { // get selected value Object selection = conceptTypeBox.getSelectedItem(); if (selection instanceof ConceptType) { selectedConceptType = (ConceptType) conceptTypeBox.getSelectedItem(); doSearch(); } } }); JPanel panel1 = new JPanel(); panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS)); panel1.add(new JLabel("Concept Type")); panel1.add(Box.createHorizontalStrut(10)); panel1.add(conceptTypeBox); final JComboBox statusBox = new JComboBox(ComponentStatus.values()); statusBox.setSelectedItem(ComponentStatus.CURRENT); statusBox.setAction(new AbstractAction() { public void actionPerformed(ActionEvent arg0) { Object selection = statusBox.getSelectedItem(); if (selection instanceof ComponentStatus) { selectedConceptStatus = (ComponentStatus) statusBox.getSelectedItem(); doSearch(); } } }); JPanel panel2 = new JPanel(); panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS)); panel2.add(new JLabel("Concept Status")); panel2.add(Box.createHorizontalStrut(10)); panel2.add(statusBox); // create stemming enabling checkbox final JCheckBox enableStemmingCheckBox = new JCheckBox(); enableStemmingCheckBox.setAction(new AbstractAction("Enable Stemming") { public void actionPerformed(ActionEvent arg0) { if (enableStemmingCheckBox.isSelected()) { // change analyser selectedAnalyzer = new SnowballAnalyzer("English"); logger.debug("Enabled Stemming"); doSearch(); } else { selectedAnalyzer = new StandardAnalyzer(); logger.debug("Disabled Stemming"); doSearch(); } } }); renderConceptIdsBox = new JCheckBox(new AbstractAction("Render Concept IDs") { public void actionPerformed(ActionEvent e) { // toggle status in tree cell renderer renderer.setRenderConceptId(renderConceptIdsBox.isSelected()); // refresh tree SwingUtilities.updateComponentTreeUI(resultsList); } }); renderConceptIdsBox.setName("preferFSNOverPTJCheckBox"); preferFSNOverPTJCheckBox = new JCheckBox(new AbstractAction("Prefer FSN over PT") { public void actionPerformed(ActionEvent e) { // toggle preference in renderer renderer.setPreferFSNOverPT(preferFSNOverPTJCheckBox.isSelected()); // refresh tree SwingUtilities.updateComponentTreeUI(resultsList); } }); preferFSNOverPTJCheckBox.setName("preferFSNOverPTJCheckBox"); // add panels to controlsPane controlsPane.add(panel1); controlsPane.add(panel2); controlsPane.add(enableStemmingCheckBox); controlsPane.add(renderConceptIdsBox); controlsPane.add(preferFSNOverPTJCheckBox); controlsPane.setCollapsed(true); }