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:GroupActionRadio.java

public static void main(String args[]) {

    String title = (args.length == 0 ? "Grouping Example" : args[0]);
    JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Slice Parts
    ActionListener sliceActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton aButton = (AbstractButton) actionEvent.getSource();
            System.out.println("Selected: " + aButton.getText());
        }// w ww .j  a  v a2  s. co  m
    };
    Container sliceContainer = RadioButtonUtils.createRadioButtonGrouping(sliceOptions, "Slice Count",
            sliceActionListener);

    // Crust Parts
    ActionListener crustActionListener = new ActionListener() {
        String lastSelected;

        public void actionPerformed(ActionEvent actionEvent) {
            AbstractButton aButton = (AbstractButton) actionEvent.getSource();
            String label = aButton.getText();
            String msgStart;
            if (label.equals(lastSelected)) {
                msgStart = "Reselected: ";
            } else {
                msgStart = "Selected: ";
            }
            lastSelected = label;
            System.out.println(msgStart + label);
        }
    };
    ItemListener itemListener = new ItemListener() {
        String lastSelected;

        public void itemStateChanged(ItemEvent itemEvent) {
            AbstractButton aButton = (AbstractButton) itemEvent.getSource();
            int state = itemEvent.getStateChange();
            String label = aButton.getText();
            String msgStart;
            if (state == ItemEvent.SELECTED) {
                if (label.equals(lastSelected)) {
                    msgStart = "Reselected -> ";
                } else {
                    msgStart = "Selected -> ";
                }
                lastSelected = label;
            } else {
                msgStart = "Deselected -> ";
            }
            System.out.println(msgStart + label);
        }
    };
    ChangeListener changeListener = new ChangeListener() {
        public void stateChanged(ChangeEvent changEvent) {
            AbstractButton aButton = (AbstractButton) changEvent.getSource();
            ButtonModel aModel = aButton.getModel();
            boolean armed = aModel.isArmed();
            boolean pressed = aModel.isPressed();
            boolean selected = aModel.isSelected();
            System.out.println("Changed: " + armed + "/" + pressed + "/" + selected);
        }
    };
    final Container crustContainer = RadioButtonUtils.createRadioButtonGrouping(crustOptions, "Crust Type",
            crustActionListener, itemListener, changeListener);

    // Button Parts
    ActionListener buttonActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            Enumeration selected = RadioButtonUtils.getSelectedElements(crustContainer);
            while (selected.hasMoreElements()) {
                System.out.println("Selected -> " + selected.nextElement());
            }
        }
    };
    JButton button = new JButton("Order Pizza");
    button.addActionListener(buttonActionListener);

    Container contentPane = frame.getContentPane();
    contentPane.add(sliceContainer, BorderLayout.WEST);
    contentPane.add(crustContainer, BorderLayout.EAST);
    contentPane.add(button, BorderLayout.SOUTH);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:com.qawaa.gui.PointAnalysisGUI.java

/**
* Auto-generated main method to display this JFrame
*///  w  ww  . j  av a  2  s. c om
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            PointAnalysisGUI inst = new PointAnalysisGUI();
            inst.setLocationRelativeTo(null);
            inst.setVisible(true);
            inst.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JFrame.setDefaultLookAndFeelDecorated(true);
            FlowLayout flowLayout = new FlowLayout();
            flowLayout.setAlignment(FlowLayout.LEFT);
            flowLayout.setAlignOnBaseline(true);
            inst.setTitle(PROGRAM_NAME + " [" + PROGRAM_VERSION + "] " + " - " + DefaultMessage.SOFT_NAME
                    + " - " + DefaultMessage.COMPANY_NAME);
            {
                consoleScrollPane = new JScrollPane();
                inst.getContentPane().add(consoleScrollPane, BorderLayout.CENTER);
                {
                    consolePane = new JEditorPane();
                    consoleScrollPane.setViewportView(consolePane);
                    consolePane.setText("");
                    setConsoleRight();
                    jConsole = new JConsole(System.out, consolePane);
                    System.setOut(jConsole);
                    System.setErr(jConsole);
                    consolePane.setEditable(false);
                    consolePane.addMouseListener(new MouseAdapter() {
                        /* (non-Javadoc)
                         * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent)
                         */
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON3) {
                                consolePane.add(consoleRight);
                                consoleRight.show(e.getComponent(), e.getX(), e.getY());
                            }
                        }
                    });
                }
            }
            {
                infoPanel = new JPanel();
                inst.getContentPane().add(infoPanel, BorderLayout.SOUTH);
                infoPanel.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                infoPanel.setPreferredSize(new Dimension(784, 30));
                infoPanel.setLayout(flowLayout);
                {
                    {
                        statusbar_count = new JTextPane();
                        infoPanel.add(statusbar_count);
                        statusbar_count
                                .setText(CONTEXT.getMessage("point.statusbar.count", null, Locale.CHINA));
                        statusbar_count.setBackground(null);
                        statusbar_count.setEditable(false);
                    }
                    {
                        statusbar_count_value = new JTextPane();
                        infoPanel.add(statusbar_count_value);
                        statusbar_count_value.setText(String.valueOf(SCAN_COUNT));
                        statusbar_count_value.setBackground(null);
                        statusbar_count_value.setEditable(false);
                        statusbar_count_value.setEnabled(false);
                    }
                    {
                        programPID = new JTextPane();
                        infoPanel.add(programPID);
                        programPID.setText("PID:");
                        programPID.setBackground(null);
                        programPID.setEditable(false);
                    }
                    {
                        programPID_value = new JTextPane();
                        infoPanel.add(programPID_value);
                        programPID_value.setText(JvmPid.getPID());
                        programPID_value.setBackground(null);
                        programPID_value.setEditable(false);
                        programPID_value.setEnabled(false);
                    }
                    {
                        memory = new JTextPane();
                        infoPanel.add(memory);
                        memory.setText(CONTEXT.getMessage("gobal.gui.memory", null, Locale.CHINA));
                        memory.setBackground(null);
                        memory.setEditable(false);
                    }
                    {
                        memory_value = new JTextPane();
                        infoPanel.add(memory_value);
                        memory_value.setText("0KB");
                        memory_value.setBackground(null);
                        memory_value.setEditable(false);
                        memory_value.setEnabled(false);
                        MemoryListener memory = new MemoryListener(memory_value);
                        memory.start();
                    }
                    {
                        runtime = new JTextPane();
                        infoPanel.add(runtime);
                        runtime.setText(CONTEXT.getMessage("gobal.gui.runtime", null, Locale.CHINA));
                        runtime.setBackground(null);
                        runtime.setEditable(false);
                    }
                    {
                        runtime_value = new JTextPane();
                        infoPanel.add(runtime_value);
                        runtime_value.setText("NULL");
                        runtime_value.setBackground(null);
                        runtime_value.setEditable(false);
                        runtime_value.setEnabled(false);
                    }
                }
            }
            {
                shortcut = new JPanel();
                inst.getContentPane().add(shortcut, BorderLayout.NORTH);
                shortcut.setSize(784, 35);
                shortcut.setPreferredSize(new Dimension(784, 35));
                shortcut.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                shortcut.setLayout(new BorderLayout());
                {
                    eventText = new JTextPane();
                    shortcut.add(eventText, BorderLayout.WEST);
                    eventText.setText(CONTEXT.getMessage("point.event.name", null, Locale.CHINA) + ": ");
                    eventText.setEditable(false);
                    eventText.setEnabled(true);
                    eventText.setBackground(null);
                    eventText.setCaretColor(new Color(0, 0, 0));
                }
                {
                    eventTextField = new JTextField();
                    shortcut.add(eventTextField, BorderLayout.CENTER);
                    eventTextField.setSize(500, 25);
                    eventTextField.setText("");
                    eventTextField.setPreferredSize(new Dimension(500, 25));
                    eventTextField.setEditable(false);
                }
                {
                    submit = new JButton();
                    shortcut.add(submit, BorderLayout.EAST);
                    submit.setText(CONTEXT.getMessage("gobal.gui.button.run", null, Locale.CHINA));
                    submit.setSize(new Dimension(75, 25));
                    submit.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                submitActionPerformed(evt);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                }
            }
        }
    });

}

From source file:Main.java

/**
 * Creates a JPanel containing the component hugging the left side
 * @param component the component to wrap
 * @return a JPanel containing the component hugging the left side
 *///from   www .j  av a2 s  .  c o  m
public static JPanel hugWest(JComponent component) {
    final JPanel result = new JPanel(new BorderLayout());
    result.add(component, BorderLayout.WEST);
    return result;
}

From source file:com.qawaa.gui.EventWebScanGUI.java

/**
* Auto-generated main method to display this JFrame
*///from   ww w .  ja v  a 2 s .c  o m
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            EventWebScanGUI inst = new EventWebScanGUI();
            inst.setLocationRelativeTo(null);
            inst.setVisible(true);
            inst.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JFrame.setDefaultLookAndFeelDecorated(true);
            FlowLayout flowLayout = new FlowLayout();
            flowLayout.setAlignment(FlowLayout.LEFT);
            flowLayout.setAlignOnBaseline(true);
            inst.setTitle(PROGRAM_NAME + " [" + PROGRAM_VERSION + "] " + " - " + DefaultMessage.SOFT_NAME
                    + " - " + DefaultMessage.COMPANY_NAME);
            {
                consoleScrollPane = new JScrollPane();
                inst.getContentPane().add(consoleScrollPane, BorderLayout.CENTER);
                {
                    consolePane = new JEditorPane();
                    consoleScrollPane.setViewportView(consolePane);
                    consolePane.setText("");
                    setConsoleRight();
                    jConsole = new JConsole(System.out, consolePane);
                    System.setOut(jConsole);
                    System.setErr(jConsole);
                    consolePane.setEditable(false);
                    consolePane.addMouseListener(new MouseAdapter() {
                        /* (non-Javadoc)
                         * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent)
                         */
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON3) {
                                consolePane.add(consoleRight);
                                consoleRight.show(e.getComponent(), e.getX(), e.getY());
                            }
                        }
                    });
                }
            }
            {
                infoPanel = new JPanel();
                inst.getContentPane().add(infoPanel, BorderLayout.SOUTH);
                infoPanel.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                infoPanel.setPreferredSize(new Dimension(784, 30));
                infoPanel.setLayout(flowLayout);
                {
                    {
                        statusbar_count = new JTextPane();
                        infoPanel.add(statusbar_count);
                        statusbar_count.setText(
                                CONTEXT.getMessage("event.web.scan.statusbar.count", null, Locale.CHINA));
                        statusbar_count.setBackground(null);
                        statusbar_count.setEditable(false);
                    }
                    {
                        statusbar_count_value = new JTextPane();
                        infoPanel.add(statusbar_count_value);
                        statusbar_count_value.setText(String.valueOf(SCAN_COUNT));
                        statusbar_count_value.setBackground(null);
                        statusbar_count_value.setEditable(false);
                        statusbar_count_value.setEnabled(false);
                    }
                    {
                        programPID = new JTextPane();
                        infoPanel.add(programPID);
                        programPID.setText("PID:");
                        programPID.setBackground(null);
                        programPID.setEditable(false);
                    }
                    {
                        programPID_value = new JTextPane();
                        infoPanel.add(programPID_value);
                        programPID_value.setText(JvmPid.getPID());
                        programPID_value.setBackground(null);
                        programPID_value.setEditable(false);
                        programPID_value.setEnabled(false);
                    }
                    {
                        memory = new JTextPane();
                        infoPanel.add(memory);
                        memory.setText(CONTEXT.getMessage("gobal.gui.memory", null, Locale.CHINA));
                        memory.setBackground(null);
                        memory.setEditable(false);
                    }
                    {
                        memory_value = new JTextPane();
                        infoPanel.add(memory_value);
                        memory_value.setText("0KB");
                        memory_value.setBackground(null);
                        memory_value.setEditable(false);
                        memory_value.setEnabled(false);
                        MemoryListener memory = new MemoryListener(memory_value);
                        memory.start();
                    }
                    {
                        runtime = new JTextPane();
                        infoPanel.add(runtime);
                        runtime.setText(CONTEXT.getMessage("gobal.gui.runtime", null, Locale.CHINA));
                        runtime.setBackground(null);
                        runtime.setEditable(false);
                    }
                    {
                        runtime_value = new JTextPane();
                        infoPanel.add(runtime_value);
                        runtime_value.setText("NULL");
                        runtime_value.setBackground(null);
                        runtime_value.setEditable(false);
                        runtime_value.setEnabled(false);
                    }
                }
            }
            {
                shortcut = new JPanel();
                inst.getContentPane().add(shortcut, BorderLayout.NORTH);
                shortcut.setSize(784, 35);
                shortcut.setPreferredSize(new Dimension(784, 35));
                shortcut.setBorder(new LineBorder(new Color(0, 0, 0), 1, false));
                shortcut.setLayout(new BorderLayout());
                {
                    eventText = new JTextPane();
                    shortcut.add(eventText, BorderLayout.WEST);
                    eventText.setText(CONTEXT.getMessage("event.web.scan.name", null, Locale.CHINA) + ": ");
                    eventText.setEditable(false);
                    eventText.setEnabled(true);
                    eventText.setBackground(null);
                    eventText.setCaretColor(new Color(0, 0, 0));
                }
                {
                    eventTextField = new JTextField();
                    shortcut.add(eventTextField, BorderLayout.CENTER);
                    eventTextField.setSize(500, 25);
                    eventTextField.setText("");
                    eventTextField.setPreferredSize(new Dimension(500, 25));
                    eventTextField.setEditable(false);
                }
                {
                    submit = new JButton();
                    shortcut.add(submit, BorderLayout.EAST);
                    submit.setText(CONTEXT.getMessage("gobal.gui.button.run", null, Locale.CHINA));
                    submit.setSize(new Dimension(75, 25));
                    submit.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                submitActionPerformed(evt);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                }
            }
        }
    });

}

From source file:Main.java

/**
 * @return a new panel whose layout forces the original panel to shrink in
 *         size as much as possible./*from  ww  w .jav a 2 s  .  c  o  m*/
 */
public static JPanel wrapInMinimizer(JPanel panel) {
    JPanel result = new JPanel();
    result.setLayout(new BorderLayout());
    result.add(panel, BorderLayout.WEST);

    return result;
}

From source file:Main.java

public static JPanel createTextComponentPane(String labelText, JTextComponent textComp, Font font,
        Color bgColor, boolean isVertical) {
    JPanel outPane = new JPanel();
    outPane.setLayout(new BorderLayout());
    outPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    JLabel labelOut = new JLabel(labelText, SwingConstants.LEFT);
    if (isVertical) {
        outPane.add(labelOut, BorderLayout.NORTH);
    } else {/*ww w  .j a  v a2 s  .  c o m*/
        outPane.add(labelOut, BorderLayout.WEST);
    }
    if (textComp instanceof JTextArea) {
        outPane.add(createScrollPane((JTextArea) textComp, font, bgColor), BorderLayout.CENTER);
    } else {
        textComp.setBackground(bgColor);
        textComp.setFont(font);
        outPane.add(textComp, BorderLayout.CENTER);
    }
    return outPane;
}

From source file:Main.java

public Main(String title) {
    super(title);
    north = new Button("North");
    south = new Button("South");
    east = new Button("East");
    west = new Button("West");
    center = new Button("Center");
    this.add(north, BorderLayout.NORTH);
    this.add(south, BorderLayout.SOUTH);
    this.add(east, BorderLayout.EAST);
    this.add(west, BorderLayout.WEST);
    this.add(center, BorderLayout.CENTER);
}

From source file:Main.java

public Main() {
    JButton button = new JButton("foo");
    JTextField textField = new JTextField(10);
    Document document = textField.getDocument();
    document.addDocumentListener(new JButtonStateController(button));

    JFrame frame = new JFrame();
    frame.add(button, BorderLayout.WEST);
    frame.add(textField, BorderLayout.CENTER);
    frame.setSize(300, 300);// w w w.  j av a 2  s .c o  m
    frame.setVisible(true);
}

From source file:Main.java

public Main() {
    String[] items = { "Select Item", "Color", "Shape", "Fruit" };
    mainComboBox = new JComboBox(items);
    mainComboBox.addActionListener(this);

    getContentPane().add(mainComboBox, BorderLayout.WEST);

    subComboBox = new JComboBox();
    getContentPane().add(subComboBox, BorderLayout.EAST);

    String[] subItems1 = { "Select Color", "Red", "Blue", "Green" };
    subItems.put(items[1], subItems1);// ww  w. ja va 2s  .  c  o m

    String[] subItems2 = { "Select Shape", "Circle", "Square", "Triangle" };
    subItems.put(items[2], subItems2);

    String[] subItems3 = { "Select Fruit", "Apple", "Orange", "Banana" };
    subItems.put(items[3], subItems3);
}

From source file:BorderLayout1.java

public void init() {
    Container cp = getContentPane();
    cp.add(BorderLayout.NORTH, new JButton("North"));
    cp.add(BorderLayout.SOUTH, new JButton("South"));
    cp.add(BorderLayout.EAST, new JButton("East"));
    cp.add(BorderLayout.WEST, new JButton("West"));
    cp.add(BorderLayout.CENTER, new JButton("Center"));
}