Example usage for javax.swing JRadioButton JRadioButton

List of usage examples for javax.swing JRadioButton JRadioButton

Introduction

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

Prototype

public JRadioButton(String text) 

Source Link

Document

Creates an unselected radio button with the specified text.

Usage

From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeographyAssignISOs.java

/**
 * @return// ww w .  j  a  va  2s  .  c  o  m
 */
@SuppressWarnings("rawtypes")
public boolean buildAsyncOrig(final int earthId) {
    String sql = adjustSQL(
            "SELECT COUNT(*) FROM geography WHERE GeographyCode IS NOT NULL AND RankID = 100 AND GeographyTreeDefID = GEOTREEDEFID");
    int numContinentsWithNames = BasicSQLUtils.getCountAsInt(sql);

    continentsCBX = createCheckBox("All Continents"); // I18N

    CellConstraints cc = new CellConstraints();
    PanelBuilder pb1 = new PanelBuilder(new FormLayout("f:p:g", "p,4px,p,4px,p,8px"));
    countriesCBX = createCheckBox("All Countries");
    stateCBX = createCheckBox("All States");
    countiesCBX = createCheckBox("All Counties");
    pb1.add(countriesCBX, cc.xy(1, 1));
    pb1.add(stateCBX, cc.xy(1, 3));
    //pb1.add(countiesCBX,   cc.xy(1, 5));

    allCountriesRB = new JRadioButton("Choose the Geography level to be processed"); //L18N
    singleCountryRB = new JRadioButton("Choose an individual Country");
    btnGroup = new ButtonGroup();
    btnGroup.add(this.allCountriesRB);
    btnGroup.add(this.singleCountryRB);

    if (numContinentsWithNames == 0) {
        continentsCBX.setEnabled(false);
        continentsCBX.setSelected(true);
    }

    countriesCBX.setEnabled(true);
    stateCBX.setEnabled(false);
    countiesCBX.setEnabled(false);

    countryIds.clear();
    sql = "SELECT g.GeographyID, g.Name, g2.Name FROM geography g LEFT JOIN geography g2 ON g.ParentID = g2.GeographyID "
            + "WHERE g.Name IS NOT NULL && LENGTH(g.Name) > 0 AND g.RankID = 200 AND g.GeographyTreeDefID = GEOTREEDEFID ORDER BY g.Name";
    sql = adjustSQL(sql);

    Vector<Object[]> rows = query(sql);
    Object[] titles = new Object[rows.size() + 1];
    int i = 0;
    titles[i++] = "None"; // I18N
    countryIds.add(-1);
    for (Object[] r : rows) {
        countryIds.add((Integer) r[0]);
        String countryStr = (String) r[1];
        String contStr = (String) r[2];
        titles[i++] = countryStr != null ? (countryStr + " (" + contStr + ")") : countryStr;
    }

    PanelBuilder pb2 = new PanelBuilder(new FormLayout("8px,p,2px,f:p:g", "p,4px,p,8px"));
    spCountriesLbl = createFormLabel("Country"); // I18N
    spCountriesCmbx = createComboBox(titles);
    spStatesCBX = createCheckBox("States (Required)"); // I18N
    spCountiesCBX = createCheckBox("Counties"); // I18N

    pb2.add(spCountriesLbl, cc.xy(2, 1));
    pb2.add(spCountriesCmbx, cc.xy(4, 1));
    pb2.add(spStatesCBX, cc.xyw(1, 3, 4));
    //pb2.add(spCountiesCBX,   cc.xyw(1, 5, 4));

    spCountriesCmbx.setSelectedIndex(0);

    spStatesCBX.setSelected(true);
    spStatesCBX.setEnabled(false);
    spCountiesCBX.setEnabled(false);

    String rowDef = createDuplicateJGoodiesDef("p", "4px", 8);
    PanelBuilder pb = new PanelBuilder(new FormLayout("16px,f:p:g", rowDef));

    pb.addSeparator("Continents to be processed", cc.xyw(1, 1, 2));
    pb.add(continentsCBX, cc.xyw(1, 3, 2));

    pb.addSeparator("Countries to be processed", cc.xyw(1, 5, 2));
    pb.add(allCountriesRB, cc.xyw(1, 7, 2));
    pb.add(pb1.getPanel(), cc.xyw(2, 9, 1));

    pb.add(singleCountryRB, cc.xyw(1, 11, 2));
    pb.add(pb2.getPanel(), cc.xyw(2, 13, 1));

    pb.add(createGeoStatsPanel(), cc.xyw(1, 15, 2));

    pb.setDefaultDialogBorder();
    final CustomDialog dlg = new CustomDialog((Frame) getTopWindow(), "ISO Code Processing", true,
            CustomDialog.OKCANCELHELP, pb.getPanel()); // I18N
    dlg.setHelpContext("GeoCleanUpLevelChooser");

    // Setup actions
    ChangeListener rbChangeListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            radioSelected(dlg);
        }
    };
    allCountriesRB.addChangeListener(rbChangeListener);
    singleCountryRB.addChangeListener(null);

    countriesCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            boolean isSel = countriesCBX.isSelected();
            stateCBX.setEnabled(isSel);
            countiesCBX.setEnabled(false);
            if (!isSel) {
                stateCBX.setSelected(false);
                countiesCBX.setSelected(false);
            }
            calcGeoStats();
            dlg.getOkBtn().setEnabled(isSel || spCountriesCmbx.getSelectedIndex() > 0);
        }
    });

    stateCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            countiesCBX.setEnabled(stateCBX.isSelected());
            if (!stateCBX.isSelected()) {
                countiesCBX.setSelected(false);
            }
            calcGeoStats();
        }
    });

    // Special
    spCountriesCmbx.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            boolean isSel = spCountriesCmbx.getSelectedIndex() > 0;
            spStatesCBX.setSelected(isSel);
            spCountiesCBX.setEnabled(isSel);
            if (!isSel) {
                spStatesCBX.setSelected(false);
                spCountiesCBX.setSelected(false);
            }
            calcGeoStats();
            dlg.getOkBtn().setEnabled(isSel || countriesCBX.isSelected());

        }
    });

    spStatesCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            spCountiesCBX.setEnabled(stateCBX.isSelected());
            calcGeoStats();
        }
    });

    allCountriesRB.setSelected(true);

    dlg.createUI();
    dlg.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // Must be called after 'createUI'
    dlg.getOkBtn().setEnabled(false);

    // AUTO Don't show Dialog because it is automatically setting what to do 
    centerAndShow(dlg);

    if (dlg.isCancelled()) {
        return false;
    }

    connectToDB();

    if (true) // AUTO 
    {
        doAllCountries = new boolean[] { countriesCBX.isSelected(), stateCBX.isSelected(),
                countiesCBX.isSelected(), false };
        doInvCountry = new boolean[] { spCountriesCmbx.getSelectedIndex() > 0, spStatesCBX.isSelected(),
                spCountiesCBX.isSelected(), false };
        doIndvCountryId = doInvCountry[0] ? countryIds.get(spCountriesCmbx.getSelectedIndex()) : null;
    } else {
        int indexOfUSA = getUnitedStatesIndex(titles);
        if (indexOfUSA == -1) {
            Vector<Object> nameList = new Vector<Object>();
            Collections.addAll(nameList, titles);
            JList list = createList(nameList);

            JScrollPane sp = createScrollPane(list);
            pb = new PanelBuilder(new FormLayout("f:p:g", "p,8px,f:p:g"));
            pb.add(createLabel("Select the United States"), cc.xy(1, 1));
            pb.add(sp, cc.xy(1, 3));
            pb.setDefaultDialogBorder();
            final CustomDialog askDlg = new CustomDialog((Frame) getTopWindow(), "Choose", true,
                    CustomDialog.OKCANCELHELP, pb.getPanel()); // I18N
            dlg.setHelpContext("GeoCleanUpLevelChooser");
            centerAndShow(askDlg);
            if (!askDlg.isCancelled()) {
                indexOfUSA = list.getSelectedIndex();
            }
        }

        doAllCountries = new boolean[] { true, false, false, false };
        doInvCountry = new boolean[] { indexOfUSA > -1, true, false, false };
        doIndvCountryId = doInvCountry[0] ? countryIds.get(indexOfUSA) : null;
    }

    // Check to see if it needs indexing.
    boolean shouldIndex = luceneSearch.shouldIndex();

    if (shouldIndex) {
        frame = new ProgressFrame("Building Geography Authority..."); // I18N
        frame.getCloseBtn().setVisible(false);
        frame.turnOffOverAll();
        frame.setDesc("Loading Geonames data..."); // I18N
        frame.pack();
        frame.setSize(450, frame.getBounds().height + 10);
        UIHelper.centerAndShow(frame, 450, frame.getBounds().height + 10);

        luceneSearch.startIndexingProcessAsync(earthId, frame, new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                frame.setVisible(false);
                frame = null;
                if (((Boolean) e.getSource())) {
                    GeographyAssignISOs.this.startTraversal();
                }
            }
        });

    } else {
        sql = "SELECT Name, geonameId, iso_alpha2 FROM countryinfo";
        for (Object[] row : query(sql)) {
            countryInfo.add(new GeoSearchResultsItem((String) row[0], (Integer) row[1], (String) row[2]));
        }
        startTraversal();
    }

    return true;
}

From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java

private JPanel getMatcherPanel() {
    if (matcherPanel == null) {
        matcherPanel = new JPanel();
        matcherPanel.setLayout(new GridBagLayout());
        Color bgColor = matcherPanel.getBackground();
        matcherPanel.setBorder(new RoundedBorderPanel(bgColor));

        GridBagConstraints constraint = new GridBagConstraints();
        constraint.gridx = 0;/*w w w.j a  v  a 2  s  .  co m*/
        constraint.gridy = 0;
        constraint.insets = new Insets(0, 0, 0, 0);
        constraint.anchor = GridBagConstraints.FIRST_LINE_START;
        constraint.weightx = 0.5;

        ignore = new JRadioButton(ResourceBundleHelper.getMessageString("videoTab.ignore"));
        match = new JRadioButton(ResourceBundleHelper.getMessageString("videoTab.match"));

        ButtonGroup groupBtn = new ButtonGroup();
        groupBtn.add(ignore);
        groupBtn.add(match);

        keep = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.keep"));
        alpha = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.alpha"));
        characters = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.characters"));
        charField = new JTextField(20);

        numeric = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.numeric"));
        lengthMin = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.min.length"));
        lengthMax = new JCheckBox(ResourceBundleHelper.getMessageString("videoTab.max.length"));
        lengthMinField = new JTextField(10);
        lengthMaxField = new JTextField(10);

        matcherPanel.add(ignore, constraint);

        constraint.gridy = 1;
        constraint.anchor = GridBagConstraints.WEST;
        matcherPanel.add(match, constraint);

        constraint.anchor = GridBagConstraints.EAST;

        enterBtn = new JButton(ResourceBundleHelper.getMessageString("videoTab.enter"));
        enterBtn.setName(ResourceBundleHelper.getMessageString("videoTab.enter"));
        enterBtn.addActionListener(this);
        matcherPanel.add(enterBtn, constraint);

        constraint.anchor = GridBagConstraints.WEST;
        constraint.gridy = 2;
        matcherPanel.add(keep, constraint);

        constraint.gridy = 3;
        matcherPanel.add(alpha, constraint);

        constraint.gridy = 4;
        JPanel panelChar = new JPanel(new FlowLayout());
        panelChar.add(characters);
        panelChar.add(charField);
        matcherPanel.add(panelChar, constraint);

        constraint.gridy = 5;
        matcherPanel.add(numeric, constraint);

        constraint.gridy = 6;
        JPanel panelNumericLength = new JPanel();
        panelNumericLength.setLayout(new BoxLayout(panelNumericLength, BoxLayout.Y_AXIS));
        JPanel panelMinLength = new JPanel(new FlowLayout());
        panelMinLength.add(lengthMin);
        panelMinLength.add(lengthMinField);
        panelNumericLength.add(panelMinLength);
        JPanel panelMaxLength = new JPanel(new FlowLayout());
        panelMaxLength.add(lengthMax);
        panelMaxLength.add(lengthMaxField);
        panelNumericLength.add(panelMaxLength);
        matcherPanel.add(panelNumericLength, constraint);

        constraint.weighty = 1;

        matcherPanel.add(new JPanel(), constraint);
    }
    return matcherPanel;
}

From source file:TexBug.java

JPanel texture2DPanel() {

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 0)); // horizontal

    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new GridLayout(0, 1)); // vertical
    panel.add(leftPanel);//  w  w w.j  ava  2 s . c  om

    JPanel rightPanel = new JPanel();
    rightPanel.setLayout(new GridLayout(0, 1)); // vertical
    panel.add(rightPanel);

    texEnableCheckBox = new JCheckBox(texEnableString);

    // set up the action commands
    texEnableCheckBox.setActionCommand(texEnableString);

    // register the applet as the listener for the buttons
    texEnableCheckBox.addActionListener(this);

    // set the initial value
    texEnableCheckBox.setSelected(texEnable);

    // add the checkbox to the panel
    leftPanel.add(texEnableCheckBox);

    // texture boundary S
    leftPanel.add(new JLabel("Boundary S Mode:"));

    // create the buttons
    JRadioButton texBoundarySWrapButton = new JRadioButton(wrapString);
    JRadioButton texBoundarySClampButton = new JRadioButton(clampString);

    // set up the action commands
    texBoundarySWrapButton.setActionCommand(texBoundarySWrapString);
    texBoundarySClampButton.setActionCommand(texBoundarySClampString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup boundSButtonGroup = new ButtonGroup();
    boundSButtonGroup.add(texBoundarySWrapButton);
    boundSButtonGroup.add(texBoundarySClampButton);

    // register the applet as the listener for the buttons
    texBoundarySWrapButton.addActionListener(this);
    texBoundarySClampButton.addActionListener(this);

    // add the buttons to the panel
    leftPanel.add(texBoundarySWrapButton);
    leftPanel.add(texBoundarySClampButton);

    // set the default
    texBoundarySWrapButton.setSelected(true);

    // texture boundary T
    leftPanel.add(new JLabel("Boundary T Mode:"));

    // create the buttons
    JRadioButton texBoundaryTWrapButton = new JRadioButton(wrapString);
    JRadioButton texBoundaryTClampButton = new JRadioButton(clampString);

    // set up the action commands
    texBoundaryTWrapButton.setActionCommand(texBoundaryTWrapString);
    texBoundaryTClampButton.setActionCommand(texBoundaryTClampString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup boundTButtonGroup = new ButtonGroup();
    boundTButtonGroup.add(texBoundaryTWrapButton);
    boundTButtonGroup.add(texBoundaryTClampButton);

    // register the applet as the listener for the buttons
    texBoundaryTWrapButton.addActionListener(this);
    texBoundaryTClampButton.addActionListener(this);

    // add the buttons to the panel
    leftPanel.add(texBoundaryTWrapButton);
    leftPanel.add(texBoundaryTClampButton);

    // set the default
    texBoundaryTWrapButton.setSelected(true);

    // texture min filter
    rightPanel.add(new JLabel("Min Filter:"));

    // create the buttons
    JRadioButton texMinFilterBasePointButton = new JRadioButton(texFilterBasePointString);
    JRadioButton texMinFilterBaseLinearButton = new JRadioButton(texFilterBaseLinearString);
    JRadioButton texMinFilterMultiPointButton = new JRadioButton(texFilterMultiPointString);
    JRadioButton texMinFilterMultiLinearButton = new JRadioButton(texFilterMultiLinearString);
    JRadioButton texMinFilterNicestButton = new JRadioButton(nicestString);
    JRadioButton texMinFilterFastestButton = new JRadioButton(fastestString);

    // set up the action commands
    texMinFilterBasePointButton.setActionCommand(texMinFilterBasePointString);
    texMinFilterBaseLinearButton.setActionCommand(texMinFilterBaseLinearString);
    texMinFilterMultiPointButton.setActionCommand(texMinFilterMultiPointString);
    texMinFilterMultiLinearButton.setActionCommand(texMinFilterMultiLinearString);
    texMinFilterNicestButton.setActionCommand(texMinFilterNicestString);
    texMinFilterFastestButton.setActionCommand(texMinFilterFastestString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup minFilterButtonGroup = new ButtonGroup();
    minFilterButtonGroup.add(texMinFilterBasePointButton);
    minFilterButtonGroup.add(texMinFilterBaseLinearButton);
    minFilterButtonGroup.add(texMinFilterMultiPointButton);
    minFilterButtonGroup.add(texMinFilterMultiLinearButton);
    minFilterButtonGroup.add(texMinFilterNicestButton);
    minFilterButtonGroup.add(texMinFilterFastestButton);

    // register the applet as the listener for the buttons
    texMinFilterBasePointButton.addActionListener(this);
    texMinFilterBaseLinearButton.addActionListener(this);
    texMinFilterMultiPointButton.addActionListener(this);
    texMinFilterMultiLinearButton.addActionListener(this);
    texMinFilterNicestButton.addActionListener(this);
    texMinFilterFastestButton.addActionListener(this);

    // add the buttons to the panel
    rightPanel.add(texMinFilterBasePointButton);
    rightPanel.add(texMinFilterBaseLinearButton);
    rightPanel.add(texMinFilterMultiPointButton);
    rightPanel.add(texMinFilterMultiLinearButton);
    rightPanel.add(texMinFilterNicestButton);
    rightPanel.add(texMinFilterFastestButton);

    // set the default
    texMinFilterBasePointButton.setSelected(true);

    // texture max filter
    rightPanel.add(new JLabel("Mag Filter:"));

    // create the buttons
    JRadioButton texMagFilterBasePointButton = new JRadioButton(texFilterBasePointString);
    JRadioButton texMagFilterBaseLinearButton = new JRadioButton(texFilterBaseLinearString);
    JRadioButton texMagFilterNicestButton = new JRadioButton(nicestString);
    JRadioButton texMagFilterFastestButton = new JRadioButton(fastestString);

    // set up the action commands
    texMagFilterBasePointButton.setActionCommand(texMagFilterBasePointString);
    texMagFilterBaseLinearButton.setActionCommand(texMagFilterBaseLinearString);
    texMagFilterNicestButton.setActionCommand(texMagFilterNicestString);
    texMagFilterFastestButton.setActionCommand(texMagFilterFastestString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup magFilterButtonGroup = new ButtonGroup();
    magFilterButtonGroup.add(texMagFilterBasePointButton);
    magFilterButtonGroup.add(texMagFilterBaseLinearButton);
    magFilterButtonGroup.add(texMagFilterNicestButton);
    magFilterButtonGroup.add(texMagFilterFastestButton);

    // register the applet as the listener for the buttons
    texMagFilterBasePointButton.addActionListener(this);
    texMagFilterBaseLinearButton.addActionListener(this);
    texMagFilterNicestButton.addActionListener(this);
    texMagFilterFastestButton.addActionListener(this);

    // add the buttons to the panel
    rightPanel.add(texMagFilterBasePointButton);
    rightPanel.add(texMagFilterBaseLinearButton);
    rightPanel.add(texMagFilterNicestButton);
    rightPanel.add(texMagFilterFastestButton);

    // set the default
    texMagFilterBasePointButton.setSelected(true);

    // MipMap Mode
    leftPanel.add(new JLabel("MipMap Mode:"));

    // create the buttons
    JRadioButton texMipMapBaseButton = new JRadioButton(texMipMapBaseString);
    JRadioButton texMipMapMultiButton = new JRadioButton(texMipMapMultiString);

    // set up the action commands
    texMipMapBaseButton.setActionCommand(texMipMapBaseString);
    texMipMapMultiButton.setActionCommand(texMipMapMultiString);

    // add the buttons to a group so that only one can be selected
    ButtonGroup texMipMapButtonGroup = new ButtonGroup();
    texMipMapButtonGroup.add(texMipMapBaseButton);
    texMipMapButtonGroup.add(texMipMapMultiButton);

    // register the applet as the listener for the buttons
    texMipMapBaseButton.addActionListener(this);
    texMipMapMultiButton.addActionListener(this);

    // add the buttons to the panel
    leftPanel.add(texMipMapBaseButton);
    leftPanel.add(texMipMapMultiButton);

    // set the default
    texMipMapBaseButton.setSelected(true);

    return panel;

}

From source file:metdemo.Finance.Pluggable.java

protected void addBottomControls(final JPanel jp) {
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.SOUTH);
    control_panel.setLayout(new BorderLayout());
    final Box vertex_panel = Box.createVerticalBox();
    vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices"));
    final Box edge_panel = Box.createVerticalBox();
    edge_panel.setBorder(BorderFactory.createTitledBorder("Edges"));
    final Box both_panel = Box.createVerticalBox();

    control_panel.add(vertex_panel, BorderLayout.WEST);
    control_panel.add(edge_panel, BorderLayout.EAST);
    control_panel.add(both_panel, BorderLayout.CENTER);

    // set up vertex controls
    v_color = new JCheckBox("vertex seed coloring");
    v_color.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            vcf.setSeedColoring(v_color.isSelected());
        }//from w w w  .  jav  a 2 s .c  o m
    });

    v_stroke = new JCheckBox("<html>vertex selection<p>stroke highlighting</html>");
    v_stroke.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            vsh.setHighlight(v_stroke.isSelected());
        }
    });

    v_labels = new JCheckBox("show vertex ranks (voltages)");
    v_labels.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (v_labels.isSelected())
                pr.setVertexStringer(vs);
            else
                pr.setVertexStringer(vs_none);
        }
    });

    v_shape = new JCheckBox("vertex degree shapes");
    v_shape.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            vssa.useFunnyShapes(v_shape.isSelected());
        }
    });

    v_size = new JCheckBox("vertex voltage size");
    v_size.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            vssa.setScaling(v_size.isSelected());
        }
    });
    v_aspect = new JCheckBox("vertex degree ratio stretch");
    v_aspect.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            vssa.setStretching(v_aspect.isSelected());
        }
    });

    v_small = new JCheckBox("filter vertices of degree < " + VertexDisplayPredicate.MIN_DEGREE);
    v_small.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            show_vertex.filterSmall(v_small.isSelected());
        }
    });

    vertex_panel.add(v_color);
    vertex_panel.add(v_stroke);
    vertex_panel.add(v_labels);
    vertex_panel.add(v_shape);
    vertex_panel.add(v_size);
    vertex_panel.add(v_aspect);
    vertex_panel.add(v_small);

    // set up edge controls
    JPanel gradient_panel = new JPanel(new GridLayout(1, 0));
    gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint"));
    no_gradient = new JRadioButton("Solid color");
    no_gradient.setSelected(true);
    no_gradient.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            gradient_level = GRADIENT_NONE;
        }
    });
    //      gradient_absolute = new JRadioButton("Absolute gradient");
    //      gradient_absolute.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { gradient_level = GRADIENT_ABSOLUTE;}});
    gradient_relative = new JRadioButton("Gradient");
    gradient_relative.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            gradient_level = GRADIENT_RELATIVE;
        }
    });

    ButtonGroup bg_grad = new ButtonGroup();
    bg_grad.add(no_gradient);
    bg_grad.add(gradient_relative);
    //bg_grad.add(gradient_absolute);
    gradient_panel.add(no_gradient);
    //gradientGrid.add(gradient_absolute);
    gradient_panel.add(gradient_relative);

    JPanel shape_panel = new JPanel(new GridLayout(3, 2));
    shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape"));
    e_line = new JRadioButton("line");
    e_line.setSelected(true);
    e_line.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pr.setEdgeShapeFunction(new EdgeShape.Line());
        }
    });
    //        e_bent = new JRadioButton("bent line");
    //        e_bent.setSelected(true);
    e_wedge = new JRadioButton("wedge");
    e_wedge.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pr.setEdgeShapeFunction(new EdgeShape.Wedge(10));
        }
    });
    e_quad = new JRadioButton("quad curve");
    e_quad.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pr.setEdgeShapeFunction(new EdgeShape.QuadCurve());
        }
    });
    e_cubic = new JRadioButton("cubic curve");
    e_cubic.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pr.setEdgeShapeFunction(new EdgeShape.CubicCurve());
        }
    });
    ButtonGroup bg_shape = new ButtonGroup();
    bg_shape.add(e_line);
    //        bg.add(e_bent);
    bg_shape.add(e_wedge);
    bg_shape.add(e_quad);
    bg_shape.add(e_cubic);
    shape_panel.add(e_line);
    //        shape_panel.add(e_bent);
    shape_panel.add(e_wedge);
    shape_panel.add(e_quad);
    shape_panel.add(e_cubic);
    fill_edges = new JCheckBox("fill edge shapes");
    fill_edges.setSelected(false);
    fill_edges.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            edgePaint.useFill(fill_edges.isSelected());
        }
    });
    shape_panel.add(fill_edges);
    shape_panel.setOpaque(true);
    e_color = new JCheckBox("edge weight highlighting");
    e_color.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ewcs.setWeighted(e_color.isSelected());
        }
    });

    e_labels = new JCheckBox("show edge weights");
    e_labels.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (e_labels.isSelected())
                pr.setEdgeStringer(es);
            else
                pr.setEdgeStringer(es_none);
        }
    });

    e_uarrow_pred = new JCheckBox("undirected");
    e_uarrow_pred.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            show_arrow.showUndirected(e_uarrow_pred.isSelected());
        }
    });
    e_darrow_pred = new JCheckBox("directed");
    e_darrow_pred.setSelected(true);
    e_darrow_pred.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            show_arrow.showDirected(e_darrow_pred.isSelected());
        }
    });
    JPanel arrow_panel = new JPanel(new GridLayout(1, 0));
    arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows"));
    arrow_panel.add(e_uarrow_pred);
    arrow_panel.add(e_darrow_pred);

    e_show_d = new JCheckBox("directed");
    e_show_d.setSelected(true);
    e_show_d.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            show_edge.showDirected(e_show_d.isSelected());
        }
    });
    e_show_u = new JCheckBox("undirected");
    e_show_u.setSelected(true);
    e_show_u.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            show_edge.showUndirected(e_show_u.isSelected());
        }
    });
    JPanel show_edge_panel = new JPanel(new GridLayout(1, 0));
    show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges"));
    show_edge_panel.add(e_show_u);
    show_edge_panel.add(e_show_d);

    shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(shape_panel);
    gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(gradient_panel);
    show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(show_edge_panel);
    arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(arrow_panel);

    e_color.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_color);
    e_labels.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_labels);

    // set up zoom controls
    zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>");
    zoom_at_mouse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            gm.setZoomAtMouse(zoom_at_mouse.isSelected());
        }
    });
    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // call listener in GraphMouse instead of manipulating vv scale directly
            // this is so the crossover from zoom to scale works with the buttons
            // as well as with the mouse wheel
            Dimension d = vv.getSize();
            gm.mouseWheelMoved(new MouseWheelEvent(vv, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(), 0,
                    d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, 1));
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // call listener in GraphMouse instead of manipulating vv scale directly
            // this is so the crossover from zoom to scale works with the buttons
            // as well as with the mouse wheel
            Dimension d = vv.getSize();
            gm.mouseWheelMoved(new MouseWheelEvent(vv, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(), 0,
                    d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, -1));
        }
    });
    Box zoomPanel = Box.createVerticalBox();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    plus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(plus);
    minus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(minus);
    zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(zoom_at_mouse);

    // add font and zoom controls to center panel
    font = new JCheckBox("bold text");
    font.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ff.setBold(font.isSelected());
        }
    });
    font.setAlignmentX(Component.CENTER_ALIGNMENT);

    both_panel.add(zoomPanel);
    both_panel.add(font);

    JComboBox modeBox = gm.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    both_panel.add(modePanel);
}

From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.java

private JPanel createMaskingPanel(JFreeChart chart) {
    JPanel wrap = new JPanel(new BorderLayout());

    JPanel maskingPanel = new JPanel(new GridLayout(1, 1));
    maskingPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    //Horizontal group
    JPanel managePanel = new JPanel(new BorderLayout());
    managePanel.setBorder(/*from w w w  .  jav a 2  s  .  c o  m*/
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Region of Interests"));

    JPanel inner = new JPanel(new LCBLayout(6));
    inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    inner.add(new JLabel("Select Region"));
    roiCombo = new JComboBox(panel.getMasks().toArray());
    //      colourScaleCombo.setMaximumRowCount(7);
    roiCombo.setSelectedIndex(-1);
    roiCombo.setActionCommand(CHANGE_ROI_COMMAND);
    roiCombo.addActionListener(this);
    inner.add(roiCombo);
    inner.add(new JLabel());

    inner.add(new JLabel("or create"));
    newRectangleButton = new JButton("New Region of Interests");
    newRectangleButton.setActionCommand(CREATE_NEW_RECT_REGION_COMMAND);
    newRectangleButton.addActionListener(this);
    inner.add(newRectangleButton);
    inner.add(new JLabel());

    JPanel editPanel = new JPanel(new BorderLayout());
    editPanel
            .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Edit the Region"));

    JPanel editInner = new JPanel(new LCBLayout(6));
    editInner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    editInner.add(new JLabel("Name"));
    roiName = new JTextField(10);
    //      colourScaleCombo.setMaximumRowCount(7);
    roiName.setActionCommand(CHANGE_ROI_NAME_COMMAND);
    roiName.addActionListener(this);
    editInner.add(roiName);
    editInner.add(new JLabel());

    editInner.add(new JLabel("Usage"));
    ButtonGroup buttonGroup = new ButtonGroup();
    JPanel radioPanel = new JPanel(new GridLayout(1, 2));
    inclusiveRadio = new JRadioButton("inclusive");
    inclusiveRadio.setActionCommand(USE_INCLUSIVE_COMMAND);
    inclusiveRadio.addActionListener(this);
    buttonGroup.add(inclusiveRadio);
    radioPanel.add(inclusiveRadio);
    exclusiveRadio = new JRadioButton("exclusive");
    exclusiveRadio.setActionCommand(USE_EXCLUSIVE_COMMAND);
    exclusiveRadio.addActionListener(this);
    buttonGroup.add(exclusiveRadio);
    radioPanel.add(exclusiveRadio);
    editInner.add(radioPanel);
    editInner.add(new JLabel());

    editInner.add(new JLabel("X Range"));
    JPanel xRangePanel = new JPanel(new GridLayout(1, 2));
    JPanel xMinPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    xMinPanel.add(new JLabel("min: "));
    xMin = new JTextField(10);
    //      xMin.setActionCommand(CHANGE_XMIN_COMMAND);
    //      xMin.addActionListener(this);
    xMin.addKeyListener(this);
    xMinPanel.add(xMin);
    xRangePanel.add(xMinPanel);
    JPanel xMaxPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    xMaxPanel.add(new JLabel("max: "));
    xMax = new JTextField(10);
    //      xMax.setActionCommand(CHANGE_XMAX_COMMAND);
    xMax.addKeyListener(this);
    xMaxPanel.add(xMax);
    xRangePanel.add(xMaxPanel);
    editInner.add(xRangePanel);
    editInner.add(new JLabel());

    editInner.add(new JLabel());
    JPanel applyPanel = new JPanel(new GridLayout(1, 2));
    deleteButton = new JButton("Remove");
    deleteButton.setEnabled(false);
    deleteButton.setActionCommand(REMOVE_CHANGE_ACTION);
    deleteButton.addActionListener(this);
    applyPanel.add(deleteButton);
    applyPanel.add(new JLabel());
    applyButton = new JButton("Apply");
    applyButton.setEnabled(false);
    applyButton.setActionCommand(APPLY_CHANGE_ACTION);
    applyButton.addActionListener(this);
    applyPanel.add(applyButton);
    editInner.add(applyPanel);
    editInner.add(new JLabel());
    //      inner.add(new JLabel("X Range"));
    //      inner.add(inclusiveRadio);
    //      exclusiveRadio = new JRadioButton("exclusive");
    //      exclusiveRadio.setActionCommand(USE_EXCLUSIVE_COMMAND);
    //      exclusiveRadio.addActionListener(this);
    //      inner.add(exclusiveRadio);
    editPanel.add(editInner, BorderLayout.NORTH);
    managePanel.add(editPanel, BorderLayout.SOUTH);
    managePanel.add(inner, BorderLayout.NORTH);
    maskingPanel.add(managePanel);
    wrap.setName("ROI");

    wrap.add(maskingPanel, BorderLayout.NORTH);
    return wrap;
}

From source file:com.diversityarrays.kdxplore.trials.AddScoringSetDialog.java

private Box createWantSampleButtons(SampleGroup curatedSampleGroup) {
    Box result = null;/* w w w  .  ja v  a 2s. c  om*/
    ActionListener rbListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            wantSampleValues = noSampleValuesButton != e.getSource();
        }
    };

    result = Box.createHorizontalBox();
    String noSampleValues = Msg.OPTION_NO_SAMPLE_VALUES();
    ButtonGroup bg = new ButtonGroup();
    for (String rbname : new String[] { noSampleValues, Msg.OPTION_CURATED_SAMPLE_VALUES() }) {
        JRadioButton rb = new JRadioButton(rbname);
        result.add(rb);
        bg.add(rb);
        rb.addActionListener(rbListener);
        if (noSampleValues.equals(rbname)) {
            noSampleValuesButton = rb;
        } else {
            rb.doClick();
        }
    }
    result.add(Box.createHorizontalGlue());

    return result;
}

From source file:com.declarativa.interprolog.gui.Ini2BCKP.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

    // create a simple graph for the demo
    graph = new DelegateForest<String, Integer>();

    createTree();//w  w  w  .  j a v  a2s  .c  o m

    layout = new TreeLayout<String, Integer>(graph);
    radialLayout = new BalloonLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(900, 900));

    vv = new VisualizationViewer<String, Integer>(layout, new Dimension(600, 600));
    vv.setBackground(Color.white);

    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Ini2BCKP.Rings(radialLayout);

    System.out.println("test");
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);

    Container content = getContentPane();

    content.add(panel);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    hyperbolicViewSupport = new ViewLensSupport<String, Integer>(vv,
            new HyperbolicShapeTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)),
            new ModalLensGraphMouse());

    graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener());

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    vv.scaleToLayout(scaler);

    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());
        }
    });

    JToggleButton radial = new JToggleButton("Balloon");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, layout,
                        radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout,
                        layout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });
    final JRadioButton hyperView = new JRadioButton("Hyperbolic View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);
    //        content.add(controls, BorderLayout.SOUTH);

    //JFrame frame = new JFrame();
    //content = frame.getContentPane();

    //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jLayeredPane1.add(vv);
    jLayeredPane1.updateUI();
    jLayeredPane1.setVisible(true);

}

From source file:edu.ucla.stat.SOCR.chart.SuperXYChart_QQ.java

public void initMapPanel() {
    listIndex = new int[dataTable.getColumnCount()];
    for (int j = 0; j < listIndex.length; j++)
        listIndex[j] = 1;/*  www. j  av  a  2s. c o m*/
    bPanel = new JPanel(new BorderLayout());
    mapPanel = new JPanel(new GridLayout(2, 3, 50, 50));
    bPanel.add(mapPanel, BorderLayout.CENTER);

    addButton1.addActionListener(this);
    addButton2.addActionListener(this);
    removeButton1.addActionListener(this);
    removeButton2.addActionListener(this);

    lModelAdded = new DefaultListModel();
    lModelDep = new DefaultListModel();
    lModelIndep = new DefaultListModel();

    int cellWidth = 10;

    listAdded = new JList(lModelAdded);
    listAdded.setSelectedIndex(0);
    listDepRemoved = new JList(lModelDep);
    listIndepRemoved = new JList(lModelIndep);

    paintMappingLists(listIndex);
    listAdded.setFixedCellWidth(cellWidth);
    listDepRemoved.setFixedCellWidth(cellWidth);
    listIndepRemoved.setFixedCellWidth(cellWidth);

    tools1 = new JToolBar(JToolBar.VERTICAL);
    tools2 = new JToolBar(JToolBar.VERTICAL);

    tools1.add(depLabel);
    //    tools2.add(indLabel);

    tools1.setFloatable(false);
    tools2.setFloatable(false);
    tools1.add(addButton1);
    tools1.add(removeButton1);
    //  tools2.add(addButton2);
    //   tools2.add(removeButton2);

    JRadioButton disChoices_normal;
    JRadioButton disChoices_poisson;

    //
    JPanel choicesPanel = new JPanel();
    disChoices_normal = new JRadioButton("Normal");
    disChoices_normal.addActionListener(this);
    disChoices_normal.setActionCommand(NORMAL);
    disChoices_normal.setSelected(true);
    disChoice = NORMAL;

    disChoices_poisson = new JRadioButton("Poisson");
    disChoices_poisson.addActionListener(this);
    disChoices_poisson.setActionCommand(POISSON);

    ButtonGroup group = new ButtonGroup();
    group.add(disChoices_normal);
    group.add(disChoices_poisson);
    choicesPanel.add(new JLabel("Choices of distribution:"));
    choicesPanel.add(disChoices_normal);
    choicesPanel.add(disChoices_poisson);
    choicesPanel.setPreferredSize(new Dimension(200, 100));

    mapPanel.add(new JScrollPane(listAdded));
    mapPanel.add(tools1);
    mapPanel.add(new JScrollPane(listDepRemoved));
    //      JPanel emptyPanel = new JPanel(new GridLayout(0,1));
    //   mapPanel.add(emptyPanel);
    mapPanel.add(choicesPanel);
    mapPanel.add(tools2);
    mapPanel.add(new JScrollPane(listIndepRemoved));

}

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

/**
 * @param jp    panel to which controls will be added
 *//*from   w w  w . ja  va2  s.com*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void addBottomControls(final JPanel jp) {
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.EAST);
    control_panel.setLayout(new BorderLayout());
    final Box vertex_panel = Box.createVerticalBox();
    vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices"));
    final Box edge_panel = Box.createVerticalBox();
    edge_panel.setBorder(BorderFactory.createTitledBorder("Edges"));
    final Box both_panel = Box.createVerticalBox();

    control_panel.add(vertex_panel, BorderLayout.NORTH);
    control_panel.add(edge_panel, BorderLayout.SOUTH);
    control_panel.add(both_panel, BorderLayout.CENTER);

    // set up vertex controls
    v_color = new JCheckBox("seed highlight");
    v_color.addActionListener(this);
    v_stroke = new JCheckBox("stroke highlight on selection");
    v_stroke.addActionListener(this);
    v_labels = new JCheckBox("show voltage values");
    v_labels.addActionListener(this);
    v_shape = new JCheckBox("shape by degree");
    v_shape.addActionListener(this);
    v_size = new JCheckBox("size by voltage");
    v_size.addActionListener(this);
    v_size.setSelected(true);
    v_aspect = new JCheckBox("stretch by degree ratio");
    v_aspect.addActionListener(this);
    v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE);
    v_small.addActionListener(this);

    vertex_panel.add(v_color);
    vertex_panel.add(v_stroke);
    vertex_panel.add(v_labels);
    vertex_panel.add(v_shape);
    vertex_panel.add(v_size);
    vertex_panel.add(v_aspect);
    vertex_panel.add(v_small);

    // set up edge controls
    JPanel gradient_panel = new JPanel(new GridLayout(1, 0));
    gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint"));
    no_gradient = new JRadioButton("Solid color");
    no_gradient.addActionListener(this);
    no_gradient.setSelected(true);
    //      gradient_absolute = new JRadioButton("Absolute gradient");
    //      gradient_absolute.addActionListener(this);
    gradient_relative = new JRadioButton("Gradient");
    gradient_relative.addActionListener(this);
    ButtonGroup bg_grad = new ButtonGroup();
    bg_grad.add(no_gradient);
    bg_grad.add(gradient_relative);
    //bg_grad.add(gradient_absolute);
    gradient_panel.add(no_gradient);
    //gradientGrid.add(gradient_absolute);
    gradient_panel.add(gradient_relative);

    JPanel shape_panel = new JPanel(new GridLayout(3, 2));
    shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape"));
    e_line = new JRadioButton("line");
    e_line.addActionListener(this);
    e_line.setSelected(true);
    //        e_bent = new JRadioButton("bent line");
    //        e_bent.addActionListener(this);
    e_wedge = new JRadioButton("wedge");
    e_wedge.addActionListener(this);
    e_quad = new JRadioButton("quad curve");
    e_quad.addActionListener(this);
    e_cubic = new JRadioButton("cubic curve");
    e_cubic.addActionListener(this);
    e_ortho = new JRadioButton("orthogonal");
    e_ortho.addActionListener(this);
    ButtonGroup bg_shape = new ButtonGroup();
    bg_shape.add(e_line);
    //        bg.add(e_bent);
    bg_shape.add(e_wedge);
    bg_shape.add(e_quad);
    bg_shape.add(e_ortho);
    bg_shape.add(e_cubic);
    shape_panel.add(e_line);
    //        shape_panel.add(e_bent);
    shape_panel.add(e_wedge);
    shape_panel.add(e_quad);
    shape_panel.add(e_cubic);
    shape_panel.add(e_ortho);
    fill_edges = new JCheckBox("fill edge shapes");
    fill_edges.setSelected(false);
    fill_edges.addActionListener(this);
    shape_panel.add(fill_edges);
    shape_panel.setOpaque(true);
    e_color = new JCheckBox("highlight edge weights");
    e_color.addActionListener(this);
    e_labels = new JCheckBox("show edge weight values");
    e_labels.addActionListener(this);
    e_uarrow_pred = new JCheckBox("undirected");
    e_uarrow_pred.addActionListener(this);
    e_darrow_pred = new JCheckBox("directed");
    e_darrow_pred.addActionListener(this);
    e_darrow_pred.setSelected(true);
    e_arrow_centered = new JCheckBox("centered");
    e_arrow_centered.addActionListener(this);
    JPanel arrow_panel = new JPanel(new GridLayout(1, 0));
    arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows"));
    arrow_panel.add(e_uarrow_pred);
    arrow_panel.add(e_darrow_pred);
    arrow_panel.add(e_arrow_centered);

    e_show_d = new JCheckBox("directed");
    e_show_d.addActionListener(this);
    e_show_d.setSelected(true);
    e_show_u = new JCheckBox("undirected");
    e_show_u.addActionListener(this);
    e_show_u.setSelected(true);
    JPanel show_edge_panel = new JPanel(new GridLayout(1, 0));
    show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges"));
    show_edge_panel.add(e_show_u);
    show_edge_panel.add(e_show_d);

    shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(shape_panel);
    gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(gradient_panel);
    show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(show_edge_panel);
    arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(arrow_panel);

    e_color.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_color);
    e_labels.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_labels);

    // set up zoom controls
    zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>");
    zoom_at_mouse.addActionListener(this);
    zoom_at_mouse.setSelected(true);

    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, 1 / 1.1f, vv.getCenter());
        }
    });

    JPanel zoomPanel = new JPanel();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    plus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(plus);
    minus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(minus);
    zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(zoom_at_mouse);

    JPanel fontPanel = new JPanel();
    // add font and zoom controls to center panel
    font = new JCheckBox("bold text");
    font.addActionListener(this);
    font.setAlignmentX(Component.CENTER_ALIGNMENT);
    fontPanel.add(font);

    both_panel.add(zoomPanel);
    both_panel.add(fontPanel);

    JComboBox modeBox = gm.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    JPanel comboGrid = new JPanel(new GridLayout(0, 1));
    comboGrid.add(modePanel);
    fontPanel.add(comboGrid);

    JComboBox cb = new JComboBox();
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.NE);
    cb.addItem(Renderer.VertexLabel.Position.E);
    cb.addItem(Renderer.VertexLabel.Position.SE);
    cb.addItem(Renderer.VertexLabel.Position.S);
    cb.addItem(Renderer.VertexLabel.Position.SW);
    cb.addItem(Renderer.VertexLabel.Position.W);
    cb.addItem(Renderer.VertexLabel.Position.NW);
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.CNTR);
    cb.addItem(Renderer.VertexLabel.Position.AUTO);
    cb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem();
            vv.getRenderer().getVertexLabelRenderer().setPosition(position);
            vv.repaint();
        }
    });
    cb.setSelectedItem(Renderer.VertexLabel.Position.SE);
    JPanel positionPanel = new JPanel();
    positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position"));
    positionPanel.add(cb);

    comboGrid.add(positionPanel);

}

From source file:com.google.code.facebook.graph.sna.applet.PluggableRendererDemo.java

/**
 * @param jp    panel to which controls will be added
 *//*from   ww w. ja va 2 s .  c  o m*/
@SuppressWarnings("serial")
protected void addBottomControls(final JPanel jp) {
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.EAST);
    control_panel.setLayout(new BorderLayout());
    final Box vertex_panel = Box.createVerticalBox();
    vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices"));
    final Box edge_panel = Box.createVerticalBox();
    edge_panel.setBorder(BorderFactory.createTitledBorder("Edges"));
    final Box both_panel = Box.createVerticalBox();

    control_panel.add(vertex_panel, BorderLayout.NORTH);
    control_panel.add(edge_panel, BorderLayout.SOUTH);
    control_panel.add(both_panel, BorderLayout.CENTER);

    // set up vertex controls
    v_color = new JCheckBox("seed highlight");
    v_color.addActionListener(this);
    v_stroke = new JCheckBox("stroke highlight on selection");
    v_stroke.addActionListener(this);
    v_labels = new JCheckBox("show voltage values");
    v_labels.addActionListener(this);
    v_shape = new JCheckBox("shape by degree");
    v_shape.addActionListener(this);
    v_size = new JCheckBox("size by voltage");
    v_size.addActionListener(this);
    v_size.setSelected(true);
    v_aspect = new JCheckBox("stretch by degree ratio");
    v_aspect.addActionListener(this);
    v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE);
    v_small.addActionListener(this);

    vertex_panel.add(v_color);
    vertex_panel.add(v_stroke);
    vertex_panel.add(v_labels);
    vertex_panel.add(v_shape);
    vertex_panel.add(v_size);
    vertex_panel.add(v_aspect);
    vertex_panel.add(v_small);

    // set up edge controls
    JPanel gradient_panel = new JPanel(new GridLayout(1, 0));
    gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint"));
    no_gradient = new JRadioButton("Solid color");
    no_gradient.addActionListener(this);
    no_gradient.setSelected(true);
    //      gradient_absolute = new JRadioButton("Absolute gradient");
    //      gradient_absolute.addActionListener(this);
    gradient_relative = new JRadioButton("Gradient");
    gradient_relative.addActionListener(this);
    ButtonGroup bg_grad = new ButtonGroup();
    bg_grad.add(no_gradient);
    bg_grad.add(gradient_relative);
    //bg_grad.add(gradient_absolute);
    gradient_panel.add(no_gradient);
    //gradientGrid.add(gradient_absolute);
    gradient_panel.add(gradient_relative);

    JPanel shape_panel = new JPanel(new GridLayout(3, 2));
    shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape"));
    e_line = new JRadioButton("line");
    e_line.addActionListener(this);
    e_line.setSelected(true);
    //        e_bent = new JRadioButton("bent line");
    //        e_bent.addActionListener(this);
    e_wedge = new JRadioButton("wedge");
    e_wedge.addActionListener(this);
    e_quad = new JRadioButton("quad curve");
    e_quad.addActionListener(this);
    e_cubic = new JRadioButton("cubic curve");
    e_cubic.addActionListener(this);
    e_ortho = new JRadioButton("orthogonal");
    e_ortho.addActionListener(this);
    ButtonGroup bg_shape = new ButtonGroup();
    bg_shape.add(e_line);
    //        bg.add(e_bent);
    bg_shape.add(e_wedge);
    bg_shape.add(e_quad);
    bg_shape.add(e_ortho);
    bg_shape.add(e_cubic);
    shape_panel.add(e_line);
    //        shape_panel.add(e_bent);
    shape_panel.add(e_wedge);
    shape_panel.add(e_quad);
    shape_panel.add(e_cubic);
    shape_panel.add(e_ortho);
    fill_edges = new JCheckBox("fill edge shapes");
    fill_edges.setSelected(false);
    fill_edges.addActionListener(this);
    shape_panel.add(fill_edges);
    shape_panel.setOpaque(true);
    e_color = new JCheckBox("highlight edge weights");
    e_color.addActionListener(this);
    e_labels = new JCheckBox("show edge weight values");
    e_labels.addActionListener(this);
    e_uarrow_pred = new JCheckBox("undirected");
    e_uarrow_pred.addActionListener(this);
    e_darrow_pred = new JCheckBox("directed");
    e_darrow_pred.addActionListener(this);
    e_darrow_pred.setSelected(true);
    e_arrow_centered = new JCheckBox("centered");
    e_arrow_centered.addActionListener(this);
    JPanel arrow_panel = new JPanel(new GridLayout(1, 0));
    arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows"));
    arrow_panel.add(e_uarrow_pred);
    arrow_panel.add(e_darrow_pred);
    arrow_panel.add(e_arrow_centered);

    e_show_d = new JCheckBox("directed");
    e_show_d.addActionListener(this);
    e_show_d.setSelected(true);
    e_show_u = new JCheckBox("undirected");
    e_show_u.addActionListener(this);
    e_show_u.setSelected(true);
    JPanel show_edge_panel = new JPanel(new GridLayout(1, 0));
    show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges"));
    show_edge_panel.add(e_show_u);
    show_edge_panel.add(e_show_d);

    shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(shape_panel);
    gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(gradient_panel);
    show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(show_edge_panel);
    arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(arrow_panel);

    e_color.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_color);
    e_labels.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_labels);

    // set up zoom controls
    zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>");
    zoom_at_mouse.addActionListener(this);
    zoom_at_mouse.setSelected(true);

    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, 1 / 1.1f, vv.getCenter());
        }
    });

    JPanel zoomPanel = new JPanel();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    plus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(plus);
    minus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(minus);
    zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(zoom_at_mouse);

    JPanel fontPanel = new JPanel();
    // add font and zoom controls to center panel
    font = new JCheckBox("bold text");
    font.addActionListener(this);
    font.setAlignmentX(Component.CENTER_ALIGNMENT);
    fontPanel.add(font);

    both_panel.add(zoomPanel);
    both_panel.add(fontPanel);

    JComboBox modeBox = gm.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    JPanel comboGrid = new JPanel(new GridLayout(0, 1));
    comboGrid.add(modePanel);
    fontPanel.add(comboGrid);

    JComboBox cb = new JComboBox();
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.NE);
    cb.addItem(Renderer.VertexLabel.Position.E);
    cb.addItem(Renderer.VertexLabel.Position.SE);
    cb.addItem(Renderer.VertexLabel.Position.S);
    cb.addItem(Renderer.VertexLabel.Position.SW);
    cb.addItem(Renderer.VertexLabel.Position.W);
    cb.addItem(Renderer.VertexLabel.Position.NW);
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.CNTR);
    cb.addItem(Renderer.VertexLabel.Position.AUTO);
    cb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem();
            vv.getRenderer().getVertexLabelRenderer().setPosition(position);
            vv.repaint();
        }
    });
    cb.setSelectedItem(Renderer.VertexLabel.Position.SE);
    JPanel positionPanel = new JPanel();
    positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position"));
    positionPanel.add(cb);

    comboGrid.add(positionPanel);

}