Example usage for java.awt.event ItemListener ItemListener

List of usage examples for java.awt.event ItemListener ItemListener

Introduction

In this page you can find the example usage for java.awt.event ItemListener ItemListener.

Prototype

ItemListener

Source Link

Usage

From source file:demos.TreeCollapse.java

@SuppressWarnings("unchecked")
public TreeCollapse() {

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

    createTree();// w  w  w . ja  va2  s.  c  om

    layout = new TreeLayout<String, Integer>(graph);
    collapser = new TreeCollapser();

    radialLayout = new RadialTreeLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(600, 600));
    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());
    vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings();

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

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

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

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

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

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                //               layout.setRadial(true);
                vv.setGraphLayout(radialLayout);
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                //               layout.setRadial(false);
                vv.setGraphLayout(layout);
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });

    JButton collapse = new JButton("Collapse");
    collapse.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection<?> picked = new HashSet<Object>(vv.getPickedVertexState().getPicked());
            if (picked.size() == 1) {
                Object root = picked.iterator().next();
                Forest<?, ?> inGraph = (Forest<?, ?>) layout.getGraph();

                try {
                    collapser.collapse(vv.getGraphLayout(), inGraph, root);
                } catch (InstantiationException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IllegalAccessException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    JButton expand = new JButton("Expand");
    expand.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = vv.getPickedVertexState().getPicked();
            for (Object v : picked) {
                if (v instanceof Forest) {
                    Forest inGraph = (Forest) layout.getGraph();
                    collapser.expand(inGraph, (Forest) v);
                }
                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    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);
    controls.add(collapse);
    controls.add(expand);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:zodicSign.treeLayout.java

@SuppressWarnings("unchecked")
public treeLayout() {

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

    createTree();//from   w  w  w . j  a va2 s  .  c  o  m

    layout = new TreeLayout<String, Integer>(graph);
    collapser = new TreeCollapser();

    radialLayout = new RadialTreeLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(600, 600));
    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());
    vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings();

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

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

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

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

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

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                //               layout.setRadial(true);
                vv.setGraphLayout(radialLayout);
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                //               layout.setRadial(false);
                vv.setGraphLayout(layout);
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });

    JButton collapse = new JButton("Collapse");
    collapse.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
            if (picked.size() == 1) {
                Object root = picked.iterator().next();
                Forest inGraph = (Forest) layout.getGraph();

                try {
                    collapser.collapse(vv.getGraphLayout(), inGraph, root);
                } catch (InstantiationException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IllegalAccessException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    JButton expand = new JButton("Expand");
    expand.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = vv.getPickedVertexState().getPicked();
            for (Object v : picked) {
                if (v instanceof Forest) {
                    Forest inGraph = (Forest) layout.getGraph();
                    collapser.expand(inGraph, (Forest) v);
                }
                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    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);
    controls.add(collapse);
    controls.add(expand);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:op.care.med.structure.DlgProduct.java

/**
 * This method is called from within the constructor to
 * initialize the form./*from w  w w  .  j av a 2s.  com*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc=" Erzeugter Quelltext ">//GEN-BEGIN:initComponents
private void initComponents() {
    lblProductName = new JLabel();
    txtName = new JTextField();
    cmbAcme = new JComboBox<>();
    lblAcme = new JLabel();
    btnAdd = new JButton();
    lblSideEffects = new JLabel();
    scrollPane1 = new JScrollPane();
    txtSideEffects = new JTextArea();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnOK = new JButton();

    //======== this ========
    setModal(true);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("2*(default, $lcgap), default:grow, 2*($lcgap, default)",
            "default, 2*($lgap, fill:default), $lgap, fill:default:grow, $lgap, fill:default, $lgap, default"));

    //---- lblProductName ----
    lblProductName.setText("Produktname");
    lblProductName.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(lblProductName, CC.xy(3, 3));

    //---- txtName ----
    txtName.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(txtName, CC.xywh(5, 3, 3, 1));

    //---- cmbAcme ----
    cmbAcme.setModel(
            new DefaultComboBoxModel<>(new String[] { "Eintrag 1", "Eintrag 2", "Eintrag 3", "Eintrag 4" }));
    cmbAcme.setFont(new Font("Arial", Font.PLAIN, 14));
    cmbAcme.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            cmbAcmeItemStateChanged(e);
        }
    });
    contentPane.add(cmbAcme, CC.xy(5, 5));

    //---- lblAcme ----
    lblAcme.setText("Hersteller");
    lblAcme.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(lblAcme, CC.xy(3, 5));

    //---- btnAdd ----
    btnAdd.setText(null);
    btnAdd.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
    btnAdd.setContentAreaFilled(false);
    btnAdd.setBorder(null);
    btnAdd.setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
    btnAdd.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    btnAdd.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnAddActionPerformed(e);
        }
    });
    contentPane.add(btnAdd, CC.xy(7, 5, CC.LEFT, CC.DEFAULT));

    //---- lblSideEffects ----
    lblSideEffects.setText("Hersteller");
    lblSideEffects.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(lblSideEffects, CC.xy(3, 7, CC.DEFAULT, CC.TOP));

    //======== scrollPane1 ========
    {

        //---- txtSideEffects ----
        txtSideEffects.setFont(new Font("Arial", Font.PLAIN, 14));
        scrollPane1.setViewportView(txtSideEffects);
    }
    contentPane.add(scrollPane1, CC.xywh(5, 7, 3, 1));

    //======== panel1 ========
    {
        panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));

        //---- btnCancel ----
        btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/16x16/cancel.png")));
        btnCancel.setText(null);
        btnCancel.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnCancelActionPerformed(e);
            }
        });
        panel1.add(btnCancel);

        //---- btnOK ----
        btnOK.setIcon(new ImageIcon(getClass().getResource("/artwork/16x16/apply.png")));
        btnOK.setText(null);
        btnOK.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnOKActionPerformed(e);
            }
        });
        panel1.add(btnOK);
    }
    contentPane.add(panel1, CC.xywh(5, 9, 3, 1, CC.RIGHT, CC.DEFAULT));
    setSize(585, 285);
    setLocationRelativeTo(null);
}

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPDefaultsGui.java

private void init() {
    setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());//from ww w . j  a v  a  2 s. co  m

    add(makeTitlePanel(), BorderLayout.NORTH);

    urlConfig = new UPMPUrlConfigGui(false, true, false);
    add(urlConfig, BorderLayout.CENTER);

    // OPTIONAL TASKS
    final JPanel optionalTasksPanel = new VerticalPanel();
    optionalTasksPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            JMeterUtils.getResString("optional_tasks"))); // $NON-NLS-1$

    final JPanel checkBoxPanel = new HorizontalPanel();
    imageParser = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$
    checkBoxPanel.add(imageParser);
    imageParser.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                enableConcurrentDwn(true);
            } else {
                enableConcurrentDwn(false);
            }
        }
    });
    // Concurrent resources download
    concurrentDwn = new JCheckBox(JMeterUtils.getResString("web_testing_concurrent_download")); // $NON-NLS-1$
    concurrentDwn.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (imageParser.isSelected() && e.getStateChange() == ItemEvent.SELECTED) {
                concurrentPool.setEnabled(true);
            } else {
                concurrentPool.setEnabled(false);
            }
        }
    });
    concurrentPool = new JTextField(2); // 2 columns size
    concurrentPool.setMaximumSize(new Dimension(30, 20));
    checkBoxPanel.add(concurrentDwn);
    checkBoxPanel.add(concurrentPool);
    optionalTasksPanel.add(checkBoxPanel);

    // Embedded URL match regex
    embeddedRE = new JLabeledTextField(JMeterUtils.getResString("web_testing_embedded_url_pattern"), 30); // $NON-NLS-1$
    optionalTasksPanel.add(embeddedRE);

    add(optionalTasksPanel, BorderLayout.SOUTH);
}

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

@SuppressWarnings("unchecked")
public TreeCollapseDemo() {

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

    createTree();/*from www.j  a va 2 s. c o  m*/

    layout = new TreeLayout<String, Integer>(graph);
    collapser = new TreeCollapser();

    radialLayout = new RadialTreeLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(600, 600));
    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());
    vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings();

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

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

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

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

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

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                //               layout.setRadial(true);
                vv.setGraphLayout(radialLayout);
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                //               layout.setRadial(false);
                vv.setGraphLayout(layout);
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });

    JButton collapse = new JButton("Collapse");
    collapse.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
            if (picked.size() == 1) {
                Object root = picked.iterator().next();
                Forest inGraph = (Forest) layout.getGraph();

                try {
                    collapser.collapse(vv.getGraphLayout(), inGraph, root);
                } catch (InstantiationException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IllegalAccessException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    JButton expand = new JButton("Expand");
    expand.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = vv.getPickedVertexState().getPicked();
            for (Object v : picked) {
                if (v instanceof Forest) {
                    Forest inGraph = (Forest) layout.getGraph();
                    collapser.expand(inGraph, (Forest) v);
                }
                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    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);
    controls.add(collapse);
    controls.add(expand);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:jung.test.TreeLayoutDemo.java

public TreeLayoutDemo() {

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

    createTree();/* w  w  w  .j  av a2  s. co  m*/

    treeLayout = new TreeLayout<String, DefaultWeightedEdge>(graph);
    radialLayout = new RadialTreeLayout<String, DefaultWeightedEdge>(graph);
    radialLayout.setSize(new Dimension(600, 600));
    vv = new VisualizationViewer<String, DefaultWeightedEdge>(treeLayout, 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 Rings();

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

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

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

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

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

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

                LayoutTransition<String, DefaultWeightedEdge> lt = new LayoutTransition<String, DefaultWeightedEdge>(
                        vv, treeLayout, radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                LayoutTransition<String, DefaultWeightedEdge> lt = new LayoutTransition<String, DefaultWeightedEdge>(
                        vv, radialLayout, treeLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });

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

From source file:de.tor.tribes.ui.views.DSWorkbenchTroopsFrame.java

/**
 * Creates new form DSWorkbenchTroopsFrame
 *//*from w  ww  . j  a  v  a  2  s . c o m*/
DSWorkbenchTroopsFrame() {
    initComponents();

    centerPanel = new GenericTestPanel(true);
    jTroopsPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jXTroopsPanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this);

    jTroopsTabPane.getModel().addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            TroopTableTab activeTab = getActiveTab();
            if (activeTab != null) {
                activeTab.updateSet();
            }
        }
    });

    DataHolder.getSingleton().addDataHolderListener(DSWorkbenchTroopsFrame.this);

    jXGroupsList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            updateFilter();
        }
    });

    jTroopAddTribe.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateTroopAddVillageList();
            }
        }
    });
    jTroopsAddDialog.pack();

    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.troops_view",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>
    setGlassPane(jxSearchPane);
    pack();
}

From source file:coolmap.canvas.datarenderer.renderer.impl.NumberComposite.java

public NumberComposite() {

    setName("Number to Composite");
    //        System.out.println("Created a new NumberComposite");
    setDescription("A renderer that can be used to assign renderers to different aggregations");

    configUI.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;//from   w w w .  ja  v a  2s.  c om
    c.gridy = 0;
    c.ipadx = 5;
    c.ipady = 5;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridwidth = 1;

    //This combo box will need to be able to add registered
    singleComboBox = new JComboBox();
    rowComboBox = new JComboBox();
    columnComboBox = new JComboBox();
    rowColumnComboBox = new JComboBox();

    singleLegend = new JLabel();
    rowLegend = new JLabel();
    columnLegend = new JLabel();
    rowColumnLegend = new JLabel();

    singleLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    rowLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    columnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    rowColumnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    //Add them
    JLabel label = new JLabel("Default:");
    label.setToolTipText("Default renderer");
    c.gridx = 0;
    c.gridy++;
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(singleComboBox, c);
    singleComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 2;
    JButton config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (singleRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    singleRenderer.getConfigUI(), "Default Renderer Config", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(singleLegend, c);

    //////////////////////////////////////////////////////////////
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Row Group:");
    label.setToolTipText("Renderer for row ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(rowComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (rowGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    rowGroupRenderer.getConfigUI(), "Row Group Renderer Config", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }

        }
    });
    rowComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(rowLegend, c);

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Column Group:");
    label.setToolTipText("Renderer for column ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(columnComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (columnGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    columnGroupRenderer.getConfigUI(), "Column Group Renderer Config",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(columnLegend, c);
    columnComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Row & Column Group:");
    label.setToolTipText("Renderer for row and column ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(rowColumnComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (rowColumnGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    rowColumnGroupRenderer.getConfigUI(), "Row + Column Group Renderer Config",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });
    rowColumnComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(rowColumnLegend, c);

    JButton button = new JButton("Apply Changes", UI.getImageIcon("refresh"));
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateRenderer();
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    configUI.add(button, c);

    singleComboBox.setRenderer(new ComboRenderer());
    rowComboBox.setRenderer(new ComboRenderer());
    columnComboBox.setRenderer(new ComboRenderer());
    rowColumnComboBox.setRenderer(new ComboRenderer());

    _updateLists();

}

From source file:hwcdhackwaterloo.GUIMain.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from w w w  . ja va2 s.c  o  m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    menuPanel = new javax.swing.JPanel();
    titleLabel = new javax.swing.JLabel();
    closeButton = new javax.swing.JButton();
    topPanel = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    roomChoice = new javax.swing.JComboBox();
    jLabel3 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    timeField = new javax.swing.JTextField();
    findButton = new javax.swing.JButton();
    monthChoice = new javax.swing.JComboBox();
    dayChoice = new javax.swing.JComboBox();
    jLabel6 = new javax.swing.JLabel();
    middlePanel = new javax.swing.JPanel();
    resultHeader = new javax.swing.JLabel();
    result = new javax.swing.JLabel();
    bottomPanel = new javax.swing.JPanel();
    jLabel4 = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Fuck_Nuts");
    setBackground(new java.awt.Color(0, 0, 0));
    setForeground(java.awt.Color.pink);
    setUndecorated(true);
    setResizable(false);

    menuPanel.setBackground(new java.awt.Color(10, 10, 10));

    titleLabel.setBackground(new java.awt.Color(255, 255, 255));
    titleLabel.setFont(new java.awt.Font("DejaVu Sans Condensed", 0, 18)); // NOI18N
    titleLabel.setForeground(new java.awt.Color(230, 230, 230));
    titleLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    titleLabel.setText("WaterLOOKup");

    closeButton.setBackground(new java.awt.Color(0, 0, 0));
    closeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/closeButtonAlt.png"))); // NOI18N
    closeButton.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            closeButtonMouseClicked(evt);
        }
    });

    javax.swing.GroupLayout menuPanelLayout = new javax.swing.GroupLayout(menuPanel);
    menuPanel.setLayout(menuPanelLayout);
    menuPanelLayout
            .setHorizontalGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(menuPanelLayout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(titleLabel).addGap(156, 156, 156).addComponent(closeButton,
                                    javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)));
    menuPanelLayout.setVerticalGroup(menuPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(menuPanelLayout.createSequentialGroup()
                    .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(titleLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                    menuPanelLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                            .addComponent(closeButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    29, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap()));

    topPanel.setBackground(new java.awt.Color(135, 0, 71));
    topPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

    jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(250, 250, 250));
    jLabel1.setText("SEARCH FOR AVAILABLE ROOMS");

    roomChoice.setBackground(new java.awt.Color(200, 50, 100));
    roomChoice.addItem("MC");

    roomChoice.addItemListener(new ItemListener() {
        Object state = new Object();
        //Object oldState = new Object();
        Object oldState = roomChoice.getSelectedItem();

        public void itemStateChanged(ItemEvent e) {

            state = e.getItem();
            if (state != oldState) {
                //System.out.println("changed to:"+ state);
                // code here to pass info to openroom.java
            }
            oldState = state;

        }
    });
    String json = getJSONData("/buildings/list");
    JSONObject obj = (JSONObject) JSONValue.parse(json);
    JSONArray courses = (JSONArray) obj.get("data");
    ArrayList<String> buildingNames = new ArrayList<>();
    for (Object course : courses) {
        JSONObject courseBlock = (JSONObject) course;
        buildingNames.add(courseBlock.get("building_code").toString());
    }
    Collections.sort(buildingNames);
    for (String buildingName : buildingNames) {
        roomChoice.addItem(buildingName);
    }

    jLabel3.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
    jLabel3.setForeground(new java.awt.Color(250, 250, 250));
    jLabel3.setText("WHAT'S DA CLOSEST BUILDIN TO YOU?");

    jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
    jLabel5.setForeground(new java.awt.Color(250, 250, 250));
    jLabel5.setText("WHEN DO YOU WANT A ROOM, AND FOR HOW LONG?");

    timeField.setBackground(new java.awt.Color(255, 160, 202));
    timeField.setText("(minutes)");

    findButton.setBackground(new java.awt.Color(255, 170, 202));
    findButton.setText("FIND AVAILABLE ROOM!");
    Object comboBoxState = roomChoice.getSelectedItem();
    findButton.setActionCommand("FIND");
    //findButton.addActionListener(this);
    findButton.setToolTipText("Dooooo itttt!");

    //pubic void actionPerformed(ActionEvent e){
    //    if("FIND".equals(e.getActionCommand())){
    //        System.out.println("Press registered.");
    //    }
    //}
    findButton.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseReleased(java.awt.event.MouseEvent evt) {
            findButtonMouseReleased(evt);
        }
    });

    monthChoice.setBackground(new java.awt.Color(200, 50, 100));
    monthChoice.setModel(new javax.swing.DefaultComboBoxModel(
            new String[] { "<select month>", "January", "February", "March", "April", "May", "June", "July",
                    "August", "September", "October", "November", "December" }));
    monthChoice.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            monthChoiceItemStateChanged(evt);
        }
    });

    dayChoice.setBackground(new java.awt.Color(200, 50, 100));

    jLabel6.setForeground(new java.awt.Color(255, 255, 255));
    jLabel6.setText("DURATION:");

    javax.swing.GroupLayout topPanelLayout = new javax.swing.GroupLayout(topPanel);
    topPanel.setLayout(topPanelLayout);
    topPanelLayout.setHorizontalGroup(topPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(topPanelLayout.createSequentialGroup().addGroup(topPanelLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(topPanelLayout.createSequentialGroup().addGap(34, 34, 34)
                            .addGroup(topPanelLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(roomChoice, javax.swing.GroupLayout.PREFERRED_SIZE, 87,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5)
                                    .addGroup(topPanelLayout.createSequentialGroup()
                                            .addComponent(monthChoice, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    122, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(dayChoice, javax.swing.GroupLayout.PREFERRED_SIZE, 55,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jLabel6)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(timeField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    108, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(topPanelLayout.createSequentialGroup().addGap(135, 135, 135).addComponent(
                            findButton, javax.swing.GroupLayout.PREFERRED_SIZE, 187,
                            javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGap(38, 38, 38))
            .addGroup(topPanelLayout.createSequentialGroup().addGap(93, 93, 93).addComponent(jLabel1)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    topPanelLayout.setVerticalGroup(topPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(topPanelLayout.createSequentialGroup()
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(roomChoice, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(timeField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(monthChoice, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dayChoice, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(findButton, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                    .addContainerGap()));

    middlePanel.setBackground(new java.awt.Color(0, 129, 16));
    middlePanel.setForeground(new java.awt.Color(240, 240, 240));

    resultHeader.setFont(new java.awt.Font("Tahoma", 0, 18));
    resultHeader.setForeground(new java.awt.Color(250, 250, 250));

    result.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
    result.setForeground(new java.awt.Color(255, 255, 255));

    javax.swing.GroupLayout middlePanelLayout = new javax.swing.GroupLayout(middlePanel);
    middlePanel.setLayout(middlePanelLayout);
    middlePanelLayout.setHorizontalGroup(middlePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(middlePanelLayout.createSequentialGroup().addGap(84, 84, 84)
                    .addComponent(resultHeader, javax.swing.GroupLayout.PREFERRED_SIZE, 267,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(115, Short.MAX_VALUE))
            .addGroup(middlePanelLayout.createSequentialGroup().addContainerGap().addComponent(result,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));
    middlePanelLayout.setVerticalGroup(middlePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(middlePanelLayout.createSequentialGroup()
                    .addComponent(resultHeader, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                    .addComponent(result, javax.swing.GroupLayout.PREFERRED_SIZE, 82,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(44, 44, 44)));

    bottomPanel.setBackground(new java.awt.Color(159, 238, 0));

    jLabel4.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
    jLabel4.setText("BY: KERI WARR, ANTHONY CALANDRA, DANIEL HOPPER, NEIL DE VRIES");

    javax.swing.GroupLayout bottomPanelLayout = new javax.swing.GroupLayout(bottomPanel);
    bottomPanel.setLayout(bottomPanelLayout);
    bottomPanelLayout
            .setHorizontalGroup(bottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            bottomPanelLayout.createSequentialGroup()
                                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 406,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap()));
    bottomPanelLayout.setVerticalGroup(
            bottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                    javax.swing.GroupLayout.Alignment.TRAILING,
                    bottomPanelLayout.createSequentialGroup().addGap(0, 132, Short.MAX_VALUE).addComponent(
                            jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                            javax.swing.GroupLayout.PREFERRED_SIZE)));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(middlePanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(menuPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
            .addComponent(bottomPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(topPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addComponent(menuPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 33,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(topPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(middlePanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(bottomPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));

    pack();
}

From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.IntHistogramVisualizer.java

@Override
protected JComponent addSettingsPanels(JTabbedPane aPanel) {

    addTab(aPanel, Messages.DI_GENERAL, new SettingsPanel(general), Messages.TT_GENSETTINGS);
    addTab(aPanel, Messages.DI_AXES, new SettingsPanel(settings.axes), Messages.TT_AXESSETTINGS);
    addTab(aPanel, Messages.DI_GRID, new SettingsPanel(settings.grid), Messages.TT_GRIDSETTINGS);

    boolean useScatter = settings.useScatter();
    final Box histPanel = Box.createVerticalBox();

    final JComboBox choiceCombo = addChoice(histPanel, useScatter ? 1 : 0);

    final CardLayout innerLayout = new CardLayout();
    final JPanel innerPanel = new JPanel(innerLayout);
    histPanel.add(innerPanel);/*from w w  w  . j av a2 s . co  m*/
    aPanel.addTab(Messages.DI_HISTOGRAM, null, histPanel, Messages.TT_HISTSETTINGS);

    ItemListener listener = new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                innerLayout.next(innerPanel);
            }
        }
    };
    choiceCombo.addItemListener(listener);

    innerPanel.add(new SettingsPanel(settings.bars), "0");
    innerPanel.add(new SettingsPanel(settings.scatter), "1");
    if (useScatter) {
        innerLayout.next(innerPanel);
    }

    return choiceCombo;
}