Example usage for java.awt BorderLayout BorderLayout

List of usage examples for java.awt BorderLayout BorderLayout

Introduction

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

Prototype

public BorderLayout() 

Source Link

Document

Constructs a new border layout with no gaps between components.

Usage

From source file:Main.java

public static void main(String[] arg) throws Exception {
    Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
    Robot robot = new Robot();

    BufferedImage image = robot//  w w w . j  a  v  a 2 s. c om
            .createScreenCapture(new Rectangle(0, 0, (int) screenDim.getWidth(), (int) screenDim.getHeight()));

    JWindow window = new JWindow(new JFrame());
    window.getContentPane().setLayout(new BorderLayout());
    window.getContentPane().add(BorderLayout.CENTER, new JLabel(new ImageIcon(image)));
    window.pack();
    window.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    final JTextPane tp = new JTextPane();
    JButton withFocus = new JButton("Select with focus");
    withFocus.addActionListener(e -> {
        tp.selectAll();//from   w w w.  ja  va  2 s. c  o m
        tp.requestFocus();
    });
    JButton withOutFocus = new JButton("Select without focus");
    withFocus.addActionListener(e -> tp.selectAll());

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(new JScrollPane(tp));
    JPanel panel = new JPanel();
    panel.add(withFocus);
    panel.add(withOutFocus);
    frame.add(panel, BorderLayout.SOUTH);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JDesktopPane dp = new JDesktopPane();
    JInternalFrame inf = new JInternalFrame("Help", true, true, true, true);
    inf.setSize(200, 200);//from w w w. java 2s  .c o  m
    inf.setVisible(true);
    dp.add(inf);

    JButton btn = new JButton("Click");
    btn.addActionListener(e -> JOptionPane.showInternalInputDialog(inf, "Hit me"));
    inf.add(btn);

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new BorderLayout());
    f.add(dp);
    f.setSize(400, 400);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    NumberFormat numberFormatGuFalse = NumberFormat.getNumberInstance();
    numberFormatGuFalse.setGroupingUsed(false);
    JFormattedTextField jftFieldGuFalse = new JFormattedTextField(numberFormatGuFalse);

    NumberFormat numberFormatGuTrue = NumberFormat.getNumberInstance();
    // numberFormatGuFalse.setGroupingUsed(true); // not necessary as is default
    JFormattedTextField jftFieldGuTrue = new JFormattedTextField(numberFormatGuTrue);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(jftFieldGuFalse, BorderLayout.NORTH);
    panel.add(jftFieldGuTrue, BorderLayout.SOUTH);

    JFrame frame = new JFrame();
    frame.getContentPane().add(panel);/*w  w w  . j a  v a  2 s  .co  m*/
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    ImageIcon icon = new ImageIcon(new URL("http://www.java2s.com/style/download.png"));
    JLabel iconLabel = new JLabel(icon);
    JPanel iconPanel = new JPanel(new GridBagLayout());
    iconPanel.add(iconLabel);//from   w  w w .  ja v  a 2 s.c  o  m

    JPanel textPanel = new JPanel(new GridLayout(0, 1));
    for (int i = 0; i < 15; i++) {
        textPanel.add(new JLabel("Hello"));
    }

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(textPanel);
    mainPanel.add(iconPanel, BorderLayout.WEST);
    JOptionPane.showMessageDialog(null, mainPanel, "Center Image Dialog", JOptionPane.PLAIN_MESSAGE);
}

From source file:Main.java

public static void main(String[] args) {
    JTree tree = new JTree(new TestModel());
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(new JScrollPane(tree));
    frame.pack();//from ww w  .j  a va2s  .c  o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JFrame f = new JFrame(Main.class.getSimpleName());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    BufferedImage bi = ImageIO.read(new URL("http://www.java2s.com/style/download.png"));
    JPanel panel = new JPanel(new BorderLayout());
    JLabel label = new JLabel(new ImageIcon(bi));
    panel.add(label);/*from  w ww.j  a va2  s  .co m*/
    MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {
            Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
            ((JPanel) e.getSource()).scrollRectToVisible(r);
        }
    };
    panel.addMouseMotionListener(doScrollRectToVisible);

    panel.setAutoscrolls(true);
    f.add(new JScrollPane(panel));
    f.pack();
    f.setSize(f.getWidth() / 2, f.getHeight() / 2);
    f.setVisible(true);
}

From source file:Main.java

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

    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);

    String days[] = symbols.getWeekdays();
    SpinnerModel model1 = new SpinnerListModel(days);
    JSpinner spinner1 = new JSpinner(model1);

    JLabel label1 = new JLabel("French Days/List");
    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(label1, BorderLayout.WEST);
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.NORTH);

    frame.setSize(200, 90);//from w  w w.  j  a v  a2 s .c o m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(200, 200);/*  w ww .  j  ava2  s . c om*/
    f.getContentPane().setLayout(new BorderLayout());
    JTextPane jtp = new JTextPane();
    jtp.setEditorKit(new WrapEditorKit());
    JScrollPane jsp = new JScrollPane(jtp);
    jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    f.getContentPane().add(jsp, BorderLayout.CENTER);
    jtp.setText("thisIsATestThisisAtestthisIsATestThisisAtestthisIsATestThisisAtest");
    f.setVisible(true);
}

From source file:SpinnerStringsSample.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JSpinner Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);

    String days[] = symbols.getWeekdays();
    SpinnerModel model1 = new SpinnerListModel(days);
    JSpinner spinner1 = new JSpinner(model1);

    JLabel label1 = new JLabel("French Days/List");
    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(label1, BorderLayout.WEST);
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.NORTH);

    frame.setSize(200, 90);//from w w w. java2s.  co m
    frame.setVisible(true);
}