Example usage for javax.swing JCheckBox isSelected

List of usage examples for javax.swing JCheckBox isSelected

Introduction

In this page you can find the example usage for javax.swing JCheckBox isSelected.

Prototype

public boolean isSelected() 

Source Link

Document

Returns the state of the button.

Usage

From source file:Simulator.java

private void init() {
    setSize(400, 400);// w  ww.  j a  v  a2 s.c o  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: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  . j av a2s  . 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);
}

From source file:de.mprengemann.intellij.plugin.androidicons.forms.AndroidBatchScaleImporter.java

private ImageInformation getImageInformation(ImageInformation baseInformation, Resolution resolution,
        float factor, JCheckBox checkbox) {
    if (!checkbox.isSelected()) {
        return null;
    }/*from   ww w.jav  a  2s . com*/

    ResizeAlgorithm algorithm = ResizeAlgorithm.from((String) algorithmSpinner.getSelectedItem());
    Object algorithmMethod = algorithm.getMethod((String) methodSpinner.getSelectedItem());

    return ImageInformation.newBuilder(baseInformation).setAlgorithm(algorithm).setMethod(algorithmMethod)
            .setResolution(resolution).setFactor(factor).build(project);
}

From source file:caarray.client.test.gui.GuiMain.java

public GuiMain() throws Exception {
    JFrame frame = new JFrame("API Test Suite");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.getContentPane().setLayout(new BorderLayout(6, 6));

    JPanel topPanel = new JPanel();

    /* ###### Text fields for modifiable parameters ##### */

    final JTextField javaHostText = new JTextField(TestProperties.getJavaServerHostname(), 20);
    JLabel javaHostLabel = new JLabel("Java Service Host");
    JButton save = new JButton("Save");
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            TestProperties.setJavaServerHostname(javaHostText.getText());
        }//from   w  w  w  . j av a2  s.  c om

    });

    JLabel javaPortLabel = new JLabel("Java Port");
    final JTextField javaPortText = new JTextField(Integer.toString(TestProperties.getJavaServerJndiPort()), 5);
    JButton save2 = new JButton("Save");
    save2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                int port = Integer.parseInt(javaPortText.getText());
                TestProperties.setJavaServerJndiPort(port);
            } catch (NumberFormatException e) {
                System.out.println(javaPortText.getText() + " is not a valid port number.");
            }
        }

    });

    JLabel gridHostLabel = new JLabel("Grid Service Host");
    final JTextField gridHostText = new JTextField(TestProperties.getGridServerHostname(), 20);
    JButton save3 = new JButton("Save");
    save3.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            TestProperties.setGridServerHostname(gridHostText.getText());
        }

    });

    JLabel gridPortLabel = new JLabel("Grid Service Port");
    final JTextField gridPortText = new JTextField(Integer.toString(TestProperties.getGridServerPort()), 5);
    JButton save4 = new JButton("Save");
    save4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            try {
                int port = Integer.parseInt(gridPortText.getText());
                TestProperties.setGridServerPort(port);
            } catch (NumberFormatException e) {
                System.out.println(gridPortText.getText() + " is not a valid port number.");
            }

        }

    });

    JLabel excludeLabel = new JLabel("Exclude test cases (comma-separated list):");
    final JTextField excludeText = new JTextField("", 30);
    JButton save5 = new JButton("Save");
    save5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            String testString = excludeText.getText();
            if (testString != null) {
                String[] testCases = testString.split(",");
                if (testCases != null && testCases.length > 0) {
                    List<Float> tests = new ArrayList<Float>();
                    for (String test : testCases) {
                        try {
                            tests.add(Float.parseFloat(test));
                        } catch (NumberFormatException e) {
                            System.out.println(test + " is not a valid test case.");
                        }
                    }
                    TestProperties.setExcludedTests(tests);
                }

            }

        }

    });

    JLabel includeLabel = new JLabel("Include only (comma-separated list):");
    final JTextField includeText = new JTextField("", 30);
    JButton save6 = new JButton("Save");
    save6.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            String testString = includeText.getText();
            if (testString != null) {
                String[] testCases = testString.split(",");
                if (testCases != null && testCases.length > 0) {
                    List<Float> tests = new ArrayList<Float>();
                    for (String test : testCases) {
                        try {
                            tests.add(Float.parseFloat(test));
                        } catch (NumberFormatException e) {
                            System.out.println(test + " is not a valid test case.");
                        }
                    }
                    TestProperties.setIncludeOnlyTests(tests);
                }

            }

        }

    });

    JLabel threadLabel = new JLabel("Number of threads:");
    final JTextField threadText = new JTextField(Integer.toString(TestProperties.getNumThreads()), 5);
    JButton save7 = new JButton("Save");
    save7.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            try {
                int threads = Integer.parseInt(threadText.getText());
                TestProperties.setNumThreads(threads);
            } catch (NumberFormatException e) {
                System.out.println(threadText.getText() + " is not a valid thread number.");
            }

        }

    });
    GridBagLayout topLayout = new GridBagLayout();
    topPanel.setLayout(topLayout);

    JLabel[] labels = new JLabel[] { javaHostLabel, javaPortLabel, gridHostLabel, gridPortLabel, excludeLabel,
            includeLabel, threadLabel };
    JTextField[] textFields = new JTextField[] { javaHostText, javaPortText, gridHostText, gridPortText,
            excludeText, includeText, threadText };
    JButton[] buttons = new JButton[] { save, save2, save3, save4, save5, save6, save7 };
    for (int i = 0; i < labels.length; i++) {
        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.NONE;
        c.gridx = 0;
        c.gridy = i;
        topPanel.add(labels[i], c);
        c.gridx = 1;
        topPanel.add(textFields[i], c);
        c.gridx = 2;
        topPanel.add(buttons[i], c);
    }

    frame.getContentPane().add(topPanel, BorderLayout.PAGE_START);

    GridLayout bottomLayout = new GridLayout(0, 4);
    selectionPanel.setLayout(bottomLayout);
    JCheckBox selectAll = new JCheckBox("Select/Deselect All");
    selectAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox box = (JCheckBox) e.getSource();
            selectAll(box.isSelected());
        }
    });
    selectionPanel.add(selectAll);
    JCheckBox excludeLongTests = new JCheckBox("Exclude Long Tests");
    excludeLongTests.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox box = (JCheckBox) e.getSource();
            if (box.isSelected()) {
                TestProperties.excludeLongTests();
            } else {
                TestProperties.removeExcludedLongTests();
            }
        }
    });
    TestProperties.excludeLongTests();
    excludeLongTests.setSelected(true);
    selectionPanel.add(excludeLongTests);

    //Initialize check boxes corresponding to test categories
    initializeTests();

    centerPanel.setLayout(new GridLayout(0, 1));
    centerPanel.add(selectionPanel);

    //Redirect System messages to gui     
    JScrollPane textScroll = new JScrollPane();
    textScroll.setViewportView(textDisplay);
    System.setOut(new PrintStream(new JTextAreaOutputStream(textDisplay)));
    System.setErr(new PrintStream(new JTextAreaOutputStream(textDisplay)));
    centerPanel.add(textScroll);
    JScrollPane scroll = new JScrollPane(centerPanel);

    frame.getContentPane().add(scroll, BorderLayout.CENTER);

    JButton runButton = new JButton("Run Tests");
    runButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            try {

                runTests();

            } catch (Exception e) {
                System.out.println("An error occured executing the tests: " + e.getClass()
                        + ". Check error log for details.");
                log.error("Exception encountered:", e);
            }
        }

    });

    JPanel bottomPanel = new JPanel();
    bottomPanel.add(runButton);
    frame.getContentPane().add(bottomPanel, BorderLayout.PAGE_END);

    frame.pack();
    frame.setVisible(true);
}

From source file:edu.uci.ics.jung.samples.PerspectiveVertexImageShaperDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the zoom features./*from w  w w.  j av  a2  s .c  o  m*/
 * 
 */
@SuppressWarnings("serial")
public PerspectiveVertexImageShaperDemo() {

    // create a simple graph for the demo
    graph = new DirectedSparseMultigraph<Number, Number>();
    Number[] vertices = createVertices(11);

    // a Map for the labels
    Map<Number, String> map = new HashMap<Number, String>();
    for (int i = 0; i < vertices.length; i++) {
        map.put(vertices[i], iconNames[i % iconNames.length]);
    }

    // a Map for the Icons
    Map<Number, Icon> iconMap = new HashMap<Number, Icon>();
    for (int i = 0; i < vertices.length; i++) {
        String name = "/images/topic" + iconNames[i] + ".gif";
        try {
            Icon icon = new LayeredIcon(
                    new ImageIcon(PerspectiveVertexImageShaperDemo.class.getResource(name)).getImage());
            iconMap.put(vertices[i], icon);
        } catch (Exception ex) {
            System.err.println("You need slashdoticons.jar in your classpath to see the image " + name);
        }
    }

    createEdges(vertices);

    final VertexStringerImpl<Number> vertexStringerImpl = new VertexStringerImpl<Number>(map);

    final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>(
            new EllipseVertexShapeTransformer<Number>());

    FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph);
    layout.setMaxIterations(100);
    vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400));

    vv.setBackground(Color.decode("0xffffdd"));
    final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>();
    vertexImageShapeFunction.setIconMap(iconMap);
    vertexIconFunction.setIconMap(iconMap);
    vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
    vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);
    vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl);
    PickedState<Number> ps = vv.getPickedVertexState();
    ps.addItemListener(new PickWithIconListener(vertexIconFunction));

    vv.addPostRenderPaintable(new VisualizationServer.Paintable() {
        int x;
        int y;
        Font font;
        FontMetrics metrics;
        int swidth;
        int sheight;
        String str = "Thank You, slashdot.org, for the images!";

        public void paint(Graphics g) {
            Dimension d = vv.getSize();
            if (font == null) {
                font = new Font(g.getFont().getName(), Font.BOLD, 20);
                metrics = g.getFontMetrics(font);
                swidth = metrics.stringWidth(str);
                sheight = metrics.getMaxAscent() + metrics.getMaxDescent();
                x = (d.width - swidth) / 2;
                y = (int) (d.height - sheight * 1.5);
            }
            g.setFont(font);
            Color oldColor = g.getColor();
            g.setColor(Color.lightGray);
            g.drawString(str, x, y);
            g.setColor(oldColor);
        }

        public boolean useTransform() {
            return false;
        }
    });

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<Number>());

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();

    vv.setGraphMouse(graphMouse);

    this.viewSupport = new PerspectiveImageLensSupport<Number, Number>(vv);
    this.layoutSupport = new PerspectiveLayoutTransformSupport<Number, Number>(vv);

    final ScalingControl scaler = new CrossoverScalingControl();

    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, 0.9f, vv.getCenter());
        }
    });
    final JSlider horizontalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(80, super.getPreferredSize().height);
        }
    };

    final JSlider verticalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width, 80);
        }
    };
    verticalSlider.setOrientation(JSlider.VERTICAL);
    final ChangeListener changeListener = new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            int vval = -verticalSlider.getValue();
            int hval = horizontalSlider.getValue();

            Dimension d = vv.getSize();
            PerspectiveTransform pt = null;
            pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval,
                    d.height + hval, -vval, d.height - hval,

                    0, 0, d.width, 0, d.width, d.height, 0, d.height);

            viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            vv.repaint();
        }
    };
    horizontalSlider.addChangeListener(changeListener);
    verticalSlider.addChangeListener(changeListener);

    JPanel perspectivePanel = new JPanel(new BorderLayout());
    JPanel perspectiveCenterPanel = new JPanel(new BorderLayout());
    perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls"));
    final JButton center = new JButton("Center");
    center.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            horizontalSlider.setValue(0);
            verticalSlider.setValue(0);
        }
    });

    final JCheckBox noText = new JCheckBox("No Text");
    noText.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            JCheckBox cb = (JCheckBox) e.getSource();
            vertexStringerImpl.setEnabled(!cb.isSelected());
            vv.repaint();
        }
    });
    JPanel centerPanel = new JPanel();
    centerPanel.add(noText);

    ButtonGroup radio = new ButtonGroup();
    JRadioButton none = new JRadioButton("None");
    none.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            boolean selected = e.getStateChange() == ItemEvent.SELECTED;
            if (selected) {
                if (viewSupport != null) {
                    viewSupport.deactivate();
                }
                if (layoutSupport != null) {
                    layoutSupport.deactivate();
                }
            }
            center.setEnabled(!selected);
            horizontalSlider.setEnabled(!selected);
            verticalSlider.setEnabled(!selected);
        }
    });
    none.setSelected(true);

    JRadioButton hyperView = new JRadioButton("View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JRadioButton hyperModel = new JRadioButton("Layout");
    hyperModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            layoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    radio.add(none);
    radio.add(hyperView);
    radio.add(hyperModel);

    JMenuBar menubar = new JMenuBar();
    JMenu modeMenu = graphMouse.getModeMenu();
    menubar.add(modeMenu);

    panel.setCorner(menubar);

    JPanel scaleGrid = new JPanel(new GridLayout(2, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel controls = new JPanel(new BorderLayout());
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid, BorderLayout.WEST);

    JPanel lensPanel = new JPanel(new GridLayout(2, 0));
    lensPanel.add(none);
    lensPanel.add(hyperView);
    lensPanel.add(hyperModel);

    perspectivePanel.add(lensPanel, BorderLayout.WEST);
    perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH);
    perspectivePanel.add(verticalSlider, BorderLayout.EAST);
    perspectiveCenterPanel.add(center);
    perspectivePanel.add(perspectiveCenterPanel);
    controls.add(perspectivePanel, BorderLayout.EAST);

    controls.add(centerPanel);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java

/**
 * @return/*  www.j av  a  2s  .c  o  m*/
 */
private Component createContentPanel() {
    JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
    scriptEditorTA = new RSyntaxTextArea();
    setSyntaxStyle();
    RTextScrollPane sp = new RTextScrollPane(scriptEditorTA);
    pane.setTopComponent(sp);

    JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    JPanel panel = new JPanel(new BorderLayout());
    output = new TextAreaOutputLogger(scrollPane, INITIAL_OUTPUT_CONTENT);
    output.setEditable(false);
    output.setAutoscrolls(true);
    output.setScrollContent(true);
    output.setWrapStyleWord(true);
    scrollPane.setViewportView(output);

    JToolBar toolBar = new JToolBar();
    JButton clearBT = new JButton("Clear");
    clearBT.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            output.setText(INITIAL_OUTPUT_CONTENT);
        }
    });

    final JCheckBox scrollCB = new JCheckBox("Auto Scroll Content");
    scrollCB.setSelected(true);
    scrollCB.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            output.setScrollContent(scrollCB.isSelected());
        }
    });
    toolBar.add(clearBT);
    toolBar.add(scrollCB);

    panel.add(toolBar, BorderLayout.NORTH);
    panel.add(scrollPane, BorderLayout.CENTER);

    pane.setBottomComponent(panel);
    pane.setDividerLocation(300);
    return pane;
}

From source file:com.diversityarrays.dal.server.ServerGui.java

public ServerGui(Image serverIconImage, IDalServer svr, DalServerFactory factory, File wwwRoot,
        DalServerPreferences prefs) {/*from ww  w  . ja v  a2 s. com*/

    this.serverIconImage = serverIconImage;
    this.dalServerFactory = factory;
    this.wwwRoot = wwwRoot;
    this.preferences = prefs;

    JMenuBar menuBar = new JMenuBar();

    JMenu serverMenu = new JMenu("Server");
    menuBar.add(serverMenu);
    serverMenu.add(serverStartAction);
    serverMenu.add(serverStopAction);
    serverMenu.add(exitAction);

    JMenu commandMenu = new JMenu("Command");
    menuBar.add(commandMenu);
    commandMenu.add(doSql);

    JMenu urlMenu = new JMenu("URL");
    menuBar.add(urlMenu);
    urlMenu.add(new JMenuItem(copyDalUrlAction));
    urlMenu.add(new JMenuItem(showDalUrlQRcodeAction));

    setJMenuBar(menuBar);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    messages.setFont(GuiUtil.createMonospacedFont(12));
    messages.setEditable(false);

    setServer(svr);

    quietOption.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            boolean q = quietOption.isSelected();
            if (server != null) {
                server.setQuiet(q);
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    final JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar();

    JButton clear = new JButton(new AbstractAction("Clear") {
        @Override
        public void actionPerformed(ActionEvent e) {
            messages.setText("");
        }
    });

    final boolean[] follow = new boolean[] { true };
    final JCheckBox followTail = new JCheckBox("Follow", follow[0]);

    followTail.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            follow[0] = followTail.isSelected();
        }
    });

    final OutputStream os = new OutputStream() {
        @Override
        public void write(int b) throws IOException {
            char ch = (char) b;
            messages.append(new Character(ch).toString());
            if (ch == '\n' && follow[0]) {
                verticalScrollBar.setValue(verticalScrollBar.getMaximum());
            }
        }
    };

    TeePrintStream pso = new TeePrintStream(System.out, os);
    TeePrintStream pse = new TeePrintStream(System.err, os);

    System.setErr(pse);
    System.setOut(pso);

    Box box = Box.createHorizontalBox();
    box.add(clear);
    box.add(followTail);
    box.add(quietOption);
    box.add(Box.createHorizontalGlue());

    JPanel bottom = new JPanel(new BorderLayout());
    bottom.add(BorderLayout.NORTH, box);
    bottom.add(BorderLayout.SOUTH, statusInfoLine);

    Container cp = getContentPane();
    cp.add(BorderLayout.CENTER, scrollPane);
    cp.add(BorderLayout.SOUTH, bottom);

    pack();
    setSize(640, 480);

    final MemoryUsageMonitor mum = new MemoryUsageMonitor();
    mum.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            statusInfoLine.setMessage(mum.getMemoryUsage());
        }
    });

    if (server == null) {
        // If initial server is null, allow user to specify
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowOpened(WindowEvent e) {
                removeWindowListener(this);
                serverStartAction.actionPerformed(null);
            }
        });
    } else {
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowOpened(WindowEvent e) {
                removeWindowListener(this);
                ensureDatabaseInitialisedThenStartServer();
            }
        });
    }
}

From source file:au.org.ala.delta.editor.ui.image.ImageSettingsDialog.java

private Font fontFromComponents(JComboBox name, JComboBox sizeCombo, JCheckBox bold, JCheckBox italic) {
    String family = (String) name.getSelectedItem();
    int size = (Integer) sizeCombo.getSelectedItem();
    int style = 0;
    if (bold.isSelected()) {
        style |= Font.BOLD;/*  w ww.j av  a  2s  . c o m*/
    }
    if (italic.isSelected()) {
        style |= Font.ITALIC;
    }
    Font font = new Font(family, style, size);

    return font;
}

From source file:net.aepik.alasca.gui.ldap.SchemaObjectEditorFrame.java

/**
 * Save values into the object./*from   w  w w . j  a  v  a2 s.  c  om*/
**/
private void saveValues() {
    Enumeration<String> k = values.keys();
    Enumeration<JComponent> l = labels.elements();
    Enumeration<JComponent> v = values.elements();
    Enumeration<JCheckBox> c = valuesPresent.elements();
    SchemaSyntax syntax = objetSchema.getSyntax();

    while (v.hasMoreElements() && k.hasMoreElements()) {
        String key = k.nextElement();
        JComponent label = l.nextElement();
        JComponent composant = v.nextElement();
        JCheckBox checkbox = c.nextElement();

        // If SUP key, we have to modify the parent of this object.
        // SUP element should be a JTextField.
        if (key.compareToIgnoreCase("SUP") == 0 && composant instanceof JComboBox) {
            SchemaObject parent = null;
            if (checkbox.isSelected()) {
                String parentName = ((JComboBox) composant).getSelectedItem().toString().trim();
                parent = parentName.length() > 0 ? schema.getObjectByName(parentName) : null;
            }
            objetSchema.setParent(parent);
        }

        // Si la checkbox n'est pas slectionne, il faut regarder si les
        // valeurs sont prsentes dans l'objet, auquel cas on les supprime.
        if (!checkbox.isSelected()) {
            if (label instanceof JComboBox) {
                objetSchema.delValue(((JComboBox) label).getSelectedItem().toString());
            } else {
                objetSchema.delValue(key);
            }
        }

        // Ajout => deux possiblits :
        // - la clef est simple = c'est un JLabel
        // - la clef est multiple = c'est un JComboBox.
        else {
            if (label instanceof JLabel) {
                if (composant instanceof JLabel) {
                    SchemaValue sv = syntax.createSchemaValue(objetSchema.getType(), key, "");
                    objetSchema.delValue(((JLabel) label).getText());
                    objetSchema.addValue(((JLabel) label).getText(), sv);
                } else if (composant instanceof JTextField) {
                    SchemaValue sv = syntax.createSchemaValue(objetSchema.getType(), key,
                            ((JTextField) composant).getText());
                    objetSchema.delValue(((JLabel) label).getText());
                    objetSchema.addValue(((JLabel) label).getText(), sv);
                } else if (composant instanceof JComboBox) {
                    SchemaValue sv = syntax.createSchemaValue(objetSchema.getType(), key,
                            ((JComboBox) composant).getSelectedItem().toString());
                    objetSchema.delValue(((JLabel) label).getText());
                    objetSchema.addValue(((JLabel) label).getText(), sv);
                }
            } else if (label instanceof JComboBox) {
                SchemaValue sv = syntax.createSchemaValue(objetSchema.getType(),
                        ((JComboBox) label).getSelectedItem().toString(), "");
                objetSchema.delValue(((JComboBox) label).getSelectedItem().toString());
                objetSchema.addValue(((JComboBox) label).getSelectedItem().toString(), sv);
            }
        }
    }
}

From source file:greenfoot.gui.export.ExportPublishPane.java

/**
 * Returns a list of the tags that the user chose for this scenario.
 *///from   ww  w  .  ja v  a2 s.c o  m
public List<String> getTags() {
    List<String> tagList = new LinkedList<String>();

    for (int i = 0; i < popTags.length; i++) {
        JCheckBox checkBox = popTags[i];
        if (checkBox.isSelected()) {
            tagList.add(checkBox.getText());
        }
    }

    String currentTags = tagArea.getText().trim();
    String[] tags = currentTags.split("\\s");
    for (int i = 0; i < tags.length; i++) {
        String tag = tags[i].trim();
        if (!tag.equals("")) {
            tagList.add(tag);
        }
    }

    if (includeSourceCode() && !tagList.contains(WITH_SOURCE_TAG)) {
        tagList.add(WITH_SOURCE_TAG);
    } else if (!includeSourceCode()) {
        tagList.remove(WITH_SOURCE_TAG);
    }
    return tagList;
}