/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user changed the service filter option if (e.getSource() == service_box) { service_list.setEnabled(service_box.isSelected()); service_list.clearSelection(); remove_service_button.setEnabled(false); add_service_field.setEnabled(service_box.isSelected()); add_service_field.setText(""); add_service_button.setEnabled(false); } // Check if the user pressed the add service button if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) { String text = add_service_field.getText(); if ((text != null) && (text.length() > 0)) { service_data.addElement(text); service_list.setListData(service_data); } add_service_field.setText(""); add_service_field.requestFocus(); } // Check if the user pressed the remove service button if (e.getSource() == remove_service_button) { Object[] sels = service_list.getSelectedValues(); for (int i = 0; i < sels.length; i++) { service_data.removeElement(sels[i]); } service_list.setListData(service_data); service_list.clearSelection(); } }
void applyDirectives() { findRemoveDirectives(true); StringBuffer buffer = new StringBuffer(); String head = "", toe = "; \n"; if (crispBox.isSelected()) buffer.append(head + "crisp=true" + toe); if (!fontField.getText().trim().equals("")) buffer.append(head + "font=\"" + fontField.getText().trim() + "\"" + toe); if (globalKeyEventsBox.isSelected()) buffer.append(head + "globalKeyEvents=true" + toe); if (pauseOnBlurBox.isSelected()) buffer.append(head + "pauseOnBlur=true" + toe); if (!preloadField.getText().trim().equals("")) buffer.append(head + "preload=\"" + preloadField.getText().trim() + "\"" + toe); /*if ( transparentBox.isSelected() ) buffer.append( head + "transparent=true" + toe );*/ Sketch sketch = editor.getSketch(); SketchCode code = sketch.getCode(0); // first tab if (buffer.length() > 0) { code.setProgram("/* @pjs " + buffer.toString() + " */\n\n" + code.getProgram()); if (sketch.getCurrentCode() == code) // update textarea if on first tab { editor.setText(sketch.getCurrentCode().getProgram()); editor.setSelection(0, 0); } sketch.setModified(false); sketch.setModified(true); } }
@Override public void onExit() { // save all painters for (EntryListPanel panel : listPanelSet) { myjava.gui.syntax.Painter painter = panel.getPainter(); if (!painter.equals(myjava.gui.syntax.Painter.getDefaultInstance())) { myjava.gui.syntax.Painter.add(painter); setConfig("painter.userDefined." + painter.getName(), painter.toWritableString()); } if (painter.equals(painterComboBox.getSelectedItem())) { // selected painter setConfig("syntax.selectedPainter", painter.getName()); myjava.gui.syntax.Painter.setCurrentInstance(painter); } } // remove "removed painters" for (myjava.gui.syntax.Painter removed : removedPainters) { removeConfig0("painter.userDefined." + removed.getName()); myjava.gui.syntax.Painter.remove(removed); } // highlight? boolean _highlightSyntax = highlightSyntax.isSelected(); boolean _matchBracket = matchBracket.isSelected(); MyUmbrellaLayerUI.setHighlightingStatus(_highlightSyntax, _matchBracket); setConfig("syntax.highlight", _highlightSyntax + ""); setConfig("syntax.matchBrackets", _matchBracket + ""); }
public void actionPerformed(ActionEvent ae) { String cname = nameF.getText().trim(); int state = conditions[stateC.getSelectedIndex()]; try { if (isSpecialCase(cname)) { handleSpecialCase(cname, state); } else { JComponent comp = (JComponent) Class.forName(cname).newInstance(); ComponentUI cui = UIManager.getUI(comp); cui.installUI(comp); results.setText("Map entries for " + cname + ":\n\n"); if (inputB.isSelected()) { loadInputMap(comp.getInputMap(state), ""); results.append("\n"); } if (actionB.isSelected()) { loadActionMap(comp.getActionMap(), ""); results.append("\n"); } if (bindingB.isSelected()) { loadBindingMap(comp, state); } } } catch (ClassCastException cce) { results.setText(cname + " is not a subclass of JComponent."); } catch (ClassNotFoundException cnfe) { results.setText(cname + " was not found."); } catch (InstantiationException ie) { results.setText(cname + " could not be instantiated."); } catch (Exception e) { results.setText("Exception found:\n" + e); e.printStackTrace(); } }
/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the ok button if (e.getSource() == ok_button) { filter_include_list = include_panel.getServiceList(); filter_exclude_list = exclude_panel.getServiceList(); if (status_box.isSelected()) { filter_active = status_active.isSelected(); filter_complete = status_complete.isSelected(); } else { filter_active = false; filter_complete = false; } ok_pressed = true; dialog.dispose(); } // Check if the user pressed the cancel button if (e.getSource() == cancel_button) { dialog.dispose(); } // Check if the user changed the status filter option if (e.getSource() == status_box) { status_active.setEnabled(status_box.isSelected()); status_complete.setEnabled(status_box.isSelected()); } }
/** * The ActionListener implementation * * @param event the event. */ public void actionPerformed(ActionEvent event) { String searchText = textField.getText().trim(); if (searchText.equals("") && !saveAs.isSelected() && (fileLength > 10000000)) { textPane.setText("Blank search text is not allowed for large IdTables."); } else { File outputFile = null; if (saveAs.isSelected()) { outputFile = chooser.getSelectedFile(); if (outputFile != null) { String name = outputFile.getName(); int k = name.lastIndexOf("."); if (k != -1) name = name.substring(0, k); name += ".txt"; File parent = outputFile.getAbsoluteFile().getParentFile(); outputFile = new File(parent, name); chooser.setSelectedFile(outputFile); } if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) System.exit(0); outputFile = chooser.getSelectedFile(); } textPane.setText(""); Searcher searcher = new Searcher(searchText, event.getSource().equals(searchPHI), outputFile); searcher.start(); } }
/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the remove button if (e.getSource() == remove_button) { int row = table.getSelectedRow(); model.removeRow(row); table.clearSelection(); table.repaint(); valueChanged(null); } // Check if the user pressed the remove all button if (e.getSource() == remove_all_button) { model.clearAll(); table.setRowSelectionInterval(0, 0); table.repaint(); valueChanged(null); } // Check if the user pressed the filter button if (e.getSource() == filter_button) { filter.showDialog(); if (filter.okPressed()) { // Update the display with new filter model.setFilter(filter); table.repaint(); } } // Check if the user pressed the start button if (e.getSource() == start_button) { start(); } // Check if the user pressed the stop button if (e.getSource() == stop_button) { stop(); } // Check if the user wants to switch layout if (e.getSource() == layout_button) { details_panel.remove(details_soap); details_soap.removeAll(); if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT); } else { details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); } details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.validate(); details_panel.repaint(); } // Check if the user is changing the reflow option if (e.getSource() == reflow_xml) { request_text.setReflowXML(reflow_xml.isSelected()); response_text.setReflowXML(reflow_xml.isSelected()); } }
/** * Saves the user input when the "Next" wizard buttons is clicked. * * @param registration the SIPAccountRegistration * @return */ public boolean commitPanel(SecurityAccountRegistration registration) { registration.setDefaultEncryption(enableDefaultEncryption.isSelected()); registration.setEncryptionProtocols(encryptionConfigurationTableModel.getEncryptionProtocols()); registration.setEncryptionProtocolStatus( encryptionConfigurationTableModel.getEncryptionProtocolStatus()); registration.setSipZrtpAttribute(enableSipZrtpAttribute.isSelected()); registration.setSavpOption(((SavpOption) cboSavpOption.getSelectedItem()).option); registration.setSDesCipherSuites(cipherModel.getEnabledCiphers()); return true; }
/** Returns false if Exception is thrown. */ private boolean setDirectory() { String pathStr = dirTF.getText().trim(); if (pathStr.equals("")) pathStr = System.getProperty("user.dir"); try { File dirPath = new File(pathStr); if (!dirPath.isDirectory()) { if (!dirPath.exists()) { if (recursiveCheckBox.isSelected()) throw new NotDirectoryException(dirPath.getAbsolutePath()); else throw new NotFileException(dirPath.getAbsolutePath()); } else { convertSet.setFile(dirPath); convertSet.setDestinationPath(dirPath.getParentFile()); } } else { // Set the descriptors setMatchingFileNames(); FlexFilter flexFilter = new FlexFilter(); flexFilter.addDescriptors(descriptors); flexFilter.setFilesOnly(!recursiveCheckBox.isSelected()); convertSet.setSourcePath(dirPath, flexFilter); convertSet.setDestinationPath(dirPath); } } catch (NotDirectoryException e1) { final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption1"); MessageFormat formatter; String info_msg; if (pathStr.equals("")) { info_msg = ResourceHandler.getMessage("notdirectory_dialog.info5"); } else { formatter = new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info0")); info_msg = formatter.format(new Object[] {pathStr}); } final String info = info_msg; JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE); return false; } catch (NotFileException e2) { final String caption = ResourceHandler.getMessage("notdirectory_dialog.caption0"); MessageFormat formatter = new MessageFormat(ResourceHandler.getMessage("notdirectory_dialog.info1")); final String info = formatter.format(new Object[] {pathStr}); JOptionPane.showMessageDialog(this, info, caption, JOptionPane.ERROR_MESSAGE); return false; } return true; // no exception thrown }
/** Constructor */ public ServiceFilterPanel(String text, Vector list) { empty_border = new EmptyBorder(5, 5, 0, 5); indent_border = new EmptyBorder(5, 25, 5, 5); service_box = new JCheckBox(text); service_box.addActionListener(this); service_data = new Vector(); if (list != null) { service_box.setSelected(true); service_data = (Vector) list.clone(); } service_list = new JList(service_data); service_list.setBorder(new EtchedBorder()); service_list.setVisibleRowCount(5); service_list.addListSelectionListener(this); service_list.setEnabled(service_box.isSelected()); service_scroll = new JScrollPane(service_list); service_scroll.setBorder(new EtchedBorder()); remove_service_button = new JButton("Remove"); remove_service_button.addActionListener(this); remove_service_button.setEnabled(false); remove_service_panel = new JPanel(); remove_service_panel.setLayout(new FlowLayout()); remove_service_panel.add(remove_service_button); service_area = new JPanel(); service_area.setLayout(new BorderLayout()); service_area.add(service_scroll, BorderLayout.CENTER); service_area.add(remove_service_panel, BorderLayout.EAST); service_area.setBorder(indent_border); add_service_field = new JTextField(); add_service_field.addActionListener(this); add_service_field.getDocument().addDocumentListener(this); add_service_field.setEnabled(service_box.isSelected()); add_service_button = new JButton("Add"); add_service_button.addActionListener(this); add_service_button.setEnabled(false); add_service_panel = new JPanel(); add_service_panel.setLayout(new BorderLayout()); JPanel dummy = new JPanel(); dummy.setBorder(empty_border); add_service_panel.add(dummy, BorderLayout.WEST); add_service_panel.add(add_service_button, BorderLayout.EAST); add_service_area = new JPanel(); add_service_area.setLayout(new BorderLayout()); add_service_area.add(add_service_field, BorderLayout.CENTER); add_service_area.add(add_service_panel, BorderLayout.EAST); add_service_area.setBorder(indent_border); setLayout(new BorderLayout()); add(service_box, BorderLayout.NORTH); add(service_area, BorderLayout.CENTER); add(add_service_area, BorderLayout.SOUTH); setBorder(empty_border); }
/** @return unstash handler */ private GitLineHandler handler() { GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH); h.setNoSSH(true); String branch = myBranchTextField.getText(); if (branch.length() == 0) { h.addParameters(myPopStashCheckBox.isSelected() ? "pop" : "apply"); if (myReinstateIndexCheckBox.isSelected()) { h.addParameters("--index"); } } else { h.addParameters("branch", branch); } String selectedStash = getSelectedStash().getStash(); addStashParameter(h, selectedStash); return h; }
public void saveDisplayObjectType() { DOTPoint newDOTPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType().getCopy(null); final String name = _dotDefinitionDialogFrame.getNameText(); if ((name == null) || (name.length() == 0)) { JOptionPane.showMessageDialog( new JFrame(), "Bitte geben Sie einen Namen an!", "Fehler", JOptionPane.ERROR_MESSAGE); return; } if (!_dotDefinitionDialogFrame.isReviseOnly()) { if (_dotDefinitionDialogFrame.getDotManager().containsDisplayObjectType(name)) { JOptionPane.showMessageDialog( new JFrame(), "Ein Darstellungstyp mit diesem Namen existiert bereits!", "Fehler", JOptionPane.ERROR_MESSAGE); return; } } newDOTPoint.setName(name); newDOTPoint.setInfo(_dotDefinitionDialogFrame.getInfoText()); final Object value = _translationFactorSpinner.getValue(); if (value instanceof Number) { final Number number = (Number) value; newDOTPoint.setTranslationFactor(number.doubleValue()); } newDOTPoint.setJoinByLine(_joinByLineCheckBox.isSelected()); _dotDefinitionDialogFrame.getDotManager().saveDisplayObjectType(newDOTPoint); _dotDefinitionDialogFrame.setDisplayObjectType(newDOTPoint, true); }
private Component createOptionsPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); onlyShowOutputOnErrorCheckBox = new JCheckBox("Only Show Output When Errors Occur"); onlyShowOutputOnErrorCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { updateShowOutputOnErrorsSetting(); settingsNode.setValueOfChildAsBoolean( SHOW_OUTPUT_ON_ERROR, onlyShowOutputOnErrorCheckBox.isSelected()); } }); // initialize its default value boolean valueAsBoolean = settingsNode.getValueOfChildAsBoolean( SHOW_OUTPUT_ON_ERROR, onlyShowOutputOnErrorCheckBox.isSelected()); onlyShowOutputOnErrorCheckBox.setSelected(valueAsBoolean); updateShowOutputOnErrorsSetting(); panel.add(Utility.addLeftJustifiedComponent(onlyShowOutputOnErrorCheckBox)); return panel; }
/** * Closes dialog box when the OK button is pressed, sets variables and calls algorithm. * * @param event Event that triggers function. */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); Object source = event.getSource(); if (command.equals("OK")) { if (setVariables()) { callAlgorithm(); } } else if (command.equals("Cancel")) { dispose(); } else if (command.equals("Help")) { // MipavUtil.showHelp(""); } else if (source.equals(doRicianCheckBox)) { if (doRicianCheckBox.isSelected()) { labelDegree.setEnabled(true); textDegree.setEnabled(true); } else { labelDegree.setEnabled(false); textDegree.setEnabled(false); } } else { // else if (source == thresholdCheckbox) super.actionPerformed(event); } }
private void updateComponents() { boolean archetypesEnabled = myUseArchetypeCheckBox.isSelected(); myAddArchetypeButton.setEnabled(archetypesEnabled); myArchetypesTree.setEnabled(archetypesEnabled); myArchetypesTree.setBackground( archetypesEnabled ? UIUtil.getListBackground() : UIUtil.getPanelBackground()); }
/** Get the current list of services */ public Vector getServiceList() { Vector list = null; if (service_box.isSelected()) { list = service_data; } return list; }
private void loadStates() { boolean b = enableDefaultEncryption.isSelected(); cboSavpOption.setEnabled(b); this.encryptionProtocolPreferences.setEnabled(b); enableSipZrtpAttribute.setEnabled( b && this.encryptionConfigurationTableModel.isEnabledLabel("ZRTP")); tabCiphers.setEnabled(b && this.encryptionConfigurationTableModel.isEnabledLabel("SDES")); }
private boolean anyDeselected(JCheckBox[] checkBoxes) { for (JCheckBox checkBox : checkBoxes) { if (!checkBox.isSelected()) { return true; } } return false; }
/** Invoked when an action occurs. */ @Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(fixSceneWidthCheck)) { imageCanvas.setImageWidthFixed(fixSceneWidthCheck.isSelected()); final boolean enable = !fixSceneWidthCheck.isSelected(); paramX1.setUIEnabled(enable); paramX2.setUIEnabled(enable); } if (e.getSource().equals(fixSceneHeightCheck)) { imageCanvas.setImageHeightFixed(fixSceneHeightCheck.isSelected()); final boolean enable = !fixSceneHeightCheck.isSelected(); paramY1.setUIEnabled(enable); paramY2.setUIEnabled(enable); } if (e.getSource().equals(setToVisibleButton)) { imageCanvas.setSliderBoxBounds(imageScrollPane.getViewport().getViewRect(), true); } }
int countChecked(boolean checked) { int counter = 0; for (JCheckBox checker : checkers) { if (checker.isSelected() == checked) { counter++; } } return counter; }
private void updateComponentStatus() { /* * enable/disable component by first checkbox */ boolean enable = highlightSyntax.isSelected(); for (JComponent c : componentSet) { c.setEnabled(enable); } }
/*-------------------------------------------------------------------------*/ public List<FoeType> getFoeTypes() { List<FoeType> result = new ArrayList<FoeType>(); for (JCheckBox cb : checkBoxes.values()) { if (cb.isSelected()) { result.add(Database.getInstance().getFoeTypes().get(cb.getText())); } } return result; }
/** Update state dialog depending on the current state of the fields */ private void updateDialogState() { String branch = myBranchTextField.getText(); if (branch.length() != 0) { setOKButtonText(GitBundle.getString("unstash.button.branch")); myPopStashCheckBox.setEnabled(false); myPopStashCheckBox.setSelected(true); myReinstateIndexCheckBox.setEnabled(false); myReinstateIndexCheckBox.setSelected(true); if (!GitBranchNameValidator.INSTANCE.checkInput(branch)) { setErrorText(GitBundle.getString("unstash.error.invalid.branch.name")); setOKActionEnabled(false); return; } if (myBranches.contains(branch)) { setErrorText(GitBundle.getString("unstash.error.branch.exists")); setOKActionEnabled(false); return; } } else { if (!myPopStashCheckBox.isEnabled()) { myPopStashCheckBox.setSelected(false); } myPopStashCheckBox.setEnabled(true); setOKButtonText( myPopStashCheckBox.isSelected() ? GitBundle.getString("unstash.button.pop") : GitBundle.getString("unstash.button.apply")); if (!myReinstateIndexCheckBox.isEnabled()) { myReinstateIndexCheckBox.setSelected(false); } myReinstateIndexCheckBox.setEnabled(true); } if (myStashList.getModel().getSize() == 0) { myViewButton.setEnabled(false); myDropButton.setEnabled(false); myClearButton.setEnabled(false); setErrorText(null); setOKActionEnabled(false); return; } else { myClearButton.setEnabled(true); } if (myStashList.getSelectedIndex() == -1) { myViewButton.setEnabled(false); myDropButton.setEnabled(false); setErrorText(null); setOKActionEnabled(false); return; } else { myViewButton.setEnabled(true); myDropButton.setEnabled(true); } setErrorText(null); setOKActionEnabled(true); }
/** Saves SWARM properties. */ public synchronized void save() { super.save(); ((ControllerSWARM) controller).P.SWARM1 = cbsw1.isSelected(); ((ControllerSWARM) controller).P.SWARM2A = cbsw2a.isSelected(); ((ControllerSWARM) controller).P.SWARM2B = cbsw2b.isSelected(); // ((ControllerSWARM)controller).set_swarm2b(cbdynbott.isSelected()); ((ControllerSWARM) controller).zones = zones; ControllerSWARM z = (ControllerSWARM) controller; z.P.SWARM_DENSITY_SAMPLE_SIZE = density_sample_size; z.P.epsilon = epsilon; z.P.SWARM_FORECAST_LEAD_TIME = forecast_lead_time; z.P.input_var_lane = input_var_lane; z.P.meas_var_lane = meas_var_lane; z.P.swarm_phi = phi; z.P.swarm_psi = psi; z.P.SWARM_SAT_DEN_NUMBER = sat_den_multiplier; z.P.sat_smoother = sat_smoother; z.P.SWARM_SLOPE_SAMPLE_SIZE = slope_sample_size; return; }
private String getPropertiesFileSuffix() { if (myResourceBundle == null) { return myUseXMLBasedPropertiesCheckBox.isSelected() ? ".xml" : ".properties"; } return "." + myResourceBundle .getDefaultPropertiesFile() .getContainingFile() .getFileType() .getDefaultExtension(); }
@Override public boolean stopCellEditing() { if (myValue != null) { if (myValue.isBoolean()) { myValue.setValue(myCheckBox.isSelected()); } else { myValue.setValue(myField.getText().trim()); } } revaliateActions(); return super.stopCellEditing(); }
/** Update button enable/disable state according enableCheckBox. */ private void updateButtonsState() { sipProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); jabberProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); rtpProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); ice4jProtocolCheckBox.setEnabled(enableCheckBox.isSelected()); fileCountField.setEnabled(enableCheckBox.isSelected()); fileSizeField.setEnabled(enableCheckBox.isSelected()); fileSizeLabel.setEnabled(enableCheckBox.isSelected()); fileCountLabel.setEnabled(enableCheckBox.isSelected()); }
private void handleSpecialCase(String cname, int condition) { Component comp = null; JComponent mapComp = null; try { if (cname.equals("javax.swing.JApplet") || cname.equals("javax.swing.JDialog") || cname.equals("javax.swing.JFrame") || cname.equals("javax.swing.JWindow")) { comp = (Component) Class.forName(cname).newInstance(); mapComp = (JComponent) ((JApplet) comp).getLayeredPane(); results.setText("Map entries for " + cname + " (delegated to JRootPane):\n\n"); } else if (cname.equals("javax.swing.JInternalFrame")) { JDesktopPane jdp = new JDesktopPane(); JInternalFrame jif = new JInternalFrame("Demo"); jif.setVisible(true); jdp.add(jif); mapComp = jif; } if (inputB.isSelected()) { loadInputMap(mapComp.getInputMap(condition), ""); results.append("\n"); } if (actionB.isSelected()) { loadActionMap(mapComp.getActionMap(), ""); results.append("\n"); } if (bindingB.isSelected()) { loadBindingMap(mapComp, condition); } } catch (ClassCastException cce) { results.setText(cname + " is not a subclass of JComponent."); } catch (ClassNotFoundException cnfe) { results.setText(cname + " was not found."); } catch (InstantiationException ie) { results.setText(cname + " could not be instantiated."); } catch (Exception e) { results.setText("Exception found:\n" + e); e.printStackTrace(); } }
private void animate() { if (lastAnimationTime > targetTime) { removeTransitions(); animating = false; if (repeatAnimationCheckbox.isSelected()) { addAnimatedTransitions(); } } else { timeController.calculateCurrentTime(); lastAnimationTime = timeController.getCurrentTime(); diagramView.repaint(); // paint it again as time has past } }
String[] getSubsetNames() { String[] names = new String[countChecked(true)]; int pos = 0; for (int i = 0; i < checkers.size(); i++) { JCheckBox checker = checkers.get(i); if (checker.isSelected()) { ProductNode productNode = (ProductNode) productNodes[i]; names[pos] = productNode.getName(); pos++; } } return names; }