Example usage for javax.swing ButtonGroup ButtonGroup

List of usage examples for javax.swing ButtonGroup ButtonGroup

Introduction

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

Prototype

public ButtonGroup() 

Source Link

Document

Creates a new ButtonGroup.

Usage

From source file:se.llbit.chunky.renderer.ui.tabs.SkyTab.java

public SkyTab(RenderControls renderControls) {
    super(renderControls);

    JLabel skyModeLbl = new JLabel("Sky Mode:");
    skyModeCB.setModel(new DefaultComboBoxModel(Sky.SkyMode.values()));
    skyModeCB.addActionListener(skyModeListener);

    // Need to hide these to not warp the Swing layout:
    simulatedSkyPanel.setVisible(false);
    skymapPanel.setVisible(false);/*from www.jav a  2s  .c  om*/
    lightProbePanel.setVisible(false);
    skyGradientPanel.setVisible(false);
    skyboxPanel.setVisible(false);

    JLabel skymapRotationLbl = new JLabel("Skymap rotation:");
    skymapRotationSlider.setMinimum(1);
    skymapRotationSlider.setMaximum(100);
    skymapRotationSlider.addChangeListener(skyRotationListener);
    skymapRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    JLabel lightProbeRotationLbl = new JLabel("Skymap rotation:");
    lightProbeRotationSlider.setMinimum(1);
    lightProbeRotationSlider.setMaximum(100);
    lightProbeRotationSlider.addChangeListener(skyRotationListener);
    lightProbeRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    JLabel skyboxRotationLbl = new JLabel("Skybox rotation:");
    skyboxRotationSlider.setMinimum(1);
    skyboxRotationSlider.setMaximum(100);
    skyboxRotationSlider.addChangeListener(skyRotationListener);
    skyboxRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");

    JLabel verticalResolutionLbl = new JLabel("Vertical resolution (degrees):");
    ButtonGroup verticalResolution = new ButtonGroup();
    v90Btn.setSelected(true);
    v180Btn.setSelected(false);
    verticalResolution.add(v90Btn);
    verticalResolution.add(v180Btn);

    v90Btn.addActionListener(v90Listener);
    v180Btn.addActionListener(v180Listener);

    simulatedSkyPanel.setBorder(BorderFactory.createTitledBorder("Simulated Sky Settings"));
    GroupLayout simulatedSkyLayout = new GroupLayout(simulatedSkyPanel);
    simulatedSkyPanel.setLayout(simulatedSkyLayout);
    simulatedSkyLayout.setAutoCreateContainerGaps(true);
    simulatedSkyLayout.setAutoCreateGaps(true);
    simulatedSkyLayout.setHorizontalGroup(simulatedSkyLayout.createParallelGroup()
            .addGroup(skyHorizonOffset.horizontalGroup(simulatedSkyLayout)));
    simulatedSkyLayout.setVerticalGroup(simulatedSkyLayout.createSequentialGroup()
            .addGroup(skyHorizonOffset.verticalGroup(simulatedSkyLayout)));

    skymapPanel.setBorder(BorderFactory.createTitledBorder("Skymap Settings"));
    GroupLayout skymapLayout = new GroupLayout(skymapPanel);
    skymapPanel.setLayout(skymapLayout);
    skymapLayout.setAutoCreateContainerGaps(true);
    skymapLayout.setAutoCreateGaps(true);
    skymapLayout.setHorizontalGroup(skymapLayout.createParallelGroup().addComponent(loadSkymapBtn)
            .addGroup(skymapLayout.createSequentialGroup().addComponent(skymapRotationLbl)
                    .addComponent(skymapRotationSlider))
            .addGroup(skymapLayout.createSequentialGroup().addComponent(verticalResolutionLbl)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(v90Btn)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(v180Btn)));
    skymapLayout.setVerticalGroup(skymapLayout.createSequentialGroup().addComponent(loadSkymapBtn)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(skymapLayout.createParallelGroup(Alignment.BASELINE).addComponent(verticalResolutionLbl)
                    .addComponent(v90Btn).addComponent(v180Btn))
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(skymapLayout.createParallelGroup()
                    .addComponent(skymapRotationLbl).addComponent(skymapRotationSlider)));

    loadSkymapBtn.setText("Load Skymap");
    loadSkymapBtn.setToolTipText("Use a panoramic skymap");
    loadSkymapBtn.addActionListener(new SkymapTextureLoader(renderMan));

    lightProbePanel.setBorder(BorderFactory.createTitledBorder("Spherical Skymap Settings"));
    GroupLayout lightProbeLayout = new GroupLayout(lightProbePanel);
    lightProbePanel.setLayout(lightProbeLayout);
    lightProbeLayout.setAutoCreateContainerGaps(true);
    lightProbeLayout.setAutoCreateGaps(true);
    lightProbeLayout.setHorizontalGroup(lightProbeLayout.createParallelGroup().addComponent(loadLightProbeBtn)
            .addGroup(lightProbeLayout.createSequentialGroup().addComponent(lightProbeRotationLbl)
                    .addComponent(lightProbeRotationSlider)));
    lightProbeLayout.setVerticalGroup(lightProbeLayout.createSequentialGroup().addComponent(loadLightProbeBtn)
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(lightProbeLayout.createParallelGroup()
                    .addComponent(lightProbeRotationLbl).addComponent(lightProbeRotationSlider)));

    loadLightProbeBtn.setText("Load Spherical Skymap");
    loadLightProbeBtn.setToolTipText("Select the spherical skymap to use");
    loadLightProbeBtn.addActionListener(new SkymapTextureLoader(renderMan));

    skyGradientPanel.setBorder(BorderFactory.createTitledBorder("Sky Gradient"));
    gradientEditor = new GradientEditor();
    gradientEditor.addGradientListener(gradientListener);
    skyGradientPanel.add(gradientEditor);

    GroupLayout skyboxLayout = new GroupLayout(skyboxPanel);
    skyboxPanel.setLayout(skyboxLayout);
    skyboxPanel.setBorder(BorderFactory.createTitledBorder("Skybox"));

    JLabel skyboxLbl = new JLabel("Load skybox textures:");

    JButton loadUpTexture = new JButton("Up");
    loadUpTexture.setToolTipText("Load up texture");
    loadUpTexture.setIcon(Icon.skyboxUp.imageIcon());
    loadUpTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_UP));

    JButton loadDownTexture = new JButton("Down");
    loadDownTexture.setToolTipText("Load down texture");
    loadDownTexture.setIcon(Icon.skyboxDown.imageIcon());
    loadDownTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_DOWN));

    JButton loadFrontTexture = new JButton("Front");
    loadFrontTexture.setToolTipText("Load front (north) texture");
    loadFrontTexture.setIcon(Icon.skyboxFront.imageIcon());
    loadFrontTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_FRONT));

    JButton loadBackTexture = new JButton("Back");
    loadBackTexture.setToolTipText("Load back (south) texture");
    loadBackTexture.setIcon(Icon.skyboxBack.imageIcon());
    loadBackTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_BACK));

    JButton loadRightTexture = new JButton("Right");
    loadRightTexture.setToolTipText("Load right (east) texture");
    loadRightTexture.setIcon(Icon.skyboxRight.imageIcon());
    loadRightTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_RIGHT));

    JButton loadLeftTexture = new JButton("Left");
    loadLeftTexture.setToolTipText("Load left (west) texture");
    loadLeftTexture.setIcon(Icon.skyboxLeft.imageIcon());
    loadLeftTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_LEFT));

    skyboxLayout.setAutoCreateContainerGaps(true);
    skyboxLayout.setAutoCreateGaps(true);
    skyboxLayout.setHorizontalGroup(skyboxLayout.createParallelGroup()
            .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl)
                    .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture)
                            .addComponent(loadFrontTexture).addComponent(loadRightTexture))
                    .addGroup(skyboxLayout.createParallelGroup().addComponent(loadDownTexture)
                            .addComponent(loadBackTexture).addComponent(loadLeftTexture)))
            .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxRotationLbl)
                    .addComponent(skyboxRotationSlider)));
    skyboxLayout.setVerticalGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl)
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture)
                    .addComponent(loadDownTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadFrontTexture)
                    .addComponent(loadBackTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadRightTexture)
                    .addComponent(loadLeftTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(skyboxRotationLbl)
                    .addComponent(skyboxRotationSlider)));

    transparentSky.setText("transparent sky");
    transparentSky.setToolTipText("Disables rendering the skybox");
    transparentSky.addActionListener(transparentSkyListener);

    JLabel fogColorLbl = new JLabel(
            "<html>Hint: set fog density &gt; 0.1 for thick fog,<br>set it &lt; 0.1 for haze/atmosphere effect");
    fogColorBtn.setIcon(Icon.colors.imageIcon());
    fogColorBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ColorPicker picker = new ColorPicker(fogColorBtn, renderMan.scene().getFogColor());
            picker.addColorListener(new ColorListener() {
                @Override
                public void onColorPicked(Vector3d color) {
                    renderMan.scene().setFogColor(color);
                }
            });
        }
    });

    cloudsEnabled.setText("enable clouds");
    cloudsEnabled.addActionListener(cloudsEnabledListener);

    GroupLayout layout = new GroupLayout(this);
    setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
            .createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(skyModeLbl)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(skyModeCB,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
            .addComponent(simulatedSkyPanel).addComponent(skymapPanel).addComponent(lightProbePanel)
            .addComponent(skyGradientPanel).addComponent(skyboxPanel).addComponent(transparentSky)
            .addComponent(cloudsEnabled).addGroup(cloudSize.horizontalGroup(layout))
            .addGroup(cloudXOffset.horizontalGroup(layout)).addGroup(cloudYOffset.horizontalGroup(layout))
            .addGroup(cloudZOffset.horizontalGroup(layout)).addGroup(fogDensity.horizontalGroup(layout))
            .addGroup(layout.createSequentialGroup().addComponent(fogColorBtn)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(fogColorLbl)))
            .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(skyModeLbl)
                    .addComponent(skyModeCB))
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(simulatedSkyPanel)
            .addComponent(skymapPanel).addComponent(lightProbePanel).addComponent(skyGradientPanel)
            .addComponent(skyboxPanel).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(transparentSky).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(cloudsEnabled).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudSize.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudXOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudYOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudZOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(fogDensity.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup().addComponent(fogColorBtn).addComponent(fogColorLbl))
            .addContainerGap());
}

From source file:se.streamsource.streamflow.client.ui.workspace.cases.general.forms.geo.GeoLocationFieldPanel.java

private JPanel createModeButtonPanel() {
    modeButtonGroup = new ButtonGroup();
    FormLayout layout = new FormLayout("pref:grow", "pref, pref, pref");
    PanelBuilder builder = new PanelBuilder(layout);

    if (fieldValue.point().get()) {
        JToggleButton selectPointButton = new StreamflowToggleButton(getActionMap().get("startPointSelection"));
        modeButtonGroup.add(selectPointButton);
        builder.add(selectPointButton);/*from   www  . j  a  va  2  s.  c o m*/
        builder.nextRow();
    }

    if (fieldValue.polyline().get()) {
        JToggleButton selectLineButton = new StreamflowToggleButton(getActionMap().get("startLineSelection"));
        modeButtonGroup.add(selectLineButton);
        builder.add(selectLineButton);
        builder.nextRow();
    }

    if (fieldValue.polygon().get()) {
        JToggleButton selectPolygonButton = new StreamflowToggleButton(
                getActionMap().get("startAreaSelection"));
        modeButtonGroup.add(selectPolygonButton);
        builder.add(selectPolygonButton);
        builder.nextRow();
    }

    return builder.getPanel();
}

From source file:sim.graph.MyPluggableRendererDemo.java

/**
 * @param jp    panel to which controls will be added
 */// w w w .j ava 2  s  . co m
protected void addBottomControls(/*final JPanel jp*/) {
    /*final JPanel*/ control_panel = new JPanel();
    //        jp.add(control_panel, BorderLayout.SOUTH);
    //        control_panel.setLayout(new BorderLayout());
    control_panel.setLayout(new FlowLayout());
    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("dimer coloring");
    v_color.addActionListener(this);
    v_stroke = new JCheckBox("<html>vertex selection<p>stroke highlighting</html>");
    v_stroke.addActionListener(this);
    v_labels = new JCheckBox("show vertex ranks (voltages)");
    v_labels.addActionListener(this);
    v_shape = new JCheckBox("vertex degree shapes");
    v_shape.addActionListener(this);
    v_size = new JCheckBox("vertex voltage size");
    v_size.addActionListener(this);
    v_size.setSelected(true);
    v_aspect = new JCheckBox("vertex degree ratio stretch");
    v_aspect.addActionListener(this);
    v_small = new JCheckBox("filter vertices of 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);
    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(this);
    shape_panel.add(fill_edges);
    shape_panel.setOpaque(true);
    e_color = new JCheckBox("edge weight highlighting");
    e_color.addActionListener(this);
    e_labels = new JCheckBox("show edge weights");
    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);
    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.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);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(visViewer, 1.1f, visViewer.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(visViewer, 1 / 1.1f, visViewer.getCenter());
        }
    });

    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(this);
    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:StockForecast.Main.java

private void groupButtonProfile() {
    ButtonGroup bg1 = new ButtonGroup();
    bg1.add(jRadioButton1);
    bg1.add(jRadioButton2);
}

From source file:StockForecast.Main.java

private void groupButtonStock() {
    ButtonGroup bg1 = new ButtonGroup();
    bg1.add(jRadioButton3);
    bg1.add(jRadioButton4);
}

From source file:test.visualization.PluggableRendererDemo.java

/**
 * @param jp    panel to which controls will be added
 *//*from  w ww .j av  a  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);
    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.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:tvbrowser.extras.favoritesplugin.wizards.TypeWizardStep.java

public JPanel createContent(final WizardHandler handler) {

    LinkButton expertBtn = new LinkButton(mLocalizer.msg("advancedView", "Switch to expert view"), null);

    CellConstraints cc = new CellConstraints();
    PanelBuilder panelBuilder = new PanelBuilder(
            new FormLayout("5dlu, pref, default:grow", "pref, 5dlu, pref, 5dlu, pref, 5dlu, pref, 5dlu, pref"));

    panelBuilder.add(new JLabel(mMainQuestion), cc.xyw(1, 1, 3));
    panelBuilder.add(mTitleRb = new JRadioButton(mLocalizer.msg("option.title", "I like this program:")),
            cc.xy(2, 3));/*w ww.  j a v a2s  .c o m*/
    panelBuilder.add(mProgramNameTf = new JTextField(), cc.xy(3, 3));
    panelBuilder.add(mTopicRb = new JRadioButton(mLocalizer.msg("option.topic", "I like this subject:")),
            cc.xy(2, 5));
    panelBuilder.add(mTopicTf = new JTextField(), cc.xy(3, 5));

    panelBuilder.add(mActorsRb = new JRadioButton(mLocalizer.msg("option.actors", "I like these actors:")),
            cc.xy(2, 7));
    mActorsCb = new JComboBox();
    mActorsCb.setEditable(true);
    panelBuilder.add(mActorsCb, cc.xy(3, 7));
    panelBuilder.setBorder(Borders.DLU4_BORDER);
    panelBuilder.add(expertBtn, cc.xyw(1, 9, 3));
    ButtonGroup group = new ButtonGroup();
    group.add(mTitleRb);
    group.add(mTopicRb);
    group.add(mActorsRb);

    mTitleRb.setSelected(true);

    updateTextfields();

    mTitleRb.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateTextfields();
        }
    });

    mTopicRb.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateTextfields();
        }
    });

    mActorsRb.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateTextfields();
        }
    });

    expertBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            handler.closeCurrentStep();
            String title;
            if (mProgram != null) {
                title = mProgram.getTitle();
            } else {
                title = "";
            }
            AdvancedFavorite favorite = new AdvancedFavorite(title);
            Window parent = UiUtilities.getLastModalChildOf(MainFrame.getInstance());
            EditFavoriteDialog dlg = new EditFavoriteDialog(parent, favorite);
            UiUtilities.centerAndShow(dlg);
            if (dlg.getOkWasPressed()) {
                FavoriteTreeModel.getInstance().addFavorite(favorite, mParentNode);
                FavoritesPlugin.getInstance().updateRootNode(true);

                if (ManageFavoritesDialog.getInstance() != null) {
                    ManageFavoritesDialog.getInstance().addFavorite(favorite, false);
                }
            }
        }
    });

    if (mProgram != null) {
        mProgramNameTf.setText(mProgram.getTitle());
        String[] actors = ProgramUtilities.getActorNames(mProgram);
        if (actors != null) {
            for (String actor : actors) {
                mActorsCb.addItem(actor);
            }
        }
    }

    mContent = panelBuilder.getPanel();

    mContent.addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            handleFocusEvent();
        }
    });

    mContent.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            handleFocusEvent();
        }
    });

    if (mTopic != null) {
        mTopicRb.setSelected(true);
        updateTextfields();
        mTopicTf.setText(mTopic);
        // the topic might also be an actor name
        if (mActor == null && ProgramUtilities.getActorNames(mProgram) == null) {
            mActorsCb.setSelectedItem(mTopic);
        }
    } else if (mActor != null) {
        mActorsRb.setSelected(true);
        updateTextfields();
        mActorsCb.setSelectedItem(mActor);
    }

    return mContent;
}

From source file:tvbrowser.extras.reminderplugin.ReminderSettingsTab.java

/**
 * Creates the settings panel for this tab.
 *///from   w  w w .j a va 2s .c  om
public JPanel createSettingsPanel() {
    FormLayout layout = new FormLayout("5dlu,pref,5dlu,pref,pref:grow,3dlu,pref,3dlu,pref,5dlu",
            "pref,5dlu,pref,1dlu,pref,1dlu,pref,1dlu,pref,10dlu,pref,5dlu,"
                    + "pref,10dlu,pref,5dlu,pref,10dlu,pref,5dlu,pref,10dlu,"
                    + "pref,5dlu,pref,3dlu,pref,10dlu,pref,5dlu,pref");
    layout.setColumnGroups(new int[][] { { 7, 9 } });
    PanelBuilder pb = new PanelBuilder(layout, new ScrollableJPanel());
    pb.setDefaultDialogBorder();

    CellConstraints cc = new CellConstraints();

    final String[] extArr = { ".wav", ".aif", ".rmf", ".au", ".mid" };
    String soundFName = mSettings.getProperty("soundfile", "/");
    String msg = mLocalizer.msg("soundFileFilter", "Sound file ({0})", "*" + StringUtils.join(extArr, ", *"));

    mReminderWindowChB = new JCheckBox(mLocalizer.msg("reminderWindow", "Reminder window"),
            mSettings.getProperty("usemsgbox", "false").equalsIgnoreCase("true"));

    mShowAlwaysOnTop = new JCheckBox(mLocalizer.msg("alwaysOnTop", "Show always on top"),
            mSettings.getProperty("alwaysOnTop", "true").equalsIgnoreCase("true"));
    mShowAlwaysOnTop.setEnabled(mReminderWindowChB.isSelected());

    JPanel reminderWindowCfg = new JPanel(new FormLayout("12dlu,default:grow", "pref,1dlu,pref"));
    reminderWindowCfg.add(mReminderWindowChB, cc.xyw(1, 1, 2));
    reminderWindowCfg.add(mShowAlwaysOnTop, cc.xy(2, 3));

    mSoundFileChB = new FileCheckBox(mLocalizer.msg("playlingSound", "Play sound"), new File(soundFName), 0,
            false);

    JFileChooser soundChooser = new JFileChooser((String) null);
    soundChooser.setFileFilter(new ExtensionFileFilter(extArr, msg));

    mSoundFileChB.setFileChooser(soundChooser);

    mSoundFileChB.setSelected(mSettings.getProperty("usesound", "false").equals("true"));

    mBeep = new JCheckBox(mLocalizer.msg("beep", "Speaker sound"),
            mSettings.getProperty("usebeep", "true").equalsIgnoreCase("true"));

    mExecFileStr = mSettings.getProperty("execfile", "");
    mExecParamStr = mSettings.getProperty("execparam", "");

    final JButton soundTestBt = new JButton(mLocalizer.msg("test", "Test"));

    mExecChB = new JCheckBox(mLocalizer.msg("executeProgram", "Execute program"));
    mExecChB.setSelected(mSettings.getProperty("useexec", "false").equals("true"));

    mExecFileDialogBtn = new JButton(mLocalizer.msg("executeConfig", "Configure"));
    mExecFileDialogBtn.setEnabled(mExecChB.isSelected());

    mPluginLabel = new JLabel();
    JButton choose = new JButton(mLocalizer.msg("selectPlugins", "Choose Plugins"));

    mClientPluginTargets = ReminderPlugin.getInstance().getClientPluginsTargets();

    handlePluginSelection();

    choose.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Window parent = UiUtilities.getLastModalChildOf(MainFrame.getInstance());
                PluginChooserDlg chooser = null;
                chooser = new PluginChooserDlg(parent, mClientPluginTargets, null,
                        ReminderPluginProxy.getInstance());

                chooser.setLocationRelativeTo(parent);
                chooser.setVisible(true);

                if (chooser.getReceiveTargets() != null) {
                    mClientPluginTargets = chooser.getReceiveTargets();
                }

                handlePluginSelection();
            } catch (Exception ee) {
                ee.printStackTrace();
            }
        }
    });

    int autoCloseReminderTime = 10;
    try {
        String asString = mSettings.getProperty("autoCloseReminderTime", "10");
        autoCloseReminderTime = Integer.parseInt(asString);

        if (autoCloseReminderTime == 0) {
            autoCloseReminderTime = 10;
        }
    } catch (Exception exc) {
        // ignore
    }

    mCloseOnEnd = new JRadioButton(mLocalizer.msg("autoCloseReminderAtProgramEnd", "Program end"),
            mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("onEnd"));
    mCloseOnEnd.setEnabled(mReminderWindowChB.isSelected());

    mCloseNever = new JRadioButton(mLocalizer.msg("autoCloseNever", "Never close"),
            mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("never"));
    mCloseNever.setEnabled(mReminderWindowChB.isSelected());

    mCloseOnTime = new JRadioButton(mLocalizer.ellipsisMsg("autoCloseAfterTime", "After time"),
            mSettings.getProperty("autoCloseBehaviour", "onEnd").equals("onTime"));
    mCloseOnTime.setEnabled(mReminderWindowChB.isSelected());

    ButtonGroup bg = new ButtonGroup();

    bg.add(mCloseOnEnd);
    bg.add(mCloseNever);
    bg.add(mCloseOnTime);

    mAutoCloseReminderTimeSp = new JSpinner(
            new SpinnerNumberModel(autoCloseReminderTime, autoCloseReminderTime < 5 ? 1 : 5, 600, 1));
    mAutoCloseReminderTimeSp.setEnabled(mCloseOnTime.isSelected() && mReminderWindowChB.isSelected());

    mShowTimeCounter = new JCheckBox(mLocalizer.msg("showTimeCounter", "Show time counter"),
            mSettings.getProperty("showTimeCounter", "false").compareTo("true") == 0);
    mShowTimeCounter.setEnabled(!mCloseNever.isSelected() && mReminderWindowChB.isSelected());

    PanelBuilder autoClosePanel = new PanelBuilder(
            new FormLayout("12dlu,default,2dlu,default:grow", "pref,2dlu,pref,2dlu,pref,2dlu,pref,10dlu,pref"));
    autoClosePanel.add(mCloseOnEnd, cc.xyw(1, 1, 4));
    autoClosePanel.add(mCloseNever, cc.xyw(1, 3, 4));
    autoClosePanel.add(mCloseOnTime, cc.xyw(1, 5, 4));
    autoClosePanel.add(mAutoCloseReminderTimeSp, cc.xy(2, 7));

    final JLabel secondsLabel = autoClosePanel.addLabel(mLocalizer.msg("seconds", "seconds (0 = off)"),
            cc.xy(4, 7));

    autoClosePanel.add(mShowTimeCounter, cc.xyw(1, 9, 4));

    secondsLabel.setEnabled(mCloseOnTime.isSelected() && mReminderWindowChB.isSelected());

    String defaultReminderEntryStr = (String) mSettings.get("defaultReminderEntry");
    mDefaultReminderEntryList = new JComboBox(ReminderDialog.SMALL_REMIND_MSG_ARR);
    if (defaultReminderEntryStr != null) {
        try {
            int inx = Integer.parseInt(defaultReminderEntryStr);
            if (inx < ReminderDialog.SMALL_REMIND_MSG_ARR.length) {
                mDefaultReminderEntryList.setSelectedIndex(inx);
            }
        } catch (NumberFormatException e) {
            // ignore
        }
    }

    mShowTimeSelectionDlg = new JCheckBox(
            mLocalizer.msg("showTimeSelectionDialog", "Show time selection dialog"));
    mShowTimeSelectionDlg
            .setSelected(mSettings.getProperty("showTimeSelectionDialog", "true").compareTo("true") == 0);
    mShowRemovedDlg = new JCheckBox(
            mLocalizer.msg("showRemovedDialog", "Show removed reminders after data update"));
    mShowRemovedDlg.setSelected(mSettings.getProperty("showRemovedDialog", "true").compareTo("true") == 0);

    pb.addSeparator(mLocalizer.msg("remindBy", "Remind me by"), cc.xyw(1, 1, 10));

    pb.add(reminderWindowCfg, cc.xyw(2, 3, 4));
    pb.add(mSoundFileChB, cc.xyw(2, 5, 4));
    pb.add(mSoundFileChB.getButton(), cc.xy(7, 5));
    pb.add(soundTestBt, cc.xy(9, 5));
    pb.add(mBeep, cc.xy(2, 7));
    pb.add(mExecChB, cc.xyw(2, 9, 4));
    pb.add(mExecFileDialogBtn, cc.xyw(7, 9, 3));

    pb.addSeparator(mLocalizer.msg("sendToPlugin", "Send reminded program to"), cc.xyw(1, 11, 10));

    pb.add(mPluginLabel, cc.xyw(2, 13, 4));
    pb.add(choose, cc.xyw(7, 13, 3));

    final JLabel c = (JLabel) pb
            .addSeparator(mLocalizer.msg("autoCloseReminder", "Automatically close reminder"),
                    cc.xyw(1, 15, 10))
            .getComponent(0);
    c.setEnabled(mReminderWindowChB.isSelected());

    pb.add(autoClosePanel.getPanel(), cc.xyw(2, 17, 5));

    JPanel reminderEntry = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    reminderEntry.add(mDefaultReminderEntryList);

    pb.addSeparator(mLocalizer.msg("defaltReminderEntry", "Default reminder time"), cc.xyw(1, 19, 10));
    pb.add(reminderEntry, cc.xyw(2, 21, 4));

    pb.addSeparator(mLocalizer.msg("miscSettings", "Misc settings"), cc.xyw(1, 23, 10));
    pb.add(mShowTimeSelectionDlg, cc.xyw(2, 25, 7));
    pb.add(mShowRemovedDlg, cc.xyw(2, 27, 7));

    pb.addSeparator(DefaultMarkingPrioritySelectionPanel.getTitle(), cc.xyw(1, 29, 10));
    pb.add(mMarkingsPanel = DefaultMarkingPrioritySelectionPanel
            .createPanel(ReminderPlugin.getInstance().getMarkPriority(), false, false), cc.xyw(2, 31, 9));

    mReminderWindowChB.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            mShowAlwaysOnTop.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            c.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            secondsLabel.setEnabled(e.getStateChange() == ItemEvent.SELECTED && mCloseOnTime.isSelected());
            mCloseOnEnd.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            mCloseNever.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            mCloseOnTime.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            mShowTimeCounter.setEnabled(e.getStateChange() == ItemEvent.SELECTED && !mCloseNever.isSelected());
            mAutoCloseReminderTimeSp
                    .setEnabled(e.getStateChange() == ItemEvent.SELECTED && mCloseOnTime.isSelected());
        }
    });

    soundTestBt.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (evt.getActionCommand().compareTo(mLocalizer.msg("test", "Test")) == 0) {
                mTestSound = ReminderPlugin.playSound(mSoundFileChB.getTextField().getText());
                if (mTestSound != null) {
                    soundTestBt.setText(mLocalizer.msg("stop", "Stop"));
                }
                if (mTestSound != null) {
                    if (mTestSound instanceof SourceDataLine) {
                        ((SourceDataLine) mTestSound).addLineListener(new LineListener() {
                            public void update(LineEvent event) {
                                if (event.getType() == Type.CLOSE) {
                                    soundTestBt.setText(mLocalizer.msg("test", "Test"));
                                }
                            }
                        });
                    } else if (mTestSound instanceof Sequencer) {
                        new Thread("Test MIDI sound") {
                            public void run() {
                                setPriority(Thread.MIN_PRIORITY);
                                while (((Sequencer) mTestSound).isRunning()) {
                                    try {
                                        Thread.sleep(100);
                                    } catch (Exception ee) {
                                    }
                                }

                                soundTestBt.setText(mLocalizer.msg("test", "Test"));
                            }
                        }.start();
                    }
                }
            } else if (mTestSound != null) {
                if (mTestSound instanceof SourceDataLine && ((SourceDataLine) mTestSound).isRunning()) {
                    ((SourceDataLine) mTestSound).stop();
                } else if (mTestSound instanceof Sequencer && ((Sequencer) mTestSound).isRunning()) {
                    ((Sequencer) mTestSound).stop();
                }
            }
        }
    });

    mSoundFileChB.getCheckBox().addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            soundTestBt.setEnabled(mSoundFileChB.isSelected());
        }
    });

    mSoundFileChB.getTextField().addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            String text = mSoundFileChB.getTextField().getText();
            if ((new File(text)).isFile()) {
                boolean notFound = true;
                for (String extension : extArr) {
                    if (StringUtils.endsWithIgnoreCase(text, extension)) {
                        notFound = false;
                        break;
                    }
                }

                if (notFound) {
                    soundTestBt.setEnabled(false);
                } else {
                    soundTestBt.setEnabled(true);
                }
            } else {
                soundTestBt.setEnabled(false);
            }
        }
    });
    mSoundFileChB.getTextField().getKeyListeners()[0].keyReleased(null);

    mExecChB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            mExecFileDialogBtn.setEnabled(mExecChB.isSelected());
            if (mExecFileDialogBtn.isEnabled()) {
                showFileSettingsDialog();
            }
        }
    });

    mExecFileDialogBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            showFileSettingsDialog();
        }
    });

    ItemListener autoCloseListener = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            mAutoCloseReminderTimeSp.setEnabled(mCloseOnTime.isSelected());
            secondsLabel.setEnabled(mCloseOnTime.isSelected());
            mShowTimeCounter.setEnabled(mCloseOnTime.isSelected() || mCloseOnEnd.isSelected());
        }
    };

    mCloseOnEnd.addItemListener(autoCloseListener);
    mCloseOnTime.addItemListener(autoCloseListener);

    mCloseOnTime.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            mShowTimeCounter.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    JScrollPane scrollPane = new JScrollPane(pb.getPanel());
    scrollPane.setBorder(null);
    scrollPane.setViewportBorder(null);

    JPanel scrollPanel = new JPanel(new FormLayout("default:grow", "default"));
    scrollPanel.add(scrollPane, cc.xy(1, 1));

    return scrollPanel;
}

From source file:tvbrowser.ui.settings.WebbrowserSettingsTab.java

/**
 * Creates the settings panel for this tab.
 *//*from   w w  w.j av a  2s  .  co m*/
public JPanel createSettingsPanel() {
    mSettingsPn = new JPanel(new FormLayout("5dlu, 10dlu, pref, 3dlu, pref, 3dlu, pref, fill:3dlu:grow, 3dlu",
            "pref, 5dlu, pref, 5dlu, pref, 5dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref"));
    mSettingsPn.setBorder(Borders.DIALOG_BORDER);

    CellConstraints cc = new CellConstraints();

    mSettingsPn.add(
            DefaultComponentFactory.getInstance().createSeparator(mLocalizer.msg("browser", "Web browser")),
            cc.xyw(1, 1, 9));

    JButton testButton = new LinkButton(mLocalizer.msg("testBrowser", "Test Webbrowser"),
            "http://www.tvbrowser.org", SwingConstants.LEFT, false);
    testButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String buffer = Settings.propUserDefinedWebbrowser.getString();
            String bufferParams = Settings.propUserDefinedWebbrowserParams.getString();
            saveSettings();
            Launch.openURL("http://www.tvbrowser.org");
            Settings.propUserDefinedWebbrowser.setString(buffer);
            Settings.propUserDefinedWebbrowserParams.setString(bufferParams);
        }
    });

    mSettingsPn.add(UiUtilities.createHelpTextArea(mLocalizer.msg("help", "Help Text")), cc.xyw(2, 3, 7));

    mSettingsPn.add(testButton, cc.xyw(2, 5, 7));

    mSettingsPn.add(new JLabel(mLocalizer.msg("whichBrowser", "which browser")), cc.xyw(2, 7, 7));

    JRadioButton useDefault = new JRadioButton(mLocalizer.msg("defaultWebbrowser", "Default Webbrowser"));
    useDefault.setSelected(Settings.propUserDefinedWebbrowser.getString() == null);
    useDefault.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateInputFields();
        }
    });

    mSettingsPn.add(useDefault, cc.xyw(2, 9, 4));

    mUseWebbrowser = new JRadioButton(mLocalizer.msg("userDefinedWebbrowser", "user defined webbrowser"));
    mUseWebbrowser.setSelected(Settings.propUserDefinedWebbrowser.getString() != null);

    mUseWebbrowser.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateInputFields();
        }
    });

    ButtonGroup group = new ButtonGroup();
    group.add(useDefault);
    group.add(mUseWebbrowser);

    mSettingsPn.add(mUseWebbrowser, cc.xyw(2, 11, 7));

    mSettingsPn.add(new JLabel(mLocalizer.msg("browserExecutable", "Executable") + ":"), cc.xy(3, 13));

    mFileTextField = new JTextField(30);
    mFileTextField.setText(Settings.propUserDefinedWebbrowser.getString());
    mSettingsPn.add(mFileTextField, cc.xy(5, 13));

    mChooseButton = new JButton(Localizer.getLocalization(Localizer.I18N_SELECT));
    mChooseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            if (mFileChooser == null) {
                mFileChooser = new JFileChooser();

                if (OperatingSystem.isMacOs()) {
                    mFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
                } else {
                    mFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
                }
            }

            int retVal = mFileChooser.showOpenDialog(mSettingsPn.getParent());
            if (retVal == JFileChooser.APPROVE_OPTION) {
                File f = mFileChooser.getSelectedFile();
                if (f != null) {
                    mFileTextField.setText(f.getAbsolutePath());
                }
            }
        }
    });
    mSettingsPn.add(mChooseButton, cc.xy(7, 13));

    mSettingsPn.add(new JLabel(mLocalizer.msg("browserParameter", "Parameter") + ":"), cc.xy(3, 15));

    mParams = new JTextField();
    mParams.setText(Settings.propUserDefinedWebbrowserParams.getString());
    mSettingsPn.add(mParams, cc.xy(5, 15));

    mSettingsPn.add(new JLabel(mLocalizer.msg("browserParameterHelp", "{0} will be replaced by the url.")),
            cc.xyw(5, 17, 4));

    updateInputFields();

    return mSettingsPn;
}