Example usage for java.awt BorderLayout WEST

List of usage examples for java.awt BorderLayout WEST

Introduction

In this page you can find the example usage for java.awt BorderLayout WEST.

Prototype

String WEST

To view the source code for java.awt BorderLayout WEST.

Click Source Link

Document

The west layout constraint (left side of container).

Usage

From source file:com.haulmont.cuba.desktop.App.java

protected JComponent createBottomPane() {
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createLineBorder(Color.gray));
    panel.setPreferredSize(new Dimension(0, 20));

    ServerSelector serverSelector = AppBeans.get(ServerSelector.NAME);
    String url = serverSelector.getUrl(serverSelector.initContext());
    if (url == null)
        url = "?";

    final JLabel connectionStateLab = new JLabel(
            messages.formatMainMessage("statusBar.connected", getUserFriendlyConnectionUrl(url)));

    panel.add(connectionStateLab, BorderLayout.WEST);

    JPanel rightPanel = new JPanel();
    BoxLayout rightLayout = new BoxLayout(rightPanel, BoxLayout.LINE_AXIS);
    rightPanel.setLayout(rightLayout);/* w w w .j a va2  s.co  m*/

    UserSession session = connection.getSession();

    JLabel userInfoLabel = new JLabel();
    String userInfo = messages.formatMainMessage("statusBar.user", session.getUser().getName(),
            session.getUser().getLogin());
    userInfoLabel.setText(userInfo);

    rightPanel.add(userInfoLabel);

    JLabel timeZoneLabel = null;
    if (session.getTimeZone() != null) {
        timeZoneLabel = new JLabel();
        String timeZone = messages.formatMainMessage("statusBar.timeZone",
                AppBeans.get(TimeZones.class).getDisplayNameShort(session.getTimeZone()));
        timeZoneLabel.setText(timeZone);

        rightPanel.add(Box.createRigidArea(new Dimension(5, 0)));
        rightPanel.add(timeZoneLabel);
    }

    panel.add(rightPanel, BorderLayout.EAST);

    if (isTestMode()) {
        panel.setName("bottomPane");
        userInfoLabel.setName("userInfoLabel");
        if (timeZoneLabel != null)
            timeZoneLabel.setName("timeZoneLabel");
        connectionStateLab.setName("connectionStateLab");
    }

    return panel;
}

From source file:com.intuit.tank.proxy.ProxyApp.java

private JPanel getTransactionTable() {
    JPanel frame = new JPanel(new BorderLayout());
    model = new TransactionTableModel();
    final JTable table = new TransactionTable(model);
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
    table.setRowSorter(sorter);/*from   w w w. j ava2 s  .c o m*/
    final JPopupMenu pm = new JPopupMenu();
    JMenuItem item = new JMenuItem("Delete Selected");
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            int[] selectedRows = table.getSelectedRows();
            if (selectedRows.length != 0) {
                int response = JOptionPane.showConfirmDialog(ProxyApp.this,
                        "Are you sure you want to delete " + selectedRows.length + " Transactions?",
                        "Confirm Delete", JOptionPane.YES_NO_OPTION);
                if (response == JOptionPane.YES_OPTION) {
                    int[] correctedRows = new int[selectedRows.length];
                    for (int i = selectedRows.length; --i >= 0;) {
                        int row = selectedRows[i];
                        int index = (Integer) table.getValueAt(row, 0) - 1;
                        correctedRows[i] = index;
                    }
                    Arrays.sort(correctedRows);
                    for (int i = correctedRows.length; --i >= 0;) {
                        int row = correctedRows[i];
                        Transaction transaction = model.getTransactionForIndex(row);
                        if (transaction != null) {
                            model.removeTransaction(transaction, row);
                            isDirty = true;
                            saveAction.setEnabled(isDirty && !stopAction.isEnabled());
                        }
                    }
                }
            }
        }
    });
    pm.add(item);
    table.add(pm);

    table.addMouseListener(new MouseAdapter() {
        boolean pressed = false;

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                Point p = e.getPoint();
                int row = table.rowAtPoint(p);
                int index = (Integer) table.getValueAt(row, 0) - 1;
                Transaction transaction = model.getTransactionForIndex(index);
                if (transaction != null) {
                    detailsTF.setText(transaction.toString());
                    detailsTF.setCaretPosition(0);
                    detailsDialog.setVisible(true);
                }
            }
        }

        /**
         * @{inheritDoc
         */
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                pressed = true;
                int[] selectedRows = table.getSelectedRows();
                if (selectedRows.length != 0) {
                    pm.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }

        /**
         * @{inheritDoc
         */
        @Override
        public void mouseReleased(MouseEvent e) {
            if (!pressed && e.isPopupTrigger()) {
                int[] selectedRows = table.getSelectedRows();
                if (selectedRows.length != 0) {
                    pm.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }

    });

    JScrollPane pane = new JScrollPane(table);
    frame.add(pane, BorderLayout.CENTER);
    JPanel panel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Filter: ");
    panel.add(label, BorderLayout.WEST);
    final JLabel countLabel = new JLabel(" Count: 0 ");
    panel.add(countLabel, BorderLayout.EAST);
    final JTextField filterText = new JTextField("");
    filterText.addKeyListener(new KeyAdapter() {
        public void keyTyped(KeyEvent e) {
            String text = filterText.getText();
            if (text.length() == 0) {
                sorter.setRowFilter(null);
            } else {
                try {
                    sorter.setRowFilter(RowFilter.regexFilter(text));
                    countLabel.setText(" Count: " + sorter.getViewRowCount() + " ");
                } catch (PatternSyntaxException pse) {
                    System.err.println("Bad regex pattern");
                }
            }
        }
    });
    panel.add(filterText, BorderLayout.CENTER);

    frame.add(panel, BorderLayout.NORTH);
    return frame;
}

From source file:edu.harvard.mcz.imagecapture.ImageDisplayFrame.java

public void addWest(JPanel panel) {
    //      JScrollPane scroll = new JScrollPane(panel);
    //      scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    //      scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    //      jContentPane.add(scroll,BorderLayout.WEST);
    jContentPane.add(panel, BorderLayout.WEST);
    panel.setPreferredSize(new Dimension(594, panel.getHeight()));
    //      scroll.setPreferredSize(new Dimension(594,panel.getHeight()));
    this.pack();/*  ww  w.j  ava  2 s. c  o m*/
}

From source file:edu.ucla.stat.SOCR.chart.demo.DotChart.java

protected void setMixPanel() {
    dataPanel2.removeAll();/* w  w  w. ja v a2  s . c o m*/
    graphPanel2.removeAll();

    graphPanel2.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 3));
    graphPanel2.setLayout(new BoxLayout(graphPanel2, BoxLayout.Y_AXIS));
    if (chartPanel1 != null)
        graphPanel2.add(chartPanel1);
    if (chartPanel2 != null)
        graphPanel2.add(chartPanel2);
    graphPanel2.validate();

    dataPanel2.add(new JLabel(" "));
    dataPanel2.add(new JLabel("Data"));
    JScrollPane dt = new JScrollPane(dataTable);
    dt.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y * 3 / 8));

    dataPanel2.add(dt);
    JScrollPane st = new JScrollPane(summaryPanel);
    st.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 6));
    dataPanel2.add(st);
    st.validate();

    dataPanel2.add(new JLabel(" "));
    dataPanel2.add(new JLabel("Mapping"));
    mapPanel.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 2));
    dataPanel2.add(mapPanel);

    dataPanel2.validate();

    mixPanel.removeAll();
    mixPanel.add(graphPanel2, BorderLayout.WEST);
    mixPanel.add(new JScrollPane(dataPanel2), BorderLayout.CENTER);
    mixPanel.validate();
}

From source file:biz.wolschon.finance.jgnucash.widgets.TransactionSum.java

/**
 * Create the UI-components./* w  w  w  .  j  a  va2 s.  c om*/
 * @param name the name to display left of the sum
 */
public void initializeUI(final String name) {
    this.setLayout(new BorderLayout());
    myNameLabel.setText(name);
    mySumLabel.setText("...");
    myDrilldownLabel.setText("");//TODO: implement drilldown
    this.add(myNameLabel, BorderLayout.WEST);
    this.add(mySumLabel, BorderLayout.CENTER);
    this.add(myDrilldownLabel, BorderLayout.EAST);
}

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

private JPanel getPortPanel() {
    port = new JTextField(4);

    JLabel label = new JLabel(UPMPConstant.upmp_server_port); // $NON-NLS-1$
    label.setLabelFor(port);//  w ww .j  av a2 s .c  o  m

    JPanel panel = new JPanel(new BorderLayout(5, 0));
    panel.add(label, BorderLayout.WEST);
    panel.add(port, BorderLayout.CENTER);

    return panel;
}

From source file:org.rdv.viz.image.ImageViz.java

private void initZoomControls() {
    zoomControls = new JPanel();
    zoomControls.setLayout(new BorderLayout());

    JButton zoomOutButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-minus.gif"));
    zoomOutButton.setBorder(null);/*from w  w w.j  a va2 s .c  o  m*/
    zoomOutButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            zoomOut();
        }
    });
    zoomControls.add(zoomOutButton, BorderLayout.WEST);

    JButton zoomControlButton = new StrechIconButton(
            DataViewer.getIcon("icons/ptz/robotic_control-zoombar-medium.gif"));
    zoomControlButton.setBorder(null);
    zoomControlButton.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            JButton button = (JButton) e.getComponent();
            int zoom = Math.round(100f * e.getPoint().x / button.getWidth());
            zoom(zoom);
        }
    });
    zoomControls.add(zoomControlButton, BorderLayout.CENTER);

    JPanel topRightControls = new JPanel();
    topRightControls.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));

    JButton zoomInButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-plus.gif"));
    zoomInButton.setBorder(null);
    zoomInButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            zoomIn();
        }
    });
    topRightControls.add(zoomInButton);

    JButton topHomeButton = new JButton(DataViewer.getIcon("icons/ptz/robotic_control-home.gif"));
    topHomeButton.setBorder(null);
    topHomeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            home();
        }
    });
    topRightControls.add(topHomeButton);

    zoomControls.add(topRightControls, BorderLayout.EAST);
}

From source file:com.rapidminer.gui.graphs.GraphViewer.java

public GraphViewer(final GraphCreator<V, E> graphCreator) {
    try {/*from  w w  w .java  2 s.c om*/
        if (!RapidMiner.getExecutionMode().isHeadless()) {
            graphMouse = new DefaultModalGraphMouse(1 / 1.1f, 1.1f);
        }
    } catch (HeadlessException e) {
    }

    this.graphCreator = graphCreator;

    setLayout(new BorderLayout());

    Graph<V, E> graph = graphCreator.createGraph();
    this.layoutSelection = new LayoutSelection<>(this, graph);
    this.layout = new ISOMLayout<>(graph);
    vv = new VisualizationViewer<V, E>(layout) {

        private static final long serialVersionUID = 8247229781249216143L;

        private boolean initialized = false;

        /**
         * Necessary in order to re-change layout after first painting (starting position and
         * size).
         */
        @Override
        public void paint(Graphics g) {
            super.paint(g);
            if (!initialized) {
                initialized = true;
                updateLayout();
                if (objectViewerSplitPane != null) {
                    objectViewerSplitPane.setDividerLocation(0.9);
                }
            }
        }
    };
    vv.setBorder(BorderFactory.createEmptyBorder());
    vv.setBackground(Color.white);

    // === design ===

    // ## edge layout ##
    // EDGE SHAPE
    int edgeShapeType = graphCreator.getEdgeShape();
    switch (edgeShapeType) {
    case GraphCreator.EDGE_SHAPE_LINE:
        vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<V, E>());
        break;
    case GraphCreator.EDGE_SHAPE_QUAD_CURVE:
        vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<V, E>());
        break;
    case GraphCreator.EDGE_SHAPE_CUBIC_CURVE:
        vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<V, E>());
        break;
    case GraphCreator.EDGE_SHAPE_BENT_LINE:
        vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.BentLine<V, E>());
        break;
    case GraphCreator.EDGE_SHAPE_WEDGE:
        vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Wedge<V, E>(5));
        break;
    default:
        vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<V, E>());
        break;
    }

    // EDGE FONT
    vv.getRenderContext().setEdgeFontTransformer(new Transformer<E, Font>() {

        @Override
        public Font transform(E arg0) {
            return EDGE_FONT;
        }
    });

    // EDGE COLORS
    vv.getRenderContext().setEdgeDrawPaintTransformer(new Transformer<E, Paint>() {

        @Override
        public Paint transform(E edge) {
            double edgeStrength = graphCreator.getEdgeStrength(edge);
            int value = (int) Math.max(140, Math.min(230, 230 - edgeStrength * 90));
            return new Color(value, value, value);
        }
    });
    vv.getRenderContext().setArrowDrawPaintTransformer(new Transformer<E, Paint>() {

        @Override
        public Paint transform(E edge) {
            double edgeStrength = graphCreator.getEdgeStrength(edge);
            int value = (int) Math.max(140, Math.min(230, 230 - edgeStrength * 90));
            return new Color(value, value, value).darker();
        }
    });
    vv.getRenderContext().setArrowFillPaintTransformer(new Transformer<E, Paint>() {

        @Override
        public Paint transform(E edge) {
            double edgeStrength = graphCreator.getEdgeStrength(edge);
            int value = (int) Math.max(140, Math.min(230, 230 - edgeStrength * 90));
            return new Color(value, value, value);
        }
    });

    // EDGE LABEL POSITION
    vv.getRenderContext()
            .setEdgeLabelClosenessTransformer(new ConstantDirectionalEdgeValueTransformer<V, E>(0.5d, 0.5d));
    int labelOffset = graphCreator.getLabelOffset();
    if (labelOffset >= 0) {
        vv.getRenderContext().setLabelOffset(labelOffset);
    }

    // EDGE LABELS
    vv.getRenderContext().setEdgeLabelTransformer(new Transformer<E, String>() {

        @Override
        public String transform(E object) {
            return graphCreator.getEdgeName(object);
        }
    });
    // EDGE LABEL RENDERER
    Renderer.EdgeLabel<V, E> edgeLabelRenderer = graphCreator.getEdgeLabelRenderer();
    if (edgeLabelRenderer != null) {
        vv.getRenderer().setEdgeLabelRenderer(edgeLabelRenderer); // renderer...
    }
    vv.getRenderContext().setEdgeLabelRenderer(new EdgeLabelRenderer() { // ...context!

        private JLabel renderer = new JLabel();

        @Override
        public <T> Component getEdgeLabelRendererComponent(JComponent parent, Object value, Font font,
                boolean isSelected, T edge) {
            this.renderer.setFont(font);
            if (graphCreator.isEdgeLabelDecorating()) {
                this.renderer.setOpaque(true);
                renderer.setBackground(Color.WHITE);
                // use this for a more fancy look and feel
                // renderer.setBackground(SwingTools.TRANSPARENT_YELLOW);
                // this.renderer.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(SwingTools.DARK_BLUE),
                // BorderFactory.createEmptyBorder(1,1,1,1)));
            }
            this.renderer.setText(value.toString());
            return this.renderer;
        }

        /** Let the graph model decide. */
        @Override
        public boolean isRotateEdgeLabels() {
            return graphCreator.isRotatingEdgeLabels();
        }

        /** Does nothing. */
        @Override
        public void setRotateEdgeLabels(boolean rotate) {
        }
    });

    // ## vertex layout ##

    // VERTEX FONT
    vv.getRenderContext().setVertexFontTransformer(new Transformer<V, Font>() {

        @Override
        public Font transform(V vertex) {
            if (graphCreator.isBold(vertex)) {
                return VERTEX_BOLD_FONT;
            } else {
                return VERTEX_PLAIN_FONT;
            }
        }
    });
    // VERTEX NAME
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<V, String>() {

        @Override
        public String transform(V object) {
            return graphCreator.getVertexName(object);
        }
    });
    // VERTEX FILL PAINT
    Transformer<V, Paint> paintTransformer = graphCreator.getVertexPaintTransformer(vv);
    if (paintTransformer == null) {
        paintTransformer = new Transformer<V, Paint>() {

            @Override
            public Paint transform(V vertex) {
                if (vv.getPickedVertexState().isPicked(vertex)) {
                    return SwingTools.LIGHT_YELLOW;
                } else {
                    return SwingTools.LIGHT_BLUE;
                }
            }
        };
    }
    vv.getRenderContext().setVertexFillPaintTransformer(paintTransformer);

    // VERTEX DRAW PAINT
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<V, Paint>() {

        @Override
        public Paint transform(V vertex) {
            if (vv.getPickedVertexState().isPicked(vertex)) {
                return SwingTools.DARKEST_YELLOW.darker();
            } else {
                return SwingTools.DARKEST_BLUE.darker();
            }
        }
    });
    // VERTEX TOOL TIP
    this.vv.setVertexToolTipTransformer(new Transformer<V, String>() {

        @Override
        public String transform(V vertex) {
            return graphCreator.getVertexToolTip(vertex);
        }
    });
    // VERTEX SHAPE
    vv.getRenderContext().setVertexShapeTransformer(new ExtendedVertexShapeTransformer<>(graphCreator));

    // VERTEX RENDERER
    Renderer.Vertex<V, E> vertexRenderer = graphCreator.getVertexRenderer();
    if (vertexRenderer != null) {
        vv.getRenderer().setVertexRenderer(vertexRenderer);
    }

    // VERTEX LABEL RENDERER
    setDefaultLabelPosition();
    // custom renderer?
    Renderer.VertexLabel<V, E> customVertexLabelRenderer = graphCreator.getVertexLabelRenderer();
    if (customVertexLabelRenderer != null) {
        vv.getRenderer().setVertexLabelRenderer(customVertexLabelRenderer);
    }

    // context
    vv.getRenderContext().setVertexLabelRenderer(new VertexLabelRenderer() {

        private JLabel label = new JLabel();

        @Override
        public <T> Component getVertexLabelRendererComponent(JComponent parent, Object object, Font font,
                boolean isSelection, T vertex) {
            label.setFont(font);
            if (object != null) {
                label.setText(object.toString());
            } else {
                label.setText("");
            }
            return label;
        }

    });

    // === end of design ===

    // === main panel ===

    if (graphCreator.getObjectViewer() == null) {
        add(vv, BorderLayout.CENTER);
    } else {
        JComponent viewer = graphCreator.getObjectViewer().getViewerComponent();
        if (viewer != null) {
            viewer.setBorder(null);
            objectViewerSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
            objectViewerSplitPane.setResizeWeight(1);
            objectViewerSplitPane.add(vv, 0);
            objectViewerSplitPane.add(viewer, 1);
            add(objectViewerSplitPane, BorderLayout.CENTER);
        } else {
            add(vv, BorderLayout.CENTER);
        }
    }

    // === control panel ===

    Component controlPanel = createControlPanel();
    add(new ExtendedJScrollPane(controlPanel), BorderLayout.WEST);

    this.showEdgeLabels = !graphCreator.showEdgeLabelsDefault();
    togglePaintEdgeLabels();
    this.showVertexLabels = !graphCreator.showVertexLabelsDefault();
    togglePaintVertexLabels();

    this.layoutSelection.setLayout();
}

From source file:com.epiq.bitshark.ui.FrequencyDomainPanel.java

/**
 * This was originally generated code so it still
 * needs some cleanup./*from   www . j  av  a  2 s  .co m*/
 */
private void initComponents() {

    topPanel = new javax.swing.JPanel();
    headerPanel = new org.jdesktop.swingx.JXPanel();
    topLeftHeaderPanel = new javax.swing.JPanel();
    graphLabel = new javax.swing.JLabel();
    chartLabelSpacerPanel = new javax.swing.JPanel();
    topRightHeaderPanel = new javax.swing.JPanel();
    topRightControlPanel = new javax.swing.JPanel();
    alphaLabel = new javax.swing.JLabel();
    alphaSlider = new javax.swing.JSlider();
    windowLabel = new javax.swing.JLabel();
    windowComboBox = new javax.swing.JComboBox();
    rightSpacerPanel = new javax.swing.JPanel();
    leftSpacerPanel = new javax.swing.JPanel();
    mainPanel = new javax.swing.JPanel();

    setLayout(new java.awt.BorderLayout());

    topPanel.setPreferredSize(new java.awt.Dimension(0, 30));
    topPanel.setLayout(new java.awt.BorderLayout());

    headerPanel.setBackground(new java.awt.Color(0, 0, 0));
    headerPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(121, 123, 125)));
    headerPanel.setPreferredSize(new java.awt.Dimension(0, 30));
    headerPanel.setLayout(new java.awt.BorderLayout());

    topLeftHeaderPanel.setOpaque(false);
    topLeftHeaderPanel.setLayout(new java.awt.BorderLayout());

    graphLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
    graphLabel.setText("Frequency Domain");
    graphLabel.setForeground(new java.awt.Color(255, 255, 255));
    topLeftHeaderPanel.add(graphLabel, java.awt.BorderLayout.CENTER);

    chartLabelSpacerPanel.setOpaque(false);
    chartLabelSpacerPanel.setPreferredSize(new java.awt.Dimension(10, 0));
    topLeftHeaderPanel.add(chartLabelSpacerPanel, java.awt.BorderLayout.WEST);

    headerPanel.add(topLeftHeaderPanel, java.awt.BorderLayout.WEST);

    topRightHeaderPanel.setOpaque(false);
    topRightHeaderPanel.setLayout(new java.awt.BorderLayout());

    topRightControlPanel.setOpaque(false);
    topRightControlPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 2));

    alphaLabel.setText("Alpha:");
    alphaLabel.setForeground(new java.awt.Color(255, 255, 255));
    topRightControlPanel.add(alphaLabel);

    alphaSlider.setMaximum(10000);
    alphaSlider.setOpaque(false);
    alphaSlider.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            alphaSliderStateChanged(evt);
        }
    });
    topRightControlPanel.add(alphaSlider);

    windowLabel.setText("Window:");
    windowLabel.setForeground(new java.awt.Color(255, 255, 255));
    topRightControlPanel.add(windowLabel);

    windowComboBox.setModel(
            new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    windowComboBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            windowComboBoxActionPerformed(evt);
        }
    });
    topRightControlPanel.add(windowComboBox);

    topRightHeaderPanel.add(topRightControlPanel, java.awt.BorderLayout.EAST);

    headerPanel.add(topRightHeaderPanel, java.awt.BorderLayout.EAST);

    topPanel.add(headerPanel, java.awt.BorderLayout.CENTER);

    rightSpacerPanel.setPreferredSize(new java.awt.Dimension(7, 0));
    topPanel.add(rightSpacerPanel, java.awt.BorderLayout.EAST);

    leftSpacerPanel.setOpaque(false);
    leftSpacerPanel.setPreferredSize(new java.awt.Dimension(44, 0));
    topPanel.add(leftSpacerPanel, java.awt.BorderLayout.WEST);

    add(topPanel, java.awt.BorderLayout.NORTH);

    mainPanel.setLayout(new java.awt.BorderLayout());
    add(mainPanel, java.awt.BorderLayout.CENTER);
}

From source file:samples.graph.PluggableRendererDemo.java

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

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

    // set up vertex controls
    v_color = new JCheckBox("vertex seed coloring");
    v_color.addActionListener(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(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());
        }
    });

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