Example usage for javax.swing JCheckBox setSelected

List of usage examples for javax.swing JCheckBox setSelected

Introduction

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

Prototype

public void setSelected(boolean b) 

Source Link

Document

Sets the state of the button.

Usage

From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java

private void handleFirstStart() {

    if (!ServiceFunctions.getPropertiesFile().exists()) {
        JOptionPane.showMessageDialog(mainFrame, "Willkommen bei " + APP_NAME, "Willkommen",
                JOptionPane.INFORMATION_MESSAGE);

        JPanel panel = new JPanel(new BorderLayout());
        panel.add(new JLabel("<html>Wenn Sie " + APP_NAME
                + " nutzen mchten, mssen Sie die folgende Punkte akzeptieren." + "<ul>"
                + "<li>This software is under the GNU GENERAL PUBLIC LICENSE Version 3.<br>"
                + "View https://github.com/kekru/ILIASDownloader2/blob/master/LICENSE for detailed information."
                + "</li>" + "<li>Dieses Programm wird Ihr Passwort nicht speichern</li>"
                + "<li>Dieses Programm wird Ihren Loginnamen und Ihr Passwort nur an den von Ihnen angegebenen Server senden</li>"
                + "<li>Ihr Passwort wird im Arbeitsspeicher dieses Computers <b>nicht</b> verschlsselt gespeichert.<br>Ein Schadprogramm knnte den Arbeitsspeicher auslesen und so an Ihre Logindaten gelangen.<br>Der Autor von "
                + APP_NAME + " bernimmt keine Verantwortung fr die Sicherheit Ihrer Logindaten</li>"
                + "<li>Im nchsten Schritt mssen Sie Ihren Ilias Server eingeben. Bitte achten Sie darauf, dass die Adresse mit 'https://' beginnt.<br>Das bewirkt eine gesicherte Verbindung zwischen "
                + APP_NAME + " und Ihrem Ilias Server</li>" + "<li>Die Nutzung und die Weitergabe von "
                + APP_NAME + " ist kostenlos.</li>"
                + "<li>Beim Programmstart wird auf Updates berprft. Dabei wird lediglich der Programmname an den Updateserver gesendet. Ihre Logindaten oder andere persnliche Daten werden nicht bertragen.<br>Wenn Sie die Updatefunktion ausschalten mchten, starten Sie das Programm mit dem Parameter '"
                + StartGui.NO_UPDATER + "'</li>" + "</ul>" + "</html>"), BorderLayout.NORTH);
        JButton licenseButton = new JButton("Open GNU GENERAL PUBLIC LICENSE Version 3");
        licenseButton.addActionListener(new ActionListener() {

            @Override/*ww  w .  ja  v  a 2s.  c o  m*/
            public void actionPerformed(ActionEvent e) {
                openWebsiteLicense();

            }
        });
        panel.add(licenseButton, BorderLayout.CENTER);

        JCheckBox checkboxAccept = new JCheckBox(
                "Ich akzeptiere die hier aufgefhrten Bedingungen/I accept these agreements.");
        checkboxAccept.setSelected(false);
        panel.add(checkboxAccept, BorderLayout.SOUTH);

        if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Bedingungen",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE) && checkboxAccept.isSelected()) {
            chooseServer();
        } else {
            System.exit(0);
        }

    }
}

From source file:sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();// w  w w .  j  a  va  2s.c  o m
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null)
                startMovie();
            else
                stopMovie();
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            if (newValue > MAXIMUM_SCALE)
                newValue = currentValue;
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java

protected void showAutoSyncSettings() {
    JCheckBox checkboxAutoSyncActive;
    JTextField fieldSyncInterval;
    JPanel panel = new JPanel(new BorderLayout());
    {//  w w w  . ja  va  2  s .  c o m
        checkboxAutoSyncActive = new JCheckBox("Automatische Synchronisierung aktiv");
        checkboxAutoSyncActive.setSelected(iliasProperties.isAutoSyncActive());
        panel.add(checkboxAutoSyncActive, BorderLayout.NORTH);
    }
    {
        JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
        panel2.add(new JLabel("Intervall in Minuten:"));
        fieldSyncInterval = new JTextField(String.valueOf(iliasProperties.getAutoSyncIntervalInSeconds() / 60),
                20);
        panel2.add(fieldSyncInterval);
        panel.add(panel2, BorderLayout.CENTER);
    }
    {
        panel.add(new JLabel(
                "<html>Sie knnen das Programm auch ohne GUI laufen lassen.<br>Weitere Informationen hierzu erhalten Sie, wenn Sie das Programm folgendermaen starten<br>java -jar &lt;name&gt;.jar help</html>"),
                BorderLayout.SOUTH);
    }

    if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel,
            "Automatische Synchronisierung einstellen", JOptionPane.OK_CANCEL_OPTION)) {
        iliasProperties.setAutoSyncActive(checkboxAutoSyncActive.isSelected());
        iliasProperties.setAutoSyncIntervalInSeconds(Integer.parseInt(fieldSyncInterval.getText()) * 60);
        saveProperties(iliasProperties);

        startOrStopAutoSync();
    }

}

From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();//from w w  w  .  j a  v a  2 s.  c om
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null) {
                startMovie();
            } else {
                stopMovie();
            }
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            if (newValue > MAXIMUM_SCALE) {
                newValue = currentValue;
            }
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:gtu._work.ui.DirectoryCompareUI.java

private void initComponents() {
    DefaultTableModel dirCompareModel = getDefaultTableModel();
    DefaultComboBoxModel extensionModel = new DefaultComboBoxModel();
    extensionModel.addElement(EXTENSION_ALL);

    while (extensionNameComboBox.getModel().getSize() != extensionModel.getSize()) {
        extensionNameComboBox.setModel(extensionModel);
        System.out.println("reset extensionNameComboBox");
    }// w  ww . java 2  s .co  m
    while (dirCompareTable.getModel().getRowCount() != dirCompareModel.getRowCount()) {
        dirCompareTable.setModel(dirCompareModel);
        System.out.println("reset dirCompareTable");
    }

    searchText.setText("");
    setTitle("");
    compareStyleComboBox.setSelectedItem(EXTENSION_ALL);
    if (diffMergeChkBox != null) {
        for (JCheckBox chk : diffMergeChkBox) {
            chk.setSelected(true);
        }
    }
}

From source file:gtu._work.ui.DirectoryCompareUI.java

private void addDiffMergeChkBox() {
    diffMergeChkBox = new JCheckBox[DiffMergeStatus.values().length];
    int ii = 0;/*from  w  ww .  j a v a  2  s .  com*/
    for (DiffMergeStatus dif : DiffMergeStatus.values()) {
        diffMergeChkBox[ii] = new JCheckBox();
        JCheckBox tempChk = diffMergeChkBox[ii];
        ii++;

        tempChk.setText(dif.toString());
        tempChk.setSelected(true);
        jPanel3.add(tempChk);
        tempChk.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                totalScanFiles(null);
            }
        });
    }
}

From source file:EnvironmentExplorer.java

Box lightPanel() {
    Box panel = new Box(BoxLayout.Y_AXIS);

    // add the ambient light checkbox to the panel
    JCheckBox ambientCheckBox = new JCheckBox("Ambient Light");
    ambientCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox checkbox = (JCheckBox) e.getSource();
            lightAmbient.setEnable(checkbox.isSelected());
        }// www .  j a  v  a  2 s  .  c  o  m
    });
    ambientCheckBox.setSelected(true);
    panel.add(new LeftAlignComponent(ambientCheckBox));

    String[] lightTypeValues = { "None", "Directional", "Positional", "Spot" };
    IntChooser lightTypeChooser = new IntChooser("Light Type:", lightTypeValues);
    lightTypeChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            int value = event.getValue();
            switch (value) {
            case 0:
                lightDirectional.setEnable(false);
                lightPoint.setEnable(false);
                lightSpot.setEnable(false);
                break;
            case 1:
                lightDirectional.setEnable(true);
                lightPoint.setEnable(false);
                lightSpot.setEnable(false);
                break;
            case 2:
                lightDirectional.setEnable(false);
                lightPoint.setEnable(true);
                lightSpot.setEnable(false);
                break;
            case 3:
                lightDirectional.setEnable(false);
                lightPoint.setEnable(false);
                lightSpot.setEnable(true);
                break;
            }
        }
    });
    lightTypeChooser.setValueByName("Directional");
    panel.add(lightTypeChooser);

    // Set up the sliders for the attenuation

    // top row
    panel.add(new LeftAlignComponent(new JLabel("Light attenuation:")));

    FloatLabelJSlider constantSlider = new FloatLabelJSlider("Constant ", 0.1f, 0.0f, 3.0f, attenuation.x);
    constantSlider.setMajorTickSpacing(1.0f);
    constantSlider.setPaintTicks(true);
    constantSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            attenuation.x = e.getValue();
            lightPoint.setAttenuation(attenuation);
            lightSpot.setAttenuation(attenuation);
        }
    });
    panel.add(constantSlider);

    FloatLabelJSlider linearSlider = new FloatLabelJSlider("Linear   ", 0.1f, 0.0f, 3.0f, attenuation.y);
    linearSlider.setMajorTickSpacing(1.0f);
    linearSlider.setPaintTicks(true);
    linearSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            attenuation.y = e.getValue();
            lightPoint.setAttenuation(attenuation);
            lightSpot.setAttenuation(attenuation);
        }
    });
    panel.add(linearSlider);

    FloatLabelJSlider quadradicSlider = new FloatLabelJSlider("Quadradic", 0.1f, 0.0f, 3.0f, attenuation.z);
    quadradicSlider.setMajorTickSpacing(1.0f);
    quadradicSlider.setPaintTicks(true);
    quadradicSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            attenuation.z = e.getValue();
            lightPoint.setAttenuation(attenuation);
            lightSpot.setAttenuation(attenuation);
        }
    });
    panel.add(quadradicSlider);

    // Set up the sliders for the attenuation
    // top row
    panel.add(new LeftAlignComponent(new JLabel("Spot light:")));

    // spread angle is 0-180 degrees, no slider scaling
    FloatLabelJSlider spotSpreadSlider = new FloatLabelJSlider("Spread Angle ", 1.0f, 0.0f, 180.0f,
            spotSpreadAngle);
    spotSpreadSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            spotSpreadAngle = e.getValue();
            lightSpot.setSpreadAngle((float) Math.toRadians(spotSpreadAngle));
        }
    });
    panel.add(spotSpreadSlider);

    // concentration angle is 0-128 degrees
    FloatLabelJSlider spotConcentrationSlider = new FloatLabelJSlider("Concentration", 1.0f, 0.0f, 128.0f,
            spotConcentration);
    spotConcentrationSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            spotConcentration = e.getValue();
            lightSpot.setConcentration(spotConcentration);
        }
    });
    panel.add(spotConcentrationSlider);

    return panel;
}

From source file:HW3.java

private void finalAttributeDisplay(String subCatName) {
    for (HashMap hmap : AttrList) {
        if (hmap != null) {
            Iterator iter = hmap.keySet().iterator();
            boolean flag;
            while (iter.hasNext()) {
                JCheckBox jcheck = (JCheckBox) iter.next();
                String attr = jcheck.getText();
                flag = checkAlredyExists(attr, attrNames);
                if (hmap.get(jcheck) == subCatName && flag == false) {
                    attrNames.add(attr);
                    jcheck.setSelected(false);
                    attrPanel.add(jcheck);
                    jcheck.addItemListener(new ItemListener() {

                        @Override
                        public void itemStateChanged(ItemEvent e) {
                            String str = jcheck.getText();
                            if (jcheck.isSelected()) {
                                if (!checkAlredyExists(str, selectedAttrList)) {
                                    selectedAttrList.add(str);
                                }/*from   www .j a  va 2 s  .  c o  m*/
                            } else {
                                clearBusinessTable();
                                selectedAttrList.remove(str);
                            }
                        }
                    });
                }
            }
        }
    }
    attrPanel.setLayout(new GridLayout(0, 1));
    attrPanel.revalidate();
    attrPanel.repaint();
    pack();
    attrPanel.setVisible(true);
    if (attrListCount == MAX_ATTR_LIST_COUNT - 1) {
        attrListCount = 0;
    } else {
        attrListCount++;
    }
}

From source file:HW3.java

private void finalDisplaySubCategory(String catName) {
    for (HashMap map : mapList) {
        if (map != null) {
            Iterator it = map.keySet().iterator();
            while (it.hasNext()) {
                JCheckBox jcheck = (JCheckBox) it.next();
                String s = jcheck.getText();
                boolean flag = checkAlredyExists(s, subCatNames);
                if (map.get(jcheck).equals(catName) && flag == false) {
                    subCatNames.add(s);//w w w.jav a2s  .co  m
                    jcheck.setSelected(false);
                    subCategoryPanel.add(jcheck);
                    jcheck.addItemListener(new ItemListener() {
                        @Override
                        public void itemStateChanged(ItemEvent e) {
                            String subCatName = null;
                            HashMap<JCheckBox, String> returnList = new HashMap<JCheckBox, String>();
                            if (jcheck.isSelected()) {
                                subCatName = jcheck.getText();
                                //System.out.println(subCatName);
                                selectSubCat.add(subCatName);
                                displayAttr(subCatName, returnList);
                                AttrList[attrListCount] = returnList;
                                finalAttributeDisplay(subCatName);
                            } else {
                                subCatName = jcheck.getText();
                                selectSubCat.remove(subCatName);
                                clearBusinessTable();
                                finalAttributeRemove(subCatName);
                            }
                        }
                    });
                }
            }
        }
    }
    subCategoryPanel.setLayout(new GridLayout(0, 1));
    subCategoryPanel.revalidate();
    subCategoryPanel.repaint();
    pack();
    subCategoryPanel.setVisible(true);
    if (mapListCount == MAX_MAP_LIST_COUNT - 1) {
        mapListCount = 0;
    } else {
        mapListCount++;
    }
}

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

/**
 * Initialize graphical components with values.
 *///from   ww w . ja v  a 2s . c om
private void init() {
    String objectType = this.objetSchema.getType();
    SchemaSyntax syntax = objetSchema.getSyntax();
    String[] params_name = syntax.getParameters(objectType);

    if (params_name == null || params_name.length == 0) {
        return;
    }

    this.labels = new Hashtable<String, JComponent>();
    this.values = new Hashtable<String, JComponent>();
    this.valuesPresent = new Hashtable<String, JCheckBox>();
    Vector<String> parametresEffectues = new Vector<String>();

    for (int i = 0; i < params_name.length; i++) {
        if (parametresEffectues.contains(params_name[i])) {
            continue;
        }

        JComponent label = null;
        JComponent composant = null;
        JCheckBox checkbox = new JCheckBox();
        String[] param_values;
        String[] param_others = syntax.getOthersParametersFor(objectType, params_name[i]);

        // If SUP parameters, add corresponding object names.
        if (params_name[i].compareTo("SUP") == 0) {
            SchemaObject[] objects = this.schema.getObjectsInOrder(objectType);
            param_values = new String[objects.length];
            for (int j = 0; j < objects.length; j++) {
                param_values[j] = objects[j].getNameFirstValue();
            }
        }

        // Else, read the syntax to find needed values.
        else {
            param_values = syntax.getParameterDefaultValues(objectType, params_name[i]);
        }

        // Plusieurs clefs.
        // C'est une liste de clefs possibles.
        if (param_others != null && param_others.length > 1) {
            label = new JComboBox(param_others);
            composant = new JLabel();
            boolean ok = false;

            for (int j = 0; j < param_others.length && !ok; j++) {
                if (objetSchema.isKeyExists(param_others[j])) {
                    ok = true;
                    ((JComboBox) label).setSelectedItem(param_others[j]);
                    checkbox.setSelected(true);
                }
            }
            for (int j = 0; j < param_others.length; j++) {
                parametresEffectues.add(param_others[j]);
            }

        }

        // Aucune valeur possible
        // La prsence du paramtre suffit => JCheckBox.
        else if (param_values.length == 0) {
            label = new JLabel(params_name[i]);
            composant = new JLabel("");
            parametresEffectues.add(params_name[i]);
            checkbox.setSelected(objetSchema.isKeyExists(params_name[i]));

        }

        // Une valeur, on regarde si c'est une valeur prcise.
        // - Si c'est une chane qui peut tre quelconque => JTextField.
        // - Si la valeur est en fait un objet => JTextField + Objet.
        else if (param_values.length == 1 && param_values[0] != null) {
            String tmp = objetSchema.isKeyExists(params_name[i])
                    ? objetSchema.getValue(params_name[i]).toString()
                    : param_values[0];

            label = new JLabel(params_name[i]);
            composant = new JTextField(tmp, 30);
            parametresEffectues.add(params_name[i]);
            checkbox.setSelected(objetSchema.isKeyExists(params_name[i]));

        }

        // Plusieurs valeurs.
        // C'est une liste de choix possibles => JComboBox.
        else if (param_values.length > 1) {
            String tmp = objetSchema.isKeyExists(params_name[i])
                    ? objetSchema.getValue(params_name[i]).toString()
                    : param_values[0];

            if (!ArrayUtils.contains(param_values, tmp)) {
                Vector<String> list = new Vector<String>();
                for (String param_value : param_values) {
                    list.add(param_value);
                }
                list.add(0, tmp);
                param_values = list.toArray(new String[0]);
            }

            label = new JLabel(params_name[i]);
            composant = new JComboBox(param_values);
            ((JComboBox) composant).setEditable(true);
            ((JComboBox) composant).setSelectedItem(tmp);
            parametresEffectues.add(params_name[i]);
            checkbox.setSelected(objetSchema.isKeyExists(params_name[i]));
        }

        // Set elements into the frame.
        if (composant != null && label != null) {
            this.labels.put(params_name[i], label);
            this.values.put(params_name[i], composant);
            this.valuesPresent.put(params_name[i], checkbox);
            SchemaValue v = syntax.createSchemaValue(objectType, params_name[i], null);
            if (v.isValues() && !(composant instanceof JComboBox)) {
                composant.setEnabled(false);
            }
        }
    } // end for
}