Example usage for java.awt BorderLayout SOUTH

List of usage examples for java.awt BorderLayout SOUTH

Introduction

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

Prototype

String SOUTH

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

Click Source Link

Document

The south layout constraint (bottom of container).

Usage

From source file:Main.java

public Main() {
    childPanel1.setBackground(Color.red);
    childPanel1.setPreferredSize(new Dimension(300, 40));
    childPanel2.setBackground(Color.blue);
    childPanel2.setPreferredSize(new Dimension(300, 40));
    childPanel3.setBackground(Color.yellow);
    childPanel3.setPreferredSize(new Dimension(300, 40));

    JButton myButton = new JButton("Add Component ");
    myButton.addActionListener(e -> {
        add(childPanel2, BorderLayout.CENTER);
        pack();/*from   w  w w. j a v a  2  s.  co m*/
    });
    setLocation(10, 200);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    add(childPanel3, BorderLayout.CENTER);
    add(myButton, BorderLayout.SOUTH);
    pack();
    setVisible(true);
}

From source file:Main.java

private void init() {
    this.setLayout(new BorderLayout());
    JPanel topPanel = new JPanel();
    final JLabel topLabel = new JLabel("North");
    topPanel.add(topLabel);//  w ww  . j  a v a2 s . c  o m
    this.add(topPanel, BorderLayout.NORTH);

    JTabbedPane tabbedPane = new JTabbedPane();
    JPanel firstTabCont = new JPanel();
    firstTabCont.add(new JLabel("First"));
    tabbedPane.addTab("First", firstTabCont);

    JPanel secondTabCont = new JPanel();
    secondTabCont.add(new JLabel("Second"));
    tabbedPane.addTab("Second", secondTabCont);

    this.add(tabbedPane, BorderLayout.CENTER);

    JPanel bottomPanel = new JPanel();
    final JLabel bottomLabel = new JLabel("South");
    bottomPanel.add(bottomLabel);
    this.add(bottomPanel, BorderLayout.SOUTH);

    tabbedPane.addChangeListener(evt -> {
        JTabbedPane pane = (JTabbedPane) evt.getSource();
        int selectedIndex = pane.getSelectedIndex();
        if (selectedIndex == 0) {
            topLabel.setText("");
            topLabel.setText("Hi");

            bottomLabel.setText("");
            bottomLabel.setText("Bye");
        } else {
            topLabel.setText("");
            topLabel.setText("Bye");

            bottomLabel.setText("");
            bottomLabel.setText("Hi");
        }

    });
    this.pack();
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);
}

From source file:Main.java

public Main() {
    addTabButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            add();/*from  ww w.ja  v a  2 s. com*/
        }
    });
    closeButtonSize = new Dimension(closeXIcon.getIconWidth() + 2, closeXIcon.getIconHeight() + 2);

    frame.add(tabbedPane, BorderLayout.CENTER);
    frame.add(addTabButton, BorderLayout.SOUTH);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.pack();
    frame.setMinimumSize(new Dimension(300, 300));
    frame.setVisible(true);

}

From source file:ContextMenu.java

public ContextMenu() {
    final JPopupMenu contextMenu = new JPopupMenu("Edit");
    contextMenu.add(makeMenuItem("Save"));
    contextMenu.add(makeMenuItem("Save As"));
    contextMenu.add(makeMenuItem("Close"));

    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    frame.add(panel);//w w w . j  a va  2s .c o  m
    panel.setComponentPopupMenu(contextMenu);

    textArea.setInheritsPopupMenu(true);
    panel.add(BorderLayout.CENTER, textArea);

    JTextField textField = new JTextField();
    textField.setInheritsPopupMenu(true);
    panel.add(BorderLayout.SOUTH, textField);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 200);
    frame.setVisible(true);
}

From source file:Main.java

public Main() {
    Vector model = new Vector();
    model.addElement(new Item(1, "A"));
    model.addElement(new Item(2, "B"));
    model.addElement(new Item(3, "C"));
    model.addElement(new Item(4, "D"));

    JComboBox comboBox = new JComboBox(model);
    comboBox.addActionListener(this);
    comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    getContentPane().add(comboBox, BorderLayout.NORTH);

    comboBox = new JComboBox(model);
    comboBox.setRenderer(new ItemRenderer());
    comboBox.addActionListener(this);
    getContentPane().add(comboBox, BorderLayout.SOUTH);
}

From source file:SwingScrollBarExample.java

public SwingScrollBarExample() {
    super(true);/*from   ww  w . j  a  v  a 2 s  .  c o  m*/
    label = new JLabel();
    setLayout(new BorderLayout());

    JScrollBar hbar = new JScrollBar(JScrollBar.HORIZONTAL, 30, 20, 0, 300);
    JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);

    hbar.setUnitIncrement(2);
    hbar.setBlockIncrement(1);

    hbar.addAdjustmentListener(new MyAdjustmentListener());
    vbar.addAdjustmentListener(new MyAdjustmentListener());

    add(hbar, BorderLayout.SOUTH);
    add(vbar, BorderLayout.EAST);
    add(label, BorderLayout.CENTER);
}

From source file:JDK6TabbedPaneExample.java

public JDK6TabbedPaneExample() {

    addTabButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            add();/*from ww w  . ja  v  a  2s  .c om*/

        }

    });
    closeButtonSize = new Dimension(closeXIcon.getIconWidth() + 2, closeXIcon.getIconHeight() + 2);

    frame.add(tabbedPane, BorderLayout.CENTER);
    frame.add(addTabButton, BorderLayout.SOUTH);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.pack();
    frame.setMinimumSize(new Dimension(300, 300));
    frame.setVisible(true);

}

From source file:WebBrowserBasedOnJEditorPane.java

public WebBrowserBasedOnJEditorPane() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JPanel pnlURL = new JPanel();
    pnlURL.setLayout(new BorderLayout());
    pnlURL.add(new JLabel("URL: "), BorderLayout.WEST);
    pnlURL.add(txtURL, BorderLayout.CENTER);
    getContentPane().add(pnlURL, BorderLayout.NORTH);
    getContentPane().add(ep, BorderLayout.CENTER);

    getContentPane().add(lblStatus, BorderLayout.SOUTH);

    ActionListener al = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                String url = ae.getActionCommand().toLowerCase();
                if (url.startsWith("http://"))
                    url = url.substring(7);
                ep.setPage("http://" + IDN.toASCII(url));
            } catch (Exception e) {
                e.printStackTrace();//ww w .  j a v  a  2s . c  om
                JOptionPane.showMessageDialog(WebBrowserBasedOnJEditorPane.this,
                        "Browser problem: " + e.getMessage());
            }
        }
    };
    txtURL.addActionListener(al);

    setSize(300, 300);
    setVisible(true);
}

From source file:Main.java

public Main() {
    JPanel parentPanel = new JPanel();
    parentPanel.setLayout(new BorderLayout(10, 10));

    JPanel childPanel1 = new JPanel();
    childPanel1.setBackground(Color.red);
    childPanel1.setPreferredSize(new Dimension(300, 40));

    JPanel childPanel2 = new JPanel();
    childPanel2.setBackground(Color.blue);
    childPanel2.setPreferredSize(new Dimension(800, 600));

    JButton myButton = new JButton("Add Component ");
    myButton.addActionListener(e -> {
        parentPanel.remove(childPanel1);
        parentPanel.add(childPanel2, BorderLayout.CENTER);
        parentPanel.revalidate();//from   ww w. java  2  s.  c  om
        parentPanel.repaint();
        pack();
    });
    setLocation(10, 200);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    parentPanel.add(childPanel1, BorderLayout.CENTER);
    parentPanel.add(myButton, BorderLayout.SOUTH);
    add(parentPanel);
    pack();
    setVisible(true);
}

From source file:MyFormatter.java

public Main() {
    JPanel panel = new JPanel();
    JLabel label = new JLabel("Number :");
    JFormattedTextField tf = new JFormattedTextField(new MyFormatter());
    tf.setColumns(10);//from w ww. j  a v a2  s  .c  om
    panel.add(label);
    panel.add(tf);
    getContentPane().add(panel, BorderLayout.SOUTH);
    pack();
}