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 JFrame createJFrame(int width, int height) {
    JFrame f = new JFrame();
    f.setSize(width, height);//from ww w .  j  a  v  a  2  s . c  o m
    f.getContentPane().setLayout(new BorderLayout());

    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    return f;
}

From source file:Main.java

public static void showFrameWithToolBar(String toolBarPosition) {

    JPanel gui = new JPanel(new BorderLayout());

    JToolBar tb = new JToolBar();

    gui.add(tb, toolBarPosition);/* w w w.j  a  v a  2s  .c  om*/
    tb.add(new JButton("Button 1"));
    tb.add(new JButton("Button 2"));
    tb.addSeparator();
    tb.add(new JButton("Button 3"));
    tb.add(new JCheckBox("Check 1", true));

    JFrame f = new JFrame(toolBarPosition);
    f.setContentPane(gui);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLocationByPlatform(true);
    f.pack();

    f.setSize(400, 120);
    f.setVisible(true);
}

From source file:Main.java

public static JPanel newPane(String labelText) {
    JPanel pane = new JPanel(new BorderLayout());
    pane.add(newLabel(labelText));/*from   w  w  w.  j av  a2 s . co m*/
    pane.add(newButton("Open dialog"), BorderLayout.SOUTH);
    return pane;
}

From source file:Main.java

public static JPanel placeInTitledEtchedJPanel(Component c, String title, Color titleColor) {
    JPanel parent = new JPanel(new BorderLayout());
    parent.add(c, BorderLayout.CENTER);
    TitledBorder tb = new TitledBorder(title);
    tb.setBorder(BorderFactory.createEtchedBorder());
    tb.setTitleColor(titleColor);//from w  w  w  .  j a va2  s .com
    parent.setBorder(tb);
    return parent;
}

From source file:Main.java

public static void setupNowLoadingPanel(JPanel panel) {
    JLabel loading = new JLabel("Loading...", SwingConstants.CENTER);
    panel.setLayout(new BorderLayout());
    panel.add(loading, BorderLayout.CENTER);
    panel.revalidate();/* ww  w. j av  a2  s.  c o  m*/
    panel.repaint();
}

From source file:MainClass.java

public static JPanel demo1() {
    JPanel pan = new JPanel(new BorderLayout());
    pan.setBorder(new TitledBorder("Demo 1: format toggles with focus"));

    MaskFormatter withFocus = null, withoutFocus = null;
    try {/*from  ww w  . jav  a2 s. co m*/
        withFocus = new MaskFormatter("LLLL");
        withoutFocus = new MaskFormatter("UUUU");
    } catch (ParseException pe) {
    }

    DefaultFormatterFactory factory = new DefaultFormatterFactory(withoutFocus, null, withFocus);

    JFormattedTextField field = new JFormattedTextField(factory);
    field.setValue("Four");
    pan.add(field, BorderLayout.CENTER);

    return pan;
}

From source file:Main.java

static public JDialog addDialogWindow(Frame mainWindow, Component jpanel, String title) {
    JDialog dialog = new JDialog(mainWindow, title, true);
    dialog.getContentPane().setLayout(new BorderLayout());
    dialog.getContentPane().add(jpanel, BorderLayout.CENTER);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.pack();/*from  w  ww .j a  va  2  s  .co  m*/
    dialog.setLocationRelativeTo(mainWindow);
    dialog.setSize(jpanel.getPreferredSize());
    dialog.setVisible(true);
    return dialog;
}

From source file:Main.java

private static JPanel getPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JLabel("Top"), BorderLayout.NORTH);
    panel.add(new JLabel("Center"), BorderLayout.CENTER);
    panel.add(new JLabel("Bottom"), BorderLayout.SOUTH);
    panel.setPreferredSize(new Dimension(400, 300));
    return panel;
}

From source file:Main.java

/**
 * Creates a JPanel containing the component hugging the top side
 * @param component the component to wrap
 * @return a JPanel containing the component hugging the top side
 *//*w ww  .ja v a  2s.  c  o m*/
public static JPanel hugNorth(JComponent component) {
    final JPanel result = new JPanel(new BorderLayout());
    result.add(component, BorderLayout.NORTH);
    return result;
}

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
 *//*w  ww.j a va 2  s .  co m*/
public static JPanel hugWest(JComponent component) {
    final JPanel result = new JPanel(new BorderLayout());
    result.add(component, BorderLayout.WEST);
    return result;
}