List of usage examples for javax.swing JCheckBox setSelected
public void setSelected(boolean b)
From source file:com.adito.upgrade.GUIUpgrader.java
void addUpgradeSelectionComponent() { upgradeSelectionPanel.invalidate();/*from ww w . ja v a 2s. c om*/ upgradeSelectionPanel.removeAll(); for (Iterator i = upgrades.iterator(); i.hasNext();) { AbstractDatabaseUpgrade upgrade = (AbstractDatabaseUpgrade) i.next(); JCheckBox box = new JCheckBox(upgrade.getName()); box.setSelected(upgrade.isSelectedByDefault()); box.setToolTipText(upgrade.getDescription()); upgradeSelectionPanel.add(box); box.putClientProperty("upgrade", upgrade); } upgradeSelectionPanel.validate(); }
From source file:sim.util.media.chart.XYChartGenerator.java
protected void buildGlobalAttributes(LabelledList list) { // create the chart ((XYPlot) (chart.getPlot())).setDomainGridlinesVisible(false); ((XYPlot) (chart.getPlot())).setRangeGridlinesVisible(false); ((XYPlot) (chart.getPlot())).setDomainGridlinePaint(new Color(200, 200, 200)); ((XYPlot) (chart.getPlot())).setRangeGridlinePaint(new Color(200, 200, 200)); xLabel = new PropertyField() { public String newValue(String newValue) { setXAxisLabel(newValue);//w w w . j a v a2 s .c o m getChartPanel().repaint(); return newValue; } }; xLabel.setValue(getXAxisLabel()); list.add(new JLabel("X Label"), xLabel); yLabel = new PropertyField() { public String newValue(String newValue) { setYAxisLabel(newValue); getChartPanel().repaint(); return newValue; } }; yLabel.setValue(getYAxisLabel()); list.add(new JLabel("Y Label"), yLabel); xLog = new JCheckBox(); xLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (xLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(xLabel.getValue()); logAxis.setStrictValuesFlag(false); chart.getXYPlot().setDomainAxis(logAxis); } else chart.getXYPlot().setDomainAxis(new NumberAxis(xLabel.getValue())); } }); yLog = new JCheckBox(); yLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (yLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(yLabel.getValue()); logAxis.setStrictValuesFlag(false); chart.getXYPlot().setRangeAxis(logAxis); } else chart.getXYPlot().setRangeAxis(new NumberAxis(yLabel.getValue())); } }); Box box = Box.createHorizontalBox(); box.add(new JLabel("X")); box.add(xLog); box.add(new JLabel(" Y")); box.add(yLog); box.add(Box.createGlue()); list.add(new JLabel("Log Axis"), box); final JCheckBox xgridlines = new JCheckBox(); xgridlines.setSelected(false); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { chart.getXYPlot().setDomainGridlinesVisible(true); } else { chart.getXYPlot().setDomainGridlinesVisible(false); } } }; xgridlines.addItemListener(il); final JCheckBox ygridlines = new JCheckBox(); ygridlines.setSelected(false); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { chart.getXYPlot().setRangeGridlinesVisible(true); } else { chart.getXYPlot().setRangeGridlinesVisible(false); } } }; ygridlines.addItemListener(il); box = Box.createHorizontalBox(); box.add(new JLabel("X")); box.add(xgridlines); box.add(new JLabel(" Y")); box.add(ygridlines); box.add(Box.createGlue()); list.add(new JLabel("Grid Lines"), box); }
From source file:lu.lippmann.cdb.datasetview.tabs.ScatterPlotTabView.java
private void update0(final Instances dataSet, int xidx, int yidx, int coloridx, final boolean asSerie) { System.out.println(xidx + " " + yidx); this.panel.removeAll(); if (xidx == -1) xidx = 0;//from w ww .j a v a 2 s .com if (yidx == -1) yidx = 1; if (coloridx == -1) coloridx = 0; final Object[] numericAttrNames = WekaDataStatsUtil.getNumericAttributesNames(dataSet).toArray(); final JComboBox xCombo = new JComboBox(numericAttrNames); xCombo.setBorder(new TitledBorder("x")); xCombo.setSelectedIndex(xidx); final JComboBox yCombo = new JComboBox(numericAttrNames); yCombo.setBorder(new TitledBorder("y")); yCombo.setSelectedIndex(yidx); final JCheckBox jcb = new JCheckBox("Draw lines"); jcb.setSelected(asSerie); final JComboBox colorCombo = new JComboBox(numericAttrNames); colorCombo.setBorder(new TitledBorder("color")); colorCombo.setSelectedIndex(coloridx); colorCombo.setVisible(dataSet.classIndex() < 0); xCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { update0(dataSet, xCombo.getSelectedIndex(), yCombo.getSelectedIndex(), colorCombo.getSelectedIndex(), jcb.isSelected()); } }); yCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { update0(dataSet, xCombo.getSelectedIndex(), yCombo.getSelectedIndex(), colorCombo.getSelectedIndex(), jcb.isSelected()); } }); colorCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { update0(dataSet, xCombo.getSelectedIndex(), yCombo.getSelectedIndex(), colorCombo.getSelectedIndex(), jcb.isSelected()); } }); jcb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { update0(dataSet, xCombo.getSelectedIndex(), yCombo.getSelectedIndex(), colorCombo.getSelectedIndex(), jcb.isSelected()); } }); final JXPanel comboPanel = new JXPanel(); comboPanel.setLayout(new GridLayout(1, 0)); comboPanel.add(xCombo); comboPanel.add(yCombo); comboPanel.add(colorCombo); comboPanel.add(jcb); this.panel.add(comboPanel, BorderLayout.NORTH); final java.util.List<Integer> numericAttrIdx = WekaDataStatsUtil.getNumericAttributesIndexes(dataSet); final ChartPanel scatterplotChartPanel = buildChartPanel(dataSet, numericAttrIdx.get(xidx), numericAttrIdx.get(yidx), numericAttrIdx.get(coloridx), asSerie); this.panel.add(scatterplotChartPanel, BorderLayout.CENTER); this.panel.repaint(); this.panel.updateUI(); }
From source file:es.emergya.ui.gis.popups.ListaCapas.java
private void addCapa(final GpxLayer layer) { final JPanel capaP = new JPanel(); capaP.setOpaque(false);// w w w .j a va 2 s .c o m layer.visible = true; mapView.addLayer(layer, false, capasActuales.size()); capasActuales.add(layer); capaP.setLayout(new BoxLayout(capaP, BoxLayout.X_AXIS)); final JCheckBox capa = new JCheckBox(layer.getAssociatedFile().getAbsolutePath()); capa.setSelected(layer.visible); capa.setBackground(Color.WHITE); capa.setToolTipText(i18n.getString("window.gpx.checkbox.show.tooltip")); capa.setActionCommand(layer.name); capa.addActionListener(this); capaP.add(capa); capaP.add(Box.createHorizontalGlue()); JButton eliminar = new JButton(LogicConstants.getIcon("button_delone")); eliminar.setToolTipText(i18n.getString("window.gpx.button.delete.tooltip")); eliminar.setBorderPainted(false); eliminar.setContentAreaFilled(false); capaP.add(eliminar); eliminar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mapView.removeLayer(layer); mapView.repaint(); capasGpx.remove(capaP); capasGpx.updateUI(); capasActuales.remove(layer); } }); capasGpx.add(capaP); capasGpx.updateUI(); }
From source file:edu.gmu.cs.sim.util.media.chart.BarChartGenerator.java
protected void buildGlobalAttributes(LabelledList list) { // create the chart CategoryPlot plot = (CategoryPlot) (chart.getPlot()); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinePaint(new Color(200, 200, 200)); plot.setRangeGridlinePaint(new Color(200, 200, 200)); // define the renderers barRenderer = new BarRenderer(); reviseRenderer(barRenderer);//from w w w . j a v a 2 s . co m stackedBarRenderer = new StackedBarRenderer(false); reviseRenderer(stackedBarRenderer); percentageRenderer = new StackedBarRenderer(true); reviseRenderer(percentageRenderer); plot.setRenderer(barRenderer); xLabel = new PropertyField() { public String newValue(String newValue) { setXAxisLabel(newValue); getChartPanel().repaint(); return newValue; } }; xLabel.setValue(getXAxisLabel()); list.add(new JLabel("X Label"), xLabel); yLabel = new PropertyField() { public String newValue(String newValue) { setYAxisLabel(newValue); getChartPanel().repaint(); return newValue; } }; yLabel.setValue(getYAxisLabel()); list.add(new JLabel("Y Label"), yLabel); final JCheckBox gridlines = new JCheckBox(); gridlines.setSelected(false); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { hasgridlines = (e.getStateChange() == ItemEvent.SELECTED); updateGridLines(); } }; gridlines.addItemListener(il); list.add(new JLabel("Grid Lines"), gridlines); final JCheckBox labels = new JCheckBox(); labels.setSelected(true); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { getBarRenderer().setBaseItemLabelsVisible(true); getStackedBarRenderer().setBaseItemLabelsVisible(true); getPercentageRenderer().setBaseItemLabelsVisible(true); } else { getBarRenderer().setBaseItemLabelsVisible(false); getStackedBarRenderer().setBaseItemLabelsVisible(false); getPercentageRenderer().setBaseItemLabelsVisible(false); } } }; labels.addItemListener(il); list.add(new JLabel("Labels"), labels); final JComboBox barType = new JComboBox(); barType.setEditable(false); barType.setModel(new DefaultComboBoxModel( new java.util.Vector(Arrays.asList(new String[] { "Separate", "Stacked", "Percentage" })))); barType.setSelectedIndex(0); barType.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CategoryPlot plot = (CategoryPlot) (chart.getPlot()); int type = barType.getSelectedIndex(); if (type == 0) // separate { plot.setRenderer(getBarRenderer()); } else if (type == 1) // stacked { plot.setRenderer(getStackedBarRenderer()); } else // percentage { plot.setRenderer(getPercentageRenderer()); } } }); list.add(new JLabel("Bars"), barType); final JCheckBox horizontal = new JCheckBox(); horizontal.setSelected(false); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { CategoryPlot plot = (CategoryPlot) (chart.getPlot()); if (e.getStateChange() == ItemEvent.SELECTED) { plot.setOrientation(PlotOrientation.HORIZONTAL); ishorizontal = true; } else { plot.setOrientation(PlotOrientation.VERTICAL); ishorizontal = false; } updateGridLines(); } }; horizontal.addItemListener(il); list.add(new JLabel("Horizontal"), horizontal); }
From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java
void setSelectedDependenciesString(String deps) { HashSet<String> hs = new HashSet<>(Arrays.asList(deps.split(","))); for (List<JCheckBox> chList : chkBoxesMap.values()) { for (JCheckBox cb : chList) { cb.setSelected(hs.contains(cb.getName())); }//from w ww . j av a 2 s . co m } }
From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java
void setSelectedDependencies(List<String> deps) { HashSet<String> hs = new HashSet<>(deps); for (List<JCheckBox> chList : chkBoxesMap.values()) { for (JCheckBox cb : chList) { cb.setSelected(hs.contains(cb.getName())); }//from w ww .j av a2 s . co m } }
From source file:Simulator.java
private void init() { setSize(400, 400);/*from w w w . jav a2s . co m*/ treeMap = new JMapViewerTree("Zones"); // Listen to the map viewer for user operations so components will // receive events and update map().addJMVListener(this); setLayout(new BorderLayout()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setExtendedState(JFrame.MAXIMIZED_BOTH); JPanel panel = new JPanel(new BorderLayout()); JPanel panelTop = new JPanel(); JPanel panelBottom = new JPanel(); JPanel helpPanel = new JPanel(); mperpLabelName = new JLabel("Meters/Pixels: "); mperpLabelValue = new JLabel(String.format("%s", map().getMeterPerPixel())); zoomLabel = new JLabel("Zoom: "); zoomValue = new JLabel(String.format("%s", map().getZoom())); add(panel, BorderLayout.NORTH); add(helpPanel, BorderLayout.SOUTH); panel.add(panelTop, BorderLayout.NORTH); panel.add(panelBottom, BorderLayout.SOUTH); JLabel helpLabel = new JLabel( "Use right mouse button to move,\n " + "left double click or mouse wheel to zoom."); helpPanel.add(helpLabel); JButton button = new JButton("Fit GPS Markers"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { map().setDisplayToFitMapMarkers(); } }); panelBottom.add(button); JButton openButton = new JButton("Open GPS File"); openButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser openFileDlg = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXT FILES", "txt", "text"); openFileDlg.setFileFilter(filter); if (openFileDlg.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { File file = openFileDlg.getSelectedFile(); //This is where a real application would open the file. System.out.println("Opening: " + file.getAbsolutePath() + "."); plotPoints(file.getAbsolutePath()); } else { System.out.println("Open command cancelled by user."); } } }); panelBottom.add(openButton); final JCheckBox showMapMarker = new JCheckBox("Map markers visible"); showMapMarker.setSelected(map().getMapMarkersVisible()); showMapMarker.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { map().setMapMarkerVisible(showMapMarker.isSelected()); } }); panelBottom.add(showMapMarker); panelTop.add(zoomLabel); panelTop.add(zoomValue); panelTop.add(mperpLabelName); panelTop.add(mperpLabelValue); add(treeMap, BorderLayout.CENTER); }
From source file:mrmc.chart.ROCCurvePlot.java
/** * Sole constructor. Creates a line plot display ROC curves * /*from w w w . j a va2s . co m*/ * @param title Title of the chart * @param xaxis x-axis label * @param yaxis y-axis label * @param treeMap Mapping of readers to a set of points defining an ROC curve */ public ROCCurvePlot(final String title, String xaxis, String yaxis, TreeMap<String, TreeSet<XYPair>> treeMap) { super(title); createDataset(treeMap); final JFreeChart chart = ChartFactory.createScatterPlot(title, xaxis, yaxis, seriesCollection, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); NumberAxis domain = (NumberAxis) xyplot.getDomainAxis(); domain.setRange(0.00, 1.00); domain.setTickUnit(new NumberTickUnit(0.1)); NumberAxis range = (NumberAxis) xyplot.getRangeAxis(); range.setRange(0.00, 1.00); range.setTickUnit(new NumberTickUnit(0.1)); renderer = new XYLineAndShapeRenderer(); chart.getXYPlot().setRenderer(renderer); ChartPanel chartPanel = new ChartPanel(chart); JPanel readerSelect = new JPanel(new WrapLayout()); readerSeriesBoxes = new ArrayList<JCheckBox>(); for (String r : treeMap.keySet()) { JCheckBox aBox = new JCheckBox("" + r); aBox.setSelected(false); aBox.addItemListener(new SeriesSelectListener()); hideSeries("" + r); readerSeriesBoxes.add(aBox); readerSelect.add(aBox); } renderer.setSeriesShapesVisible(seriesCollection.getSeriesIndex("Vertical Average"), false); renderer.setSeriesStroke(seriesCollection.getSeriesIndex("Vertical Average"), new java.awt.BasicStroke(3f)); renderer.setSeriesShapesVisible(seriesCollection.getSeriesIndex("Horizontal Average"), false); renderer.setSeriesStroke(seriesCollection.getSeriesIndex("Horizontal Average"), new java.awt.BasicStroke(3f)); renderer.setSeriesShapesVisible(seriesCollection.getSeriesIndex("Diagonal Average"), false); renderer.setSeriesStroke(seriesCollection.getSeriesIndex("Diagonal Average"), new java.awt.BasicStroke(3f)); renderer.setSeriesStroke(seriesCollection.getSeriesIndex("Pooled Average"), new java.awt.BasicStroke(3f)); vert = new JCheckBox("Vertical Average"); vert.setSelected(true); vert.addItemListener(new SeriesSelectListener()); readerSelect.add(vert); horiz = new JCheckBox("Horizontal Average"); horiz.setSelected(true); horiz.addItemListener(new SeriesSelectListener()); readerSelect.add(horiz); diag = new JCheckBox("Diagonal Average"); diag.setSelected(true); diag.addItemListener(new SeriesSelectListener()); readerSelect.add(diag); pooled = new JCheckBox("Pooled Average"); pooled.setSelected(true); pooled.addItemListener(new SeriesSelectListener()); readerSelect.add(pooled); JCheckBox allReaders = new JCheckBox("Show Readers"); allReaders.setSelected(false); allReaders.addItemListener(new ReadersSelectListener()); readerSelect.add(allReaders); JCheckBox allAverages = new JCheckBox("Show Averages"); allAverages.setSelected(true); allAverages.addItemListener(new AverageSelectListener()); readerSelect.add(allAverages); chartPanel.setPreferredSize(new java.awt.Dimension(700, 700)); this.add(chartPanel); this.add(readerSelect, BorderLayout.PAGE_END); }
From source file:com.jbombardier.console.charts.XYTimeChartPanel.java
public XYTimeChartPanel() { DateAxis numberaxis = new DateAxis("Time"); yAxis = new NumberAxis("Count"); yAxis.setAutoRangeIncludesZero(true); XYSplineRenderer renderer = new XYSplineRenderer(); // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); xyplot = new XYPlot(xyseriescollection, numberaxis, yAxis, renderer); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.lightGray); // xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); // XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) // xyplot.getRenderer(); // xylineandshaperenderer.setBaseShapesVisible(false); // xylineandshaperenderer.setBaseShapesFilled(false); chart = new JFreeChart("Running threads", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); /*/*from w ww . ja va2s .c om*/ * ValueMarker valuemarker1 = new ValueMarker(175D); * valuemarker1.setLabelOffsetType(LengthAdjustmentType.EXPAND); * valuemarker1.setPaint(Color.red); valuemarker1.setLabel("Target Price"); * valuemarker1.setLabelAnchor(RectangleAnchor.TOP_RIGHT); * valuemarker1.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); * xyplot.addRangeMarker(valuemarker1); */ LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); // ChartUtilities.applyCurrentTheme(chart); setLayout(new BorderLayout()); jFreeChartPanel = new ChartPanel(chart); jFreeChartPanel.setMinimumDrawHeight(0); jFreeChartPanel.setMinimumDrawWidth(0); jFreeChartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); jFreeChartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); add(jFreeChartPanel, BorderLayout.CENTER); JPanel controls = new JPanel(new MigLayout("gap 0, ins 0", "[grow,center,fill]", "[grow,center]")); final JCheckBox checkbox = new JCheckBox("Auto-scale"); checkbox.setSelected(true); checkbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleAutoscroll(checkbox.isSelected()); } }); checkbox.setHorizontalAlignment(SwingConstants.RIGHT); controls.add(checkbox, "cell 0 0,alignx center"); add(controls, BorderLayout.SOUTH); }