Example usage for javax.swing JPanel JPanel

List of usage examples for javax.swing JPanel JPanel

Introduction

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

Prototype

public JPanel(boolean isDoubleBuffered) 

Source Link

Document

Creates a new JPanel with FlowLayout and the specified buffering strategy.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel(new BorderLayout());
    JPanel panel2 = new JPanel(new BorderLayout());
    panel2.add(new JButton("NORTH"), BorderLayout.NORTH);
    panel2.add(new JButton("CENTER"));
    panel.add(panel2);//from w w  w  .  j a  v  a  2 s  . c o m
    panel.add(new JButton("SOUTH"), BorderLayout.SOUTH);
    panel.add(new JButton("EAST"), BorderLayout.EAST);
    frame.add(panel);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JButton component1 = new JButton();
    JButton component2 = new JButton();

    int rows = 2;
    int cols = 2;
    JPanel panel = new JPanel(new GridLayout(rows, cols));
    panel.add(component1);/*from   www  .  ja  v a2 s .  com*/
    panel.add(component2);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    JButton component1 = new JButton();
    JButton component2 = new JButton();
    int align = FlowLayout.CENTER; // or LEFT, RIGHT
    JPanel panel = new JPanel(new FlowLayout(align));
    panel.add(component1);/*www  .  j a v a 2 s . com*/
    panel.add(component2);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel gui = new JPanel(new BorderLayout(5, 5));

    int sz = 4;//from   w w  w  . j  av  a2  s .  c  o  m
    Container content = new JPanel(new GridLayout(sz, 0, 2, 2));
    for (int f = 0; f < sz * sz; f++) {
        content.add(new JButton());
    }
    gui.add(content, BorderLayout.CENTER);

    Container info = new JPanel(new FlowLayout(FlowLayout.CENTER, 50, 5));
    info.add(new JLabel("Flow"));
    info.add(new JLabel("Layout"));
    gui.add(info, BorderLayout.PAGE_START);

    gui.add(new JLabel("Label"), BorderLayout.LINE_END);

    JOptionPane.showMessageDialog(null, gui);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel ui = new JPanel(new BorderLayout(20, 20));

    ui.setBorder(new LineBorder(Color.RED, 1));

    JTextField fileName = new JTextField();
    ui.add(fileName, BorderLayout.NORTH);

    JPanel buttonPanel = new JPanel(new GridLayout(1, 0, 10, 30));
    ui.add(buttonPanel, BorderLayout.CENTER);

    JButton creater = new JButton("Create File");
    buttonPanel.add(creater);/*from   www  .  j a v  a  2s . c o m*/
    JButton deleter = new JButton("Delete File");
    buttonPanel.add(deleter);

    JOptionPane.showMessageDialog(null, ui);

}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel outerPanel = new JPanel(new BorderLayout());
    JPanel topPanel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Name:");
    JTextField text = new JTextField();
    topPanel.add(label, BorderLayout.PAGE_START);
    topPanel.add(text, BorderLayout.CENTER);
    outerPanel.add(topPanel, BorderLayout.AFTER_LAST_LINE);

    frame.add(outerPanel);//from  ww  w  . j  ava 2s  . co m
    frame.setSize(300, 200);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel outerPanel = new JPanel(new BorderLayout());
    JPanel topPanel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Name:");
    JTextField text = new JTextField();
    topPanel.add(label, BorderLayout.LINE_START);
    topPanel.add(text, BorderLayout.CENTER);
    outerPanel.add(topPanel, BorderLayout.AFTER_LAST_LINE);

    frame.add(outerPanel);/*from  w ww  .  java2  s .c  o m*/
    frame.setSize(300, 200);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel outerPanel = new JPanel(new BorderLayout());
    JPanel topPanel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Name:");
    JTextField text = new JTextField();
    topPanel.add(label, BorderLayout.PAGE_END);
    topPanel.add(text, BorderLayout.CENTER);
    outerPanel.add(topPanel, BorderLayout.AFTER_LAST_LINE);

    frame.add(outerPanel);/* w w  w  . ja va 2 s  .  c om*/
    frame.setSize(300, 200);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel outerPanel = new JPanel(new BorderLayout());
    JPanel topPanel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Name:");
    JTextField text = new JTextField();
    topPanel.add(label, BorderLayout.LINE_END);
    topPanel.add(text, BorderLayout.CENTER);
    outerPanel.add(topPanel, BorderLayout.AFTER_LAST_LINE);

    frame.add(outerPanel);/* w ww .  j  a v a  2 s .c  o m*/
    frame.setSize(300, 200);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel outerPanel = new JPanel(new BorderLayout());
    JPanel topPanel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Name:");
    JTextField text = new JTextField();
    topPanel.add(label, BorderLayout.BEFORE_LINE_BEGINS);
    topPanel.add(text, BorderLayout.CENTER);
    outerPanel.add(topPanel, BorderLayout.AFTER_LINE_ENDS);

    frame.add(outerPanel);/*from  w ww  . jav  a 2  s.  co  m*/
    frame.setSize(300, 200);
    frame.setVisible(true);

}