List of usage examples for javax.swing JCheckBox setSelected
public void setSelected(boolean b)
From source file:edu.ku.brc.af.ui.PasswordStrengthUI.java
/** * Hooks up a Password field to the Strength UI * @param pwdTF the password text field to be be hooked up to this * @param btn optional button that will be enabled when the PasswordText is not empty *//*w w w . j a v a 2 s . com*/ public void setPasswordField(final JTextField pwdTF, final JButton btn) { DocumentListener listener = new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { String txt = ((JTextField) pwdTF).getText(); if (StringUtils.isEmpty(txt)) { initialSet = true; doPainting = false; for (JCheckBox cbx : cbxs) { cbx.setSelected(false); } } else if (initialSet) { initialSet = false; } else { doPainting = true; } if (btn != null) { btn.setEnabled(!txt.isEmpty()); } if (doPainting) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { checkStrength(pwdTF.getText()); // ignore return boolean colorPanel.repaint(); } }); } } }; pwdTF.getDocument().addDocumentListener(listener); }
From source file:caarray.client.test.gui.GuiMain.java
private void initializeTests() throws Exception { int index = 0; ApiFacade apiFacade = new FullApiFacade(); List<ConfigurableTestSuite> shortTests = TestMain.getShortTestSuites(apiFacade); List<ConfigurableTestSuite> longTests = TestMain.getLongTestSuites(apiFacade); List<ConfigurableTestSuite> testSuites = new ArrayList<ConfigurableTestSuite>(); runTests = new boolean[shortTests.size() + longTests.size()]; for (ConfigurableTestSuite test : shortTests) { JCheckBox box = new JCheckBox(test.getDisplayName()); box.addChangeListener(new SelectTestListener(index)); box.setSelected(true); testCheckBoxes.add(box);//w w w .j ava 2 s . com selectionPanel.add(box); testSuites.add(test); index++; } for (ConfigurableTestSuite test : longTests) { JCheckBox box = new JCheckBox(test.getDisplayName()); box.addChangeListener(new SelectTestListener(index)); box.setSelected(false); testCheckBoxes.add(box); selectionPanel.add(box); testSuites.add(test); index++; } testSuiteCollection.add(testSuites); apiFacades.add(apiFacade); }
From source file:edu.ku.brc.af.ui.PasswordStrengthUI.java
/** * @param pwd// ww w. j av a2 s. com * @return */ private boolean checkStrengthInternal(final String pwd) { int upper = 0; int lower = 0; int numbers = 0; int special = 0; int length = 0; score = 0; Pattern p; Matcher m; if (StringUtils.isEmpty(pwd)) { return false; } // Password Length length = pwd.length(); if (length < 5) // length 4 or less { score += 3; } else if (length > 4 && length < 8) // length between 5 and 7 { score += 6; } else if (length > 7 && length < 16) // length between 8 and 15 { score += 12; } else if (length > 15) // length 16 or more { score += 18; } // 18 sub-total // Letters p = Pattern.compile(".??[a-z]"); m = p.matcher(pwd); while (m.find()) // at least one lower case letter { lower += 1; } if (lower > 0) { score += 1; // 19 } // Uppercase p = Pattern.compile(".??[A-Z]"); m = p.matcher(pwd); while (m.find()) // at least one upper case letter { upper += 1; // 20 } if (upper > 0) { score += 5; // 21 } // Includes Numbers p = Pattern.compile(".??[0-9]"); m = p.matcher(pwd); while (m.find()) // at least one number { numbers += 1; // 22 } if (numbers > 0) { score += 5; // 27 if (numbers > 1) { score += 2; // 29 if (numbers > 2) { score += 3; // 31 } } } // Special Characters p = Pattern.compile(".??[:,!,@,#,$,%,^,&,*,?,_,~]"); m = p.matcher(pwd); while (m.find()) // at least one special character { special += 1; // 32 } if (special > 0) { score += 5; // 37 if (special > 1) { score += 5; // 42 } } // Combinations if (upper > 0 && lower > 0) // both upper and lower case { score += 2; // 44 } if ((upper > 0 || lower > 0) && numbers > 0) // both letters and numbers { score += 2; // 46 } if ((upper > 0 || lower > 0) && numbers > 0 && special > 0) // letters, numbers, and special characters { score += 2; // 48 } if (upper > 0 && lower > 0 && numbers > 0 && special > 0) // upper, lower, numbers, and special characters { score += 2; // 50 } for (JCheckBox cbx : cbxs) { cbx.setSelected(false); } errReason = null; if (length < minPwdLen) { errReason = errorStrings[0]; } else { cbxs[0].setSelected(true); } if (numbers < PWD_NUMERIC) { errReason = errorStrings[1]; } else { cbxs[1].setSelected(true); } // Does it meet the password policy? if (upper < PWD_MIXED_CASE || lower < PWD_MIXED_CASE) { errReason = errorStrings[2]; } else { cbxs[2].setSelected(true); } if (special < PWD_SPECIAL) { errReason = errorStrings[3]; } else { cbxs[3].setSelected(true); } return true; }
From source file:de.mprengemann.intellij.plugin.androidicons.dialogs.IconImporter.java
private void updateExportResolutions() { final Set<Resolution> resolutions = controller.getExportResolutions(); for (JCheckBox checkBox : Arrays.asList(LDPICheckBox, MDPICheckBox, HDPICheckBox, XHDPICheckBox, XXHDPICheckBox, XXXHDPICheckBox, TVDPICheckBox)) { checkBox.removeActionListener(resolutionActionListener); final Resolution resolution = ((ResolutionButtonModel) checkBox.getModel()).getResolution(); checkBox.setSelected(resolutions.contains(resolution)); checkBox.addActionListener(resolutionActionListener); }/* w ww. ja v a 2s .co m*/ }
From source file:net.pandoragames.far.ui.swing.dialog.SettingsDialog.java
private void init() { this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); this.setResizable(false); JPanel basePanel = new JPanel(); basePanel.setLayout(new BoxLayout(basePanel, BoxLayout.Y_AXIS)); basePanel.setBorder(//from ww w.j av a2s .c o m BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); registerCloseWindowKeyListener(basePanel); // sink for error messages MessageLabel errorField = new MessageLabel(); errorField.setMinimumSize(new Dimension(100, swingConfig.getStandardComponentHight())); errorField.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); TwoComponentsPanel lineError = new TwoComponentsPanel(errorField, Box.createRigidArea(new Dimension(1, swingConfig.getStandardComponentHight()))); lineError.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineError); // character set JLabel labelCharset = new JLabel(swingConfig.getLocalizer().localize("label.default-characterset")); labelCharset.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(labelCharset); JComboBox listCharset = new JComboBox(swingConfig.getCharsetList().toArray()); listCharset.setAlignmentX(Component.LEFT_ALIGNMENT); listCharset.setSelectedItem(swingConfig.getDefaultCharset()); listCharset.setEditable(true); listCharset.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); listCharset.addActionListener(new CharacterSetListener(errorField)); listCharset.setEditor(new CharacterSetEditor(errorField)); basePanel.add(listCharset); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // select the group selector JPanel selectorPanel = new JPanel(); selectorPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); selectorPanel.setAlignmentX(Component.LEFT_ALIGNMENT); // linePattern.setAlignmentX( Component.LEFT_ALIGNMENT ); JLabel labelSelector = new JLabel(swingConfig.getLocalizer().localize("label.group-ref-indicator")); selectorPanel.add(labelSelector); JComboBox selectorBox = new JComboBox(FARConfig.GROUPREFINDICATORLIST); selectorBox.setSelectedItem(Character.toString(groupReference)); selectorBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JComboBox cbox = (JComboBox) event.getSource(); String indicator = (String) cbox.getSelectedItem(); groupReference = indicator.charAt(0); } }); selectorPanel.add(selectorBox); basePanel.add(selectorPanel); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // checkbox DO BACKUP JCheckBox doBackupFlag = new JCheckBox(swingConfig.getLocalizer().localize("label.create-backup")); doBackupFlag.setAlignmentX(Component.LEFT_ALIGNMENT); doBackupFlag.setHorizontalTextPosition(SwingConstants.LEADING); doBackupFlag.setSelected(replaceForm.isDoBackup()); doBackupFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { doBackup = ItemEvent.SELECTED == event.getStateChange(); backupFlagEvent = event; } }); basePanel.add(doBackupFlag); JTextField backupDirPathTextField = new JTextField(); backupDirPathTextField.setPreferredSize( new Dimension(SwingConfig.COMPONENT_WIDTH, swingConfig.getStandardComponentHight())); backupDirPathTextField.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); backupDirPathTextField.setText(backupDirectory.getPath()); backupDirPathTextField.setToolTipText(backupDirectory.getPath()); backupDirPathTextField.setEditable(false); JButton openBaseDirFileChooserButton = new JButton(swingConfig.getLocalizer().localize("button.browse")); BrowseButtonListener backupDirButtonListener = new BrowseButtonListener(backupDirPathTextField, new BackUpDirectoryRepository(swingConfig, findForm, replaceForm, errorField), swingConfig.getLocalizer().localize("label.choose-backup-directory")); openBaseDirFileChooserButton.addActionListener(backupDirButtonListener); TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(backupDirPathTextField, openBaseDirFileChooserButton); lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineBaseDir); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JPanel fileInfoPanel = new JPanel(); fileInfoPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), swingConfig.getLocalizer().localize("label.default-file-info"))); fileInfoPanel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.setLayout(new BoxLayout(fileInfoPanel, BoxLayout.Y_AXIS)); JLabel fileInfoLabel = new JLabel(swingConfig.getLocalizer().localize("message.displayed-in-info-column")); fileInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.add(fileInfoLabel); fileInfoPanel.add(Box.createHorizontalGlue()); JRadioButton nothingRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.nothing")); nothingRadio.setAlignmentX(Component.LEFT_ALIGNMENT); nothingRadio.setActionCommand(SwingConfig.DefaultFileInfo.NOTHING.name()); nothingRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.NOTHING); fileInfoOptions.add(nothingRadio); fileInfoPanel.add(nothingRadio); JRadioButton readOnlyRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.read-only-warning")); readOnlyRadio.setAlignmentX(Component.LEFT_ALIGNMENT); readOnlyRadio.setActionCommand(SwingConfig.DefaultFileInfo.READONLY.name()); readOnlyRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.READONLY); fileInfoOptions.add(readOnlyRadio); fileInfoPanel.add(readOnlyRadio); JRadioButton sizeRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.filesize")); sizeRadio.setAlignmentX(Component.LEFT_ALIGNMENT); sizeRadio.setActionCommand(SwingConfig.DefaultFileInfo.SIZE.name()); sizeRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.SIZE); fileInfoOptions.add(sizeRadio); fileInfoPanel.add(sizeRadio); JCheckBox showPlainBytesFlag = new JCheckBox( " " + swingConfig.getLocalizer().localize("label.show-plain-bytes")); showPlainBytesFlag.setAlignmentX(Component.LEFT_ALIGNMENT); showPlainBytesFlag.setHorizontalTextPosition(SwingConstants.LEADING); showPlainBytesFlag.setSelected(swingConfig.isShowPlainBytes()); showPlainBytesFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { showBytes = ItemEvent.SELECTED == event.getStateChange(); } }); fileInfoPanel.add(showPlainBytesFlag); JRadioButton lastModifiedRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.last-modified")); lastModifiedRadio.setAlignmentX(Component.LEFT_ALIGNMENT); lastModifiedRadio.setActionCommand(SwingConfig.DefaultFileInfo.LAST_MODIFIED.name()); lastModifiedRadio .setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.LAST_MODIFIED); fileInfoOptions.add(lastModifiedRadio); fileInfoPanel.add(lastModifiedRadio); basePanel.add(fileInfoPanel); // buttons JPanel buttonPannel = new JPanel(); buttonPannel.setAlignmentX(Component.LEFT_ALIGNMENT); buttonPannel.setLayout(new FlowLayout(FlowLayout.TRAILING)); // cancel JButton cancelButton = new JButton(swingConfig.getLocalizer().localize("button.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { SettingsDialog.this.dispose(); } }); buttonPannel.add(cancelButton); // save JButton saveButton = new JButton(swingConfig.getLocalizer().localize("button.save")); saveButton.addActionListener(new SaveButtonListener()); buttonPannel.add(saveButton); this.getRootPane().setDefaultButton(saveButton); this.add(basePanel); this.add(buttonPannel); placeOnScreen(swingConfig.getScreenCenter()); }
From source file:au.org.ala.delta.editor.ui.image.ImageSettingsDialog.java
private void updateFromFont(Font font, JComboBox name, JComboBox size, JCheckBox bold, JCheckBox italic) { name.getModel().setSelectedItem(font.getFamily()); size.getModel().setSelectedItem(font.getSize()); bold.setSelected(font.isBold()); italic.setSelected(font.isItalic()); }
From source file:es.emergya.ui.gis.popups.SummaryDialog.java
public SummaryDialog(Recurso r) { super();//from ww w . j a v a2s . c o m r = (r == null) ? null : RecursoConsultas.getByIdentificador(r.getIdentificador()); setAlwaysOnTop(true); setResizable(false); setName(r.getIdentificador()); setBackground(Color.WHITE); setSize(600, 400); setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador()); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); base.setBackground(Color.WHITE); r = RecursoConsultas.getByIdentificador(r.getIdentificador()); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JLabel labelTitle = new JLabel(i18n.getString("Resources.summary.title") + " " + r.getIdentificador(), LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT); labelTitle.setFont(LogicConstants.deriveBoldFont(12f)); title.setBackground(Color.WHITE); title.add(labelTitle); base.add(title); // Nombre JPanel mid = new JPanel(new SpringLayout()); mid.setBackground(Color.WHITE); mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT)); JTextField name = new JTextField(25); if (r != null) name.setText(r.getIdentificador()); name.setEditable(false); mid.add(name); // Patrulla mid.add(new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT)); // JComboBox squads = new // JComboBox(PatrullaConsultas.getAll().toArray()); JTextField squads = new JTextField(r.getPatrullas() == null ? null : r.getPatrullas().getNombre()); // squads.setSelectedItem(r.getPatrullas()); squads.setEditable(false); squads.setColumns(21); // squads.setEnabled(false); mid.add(squads); // Tipo mid.add(new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT)); JTextField types = new JTextField(r.getTipo()); types.setEditable(false); mid.add(types); // Estado Eurocop mid.add(new JLabel(i18n.getString("Resources.status"), JLabel.RIGHT)); JTextField status = new JTextField(); if (r.getEstadoEurocop() != null) status.setText(r.getEstadoEurocop().getIdentificador()); status.setEditable(false); mid.add(status); // Subflota mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT)); JTextField subfleets = new JTextField(r.getFlotas() == null ? null : r.getFlotas().getNombre()); subfleets.setEditable(false); mid.add(subfleets); // Referencia Humana mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT)); JTextField rHumana = new JTextField(); // if (r.getIncidencias() != null) // rHumana.setText(r.getIncidencias().getReferenciaHumana()); rHumana.setEditable(false); mid.add(rHumana); // dispositivo mid.add(new JLabel(i18n.getString("Resources.device"), JLabel.RIGHT)); JTextField issi = new JTextField(); issi.setEditable(false); mid.add(issi); mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT)); JCheckBox enabled = new JCheckBox("", true); enabled.setEnabled(false); enabled.setOpaque(false); if (r.getDispositivo() != null) { final String valueOf = String.valueOf(r.getDispositivo()); try { issi.setText(String.format(FORMAT, r.getDispositivo())); } catch (Throwable t) { issi.setText(valueOf); } enabled.setSelected(r.getHabilitado()); } mid.add(enabled); // Fecha ultimo gps mid.add(new JLabel(i18n.getString("Resources.lastPosition"), JLabel.RIGHT)); JTextField lastGPS = new JTextField(); final Date lastGPSDateForRecurso = HistoricoGPSConsultas.lastGPSDateForRecurso(r); if (lastGPSDateForRecurso != null) { lastGPS.setText(SimpleDateFormat.getDateTimeInstance().format(lastGPSDateForRecurso)); } lastGPS.setEditable(false); mid.add(lastGPS); // Espacio en blanco mid.add(Box.createHorizontalGlue()); mid.add(Box.createHorizontalGlue()); // Espacio en blanco mid.add(Box.createHorizontalGlue()); mid.add(Box.createHorizontalGlue()); SpringUtilities.makeCompactGrid(mid, 5, 4, 6, 6, 6, 18); base.add(mid); // informacion adicional JPanel infoPanel = new JPanel(new SpringLayout()); JTextField info = new JTextField(25); info.setText(r.getInfoAdicional()); info.setEditable(false); infoPanel.setOpaque(false); infoPanel.add(new JLabel(i18n.getString("Resources.info"))); infoPanel.add(info); SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18); base.add(infoPanel); JPanel buttons = new JPanel(); buttons.setBackground(Color.WHITE); JButton accept = new JButton(i18n.getString("Buttons.ok"), LogicConstants.getIcon("button_accept")); accept.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); buttons.add(accept); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } }
From source file:EdgeLabelDemo.java
/** * create an instance of a simple graph with controls to * demo the label positioning features/*www.j av a2s . c o m*/ * */ @SuppressWarnings("serial") public EdgeLabelDemo() { // create a simple graph for the demo graph = new SparseMultigraph<Integer, Number>(); Integer[] v = createVertices(3); createEdges(v); Layout<Integer, Number> layout = new CircleLayout<Integer, Number>(graph); vv = new VisualizationViewer<Integer, Number>(layout, new Dimension(600, 400)); vv.setBackground(Color.white); vertexLabelRenderer = vv.getRenderContext().getVertexLabelRenderer(); edgeLabelRenderer = vv.getRenderContext().getEdgeLabelRenderer(); Transformer<Number, String> stringer = new Transformer<Number, String>() { public String transform(Number e) { return "Edge:" + graph.getEndpoints(e).toString(); } }; vv.getRenderContext().setEdgeLabelTransformer(stringer); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.red, Color.yellow)); // add my listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>()); // create a frome to hold the graph final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); Container content = getContentPane(); content.add(panel); final DefaultModalGraphMouse<Integer, Number> graphMouse = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(graphMouse); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); ButtonGroup radio = new ButtonGroup(); JRadioButton lineButton = new JRadioButton("Line"); lineButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<Integer, Number>()); vv.repaint(); } } }); JRadioButton quadButton = new JRadioButton("QuadCurve"); quadButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<Integer, Number>()); vv.repaint(); } } }); JRadioButton cubicButton = new JRadioButton("CubicCurve"); cubicButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<Integer, Number>()); vv.repaint(); } } }); radio.add(lineButton); radio.add(quadButton); radio.add(cubicButton); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); JCheckBox rotate = new JCheckBox("<html><center>EdgeType<p>Parallel</center></html>"); rotate.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { AbstractButton b = (AbstractButton) e.getSource(); edgeLabelRenderer.setRotateEdgeLabels(b.isSelected()); vv.repaint(); } }); rotate.setSelected(true); MutableDirectionalEdgeValue mv = new MutableDirectionalEdgeValue(.5, .7); vv.getRenderContext().setEdgeLabelClosenessTransformer(mv); JSlider directedSlider = new JSlider(mv.getDirectedModel()) { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width /= 2; return d; } }; JSlider undirectedSlider = new JSlider(mv.getUndirectedModel()) { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width /= 2; return d; } }; JSlider edgeOffsetSlider = new JSlider(0, 50) { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.width /= 2; return d; } }; edgeOffsetSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { JSlider s = (JSlider) e.getSource(); AbstractEdgeShapeTransformer<Integer, Number> aesf = (AbstractEdgeShapeTransformer<Integer, Number>) vv .getRenderContext().getEdgeShapeTransformer(); aesf.setControlOffsetIncrement(s.getValue()); vv.repaint(); } }); Box controls = Box.createHorizontalBox(); JPanel zoomPanel = new JPanel(new GridLayout(0, 1)); zoomPanel.setBorder(BorderFactory.createTitledBorder("Scale")); zoomPanel.add(plus); zoomPanel.add(minus); JPanel edgePanel = new JPanel(new GridLayout(0, 1)); edgePanel.setBorder(BorderFactory.createTitledBorder("EdgeType Type")); edgePanel.add(lineButton); edgePanel.add(quadButton); edgePanel.add(cubicButton); JPanel rotatePanel = new JPanel(); rotatePanel.setBorder(BorderFactory.createTitledBorder("Alignment")); rotatePanel.add(rotate); JPanel labelPanel = new JPanel(new BorderLayout()); JPanel sliderPanel = new JPanel(new GridLayout(3, 1)); JPanel sliderLabelPanel = new JPanel(new GridLayout(3, 1)); JPanel offsetPanel = new JPanel(new BorderLayout()); offsetPanel.setBorder(BorderFactory.createTitledBorder("Offset")); sliderPanel.add(directedSlider); sliderPanel.add(undirectedSlider); sliderPanel.add(edgeOffsetSlider); sliderLabelPanel.add(new JLabel("Directed", JLabel.RIGHT)); sliderLabelPanel.add(new JLabel("Undirected", JLabel.RIGHT)); sliderLabelPanel.add(new JLabel("Edges", JLabel.RIGHT)); offsetPanel.add(sliderLabelPanel, BorderLayout.WEST); offsetPanel.add(sliderPanel); labelPanel.add(offsetPanel); labelPanel.add(rotatePanel, BorderLayout.WEST); JPanel modePanel = new JPanel(new GridLayout(2, 1)); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(graphMouse.getModeComboBox()); controls.add(zoomPanel); controls.add(edgePanel); controls.add(labelPanel); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); quadButton.setSelected(true); }
From source file:net.sf.jclal.gui.view.components.chart.ExternalBasicChart.java
/** * * @return Create the menu that allows load the result from others * experiments.//w ww .java 2s . c o m */ private JMenu createMenu() { final JMenu fileMenu = new JMenu("Options"); final JFileChooser f = new JFileChooser(); f.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileMenu.add("Add report file or directory").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (curveOptions != null) { curveOptions.setVisible(false); curveOptions = null; } int action = f.showOpenDialog(fileMenu); if (action == JFileChooser.APPROVE_OPTION) { loadReportFile(f.getSelectedFile()); } } }); fileMenu.add("Area under learning curve (ALC)").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (comboBox.getItemCount() != 0) { if (!comboBox.getSelectedItem().toString().isEmpty()) { StringBuilder st = new StringBuilder(); st.append("Measure: ").append(comboBox.getSelectedItem()).append("\n\n"); for (int query = 0; query < queryNames.size(); query++) { double value = LearningCurveUtility.getArea(evaluationsCollection.get(query), comboBox.getSelectedItem().toString()); String valueString = String.format("%.3f", value); st.append(queryNames.get(query)).append(": ").append(valueString).append("\n"); } JOptionPane.showMessageDialog(content, st.toString(), "Area under the learning curve", JOptionPane.INFORMATION_MESSAGE); } } } }); fileMenu.add("Clear").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { queryNames = new ArrayList<String>(); evaluationsCollection = new ArrayList<List<AbstractEvaluation>>(); comboBox.removeAllItems(); controlCurveColor = new HashMap<String, Color>(); colors.clear(); data = null; set.clear(); curveOptions.setVisible(false); curveOptions = null; setSeries.clear(); passiveEvaluation = null; } }); fileMenu.add("Curve options").addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { data = informationTable(); if (queryNames.isEmpty()) { JOptionPane.showMessageDialog(null, "Please add curves"); return; } if (curveOptions == null) { curveOptions = new LearningCurvesVisualTable(ExternalBasicChart.this); } else { curveOptions.setVisible(true); } } }); final JCheckBox viewPoints = new JCheckBox("View points's shapes"); viewPoints.setSelected(false); viewPoints.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { viewPointsForm = viewPoints.isSelected(); jComboBoxItemStateChanged(); } }); fileMenu.add(viewPoints); final JCheckBox withOutColor = new JCheckBox("View without color"); withOutColor.setSelected(false); withOutColor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { viewWithOutColor = withOutColor.isSelected(); jComboBoxItemStateChanged(); } }); fileMenu.add(withOutColor); return fileMenu; }
From source file:frames.MainGUI.java
public void setJcheckBox(String name, Resident r, JCheckBox c) { if (r.hasFeeToPay(name)) { c.setSelected(true); } else {/*from w w w.j av a 2 s.c o m*/ c.setSelected(false); } }