Example usage for java.awt BorderLayout NORTH

List of usage examples for java.awt BorderLayout NORTH

Introduction

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

Prototype

String NORTH

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

Click Source Link

Document

The north layout constraint (top of container).

Usage

From source file:Main.java

public Main() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(400, 400);//www .  j  a  v  a2  s  .c o  m
    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split.setDividerLocation(200);
    add(split);

    JPanel panel1 = new JPanel();
    panel1.setLayout(new BorderLayout());
    panel1.add(new JLabel("top panel"), BorderLayout.NORTH);

    JPanel myDrawPanel = new JPanel();
    myDrawPanel.setPreferredSize(new Dimension(100, 100));
    myDrawPanel.add(new JLabel("draw panel here!"));
    panel1.add(new JScrollPane(myDrawPanel), BorderLayout.CENTER);

    split.setTopComponent(panel1);

    JPanel panel2 = new JPanel();
    panel2.add(new JLabel("bottom panel"));
    split.setBottomComponent(panel2);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());

    list = new JList(label);
    JScrollPane pane = new JScrollPane(list);

    DefaultListSelectionModel m = new DefaultListSelectionModel();

    list.setSelectionModel(m);//from  w  w w.j a  va  2 s  .  c o  m

    System.out.println(m.getLeadSelectionIndex());

    add(pane, BorderLayout.NORTH);
}

From source file:Main.java

public Main() {
    btnNewButton.addActionListener(e -> d.setVisible(true));
    getContentPane().add(btnNewButton, BorderLayout.CENTER);

    slider.addChangeListener(e -> text.setText(Integer.toString(slider.getValue())));

    getContentPane().add(slider, BorderLayout.NORTH);
    d.getContentPane().add(text);/*from  w  w  w .j  ava  2s .com*/
    d.pack();

    pack();
    setVisible(true);
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());

    list = new JList(label);
    JScrollPane pane = new JScrollPane(list);

    DefaultListSelectionModel m = new DefaultListSelectionModel();

    list.setSelectionModel(m);/*from  w  w  w .  j  a  v a 2 s.  com*/

    System.out.println(m.getAnchorSelectionIndex());

    add(pane, BorderLayout.NORTH);
}

From source file:Main.java

public Main(final Frame owner) {
    super(owner);
    JPanel pnl = new JPanel(new BorderLayout());
    pnl.add(new JLabel("Click outside this dialog in the parent frame to close it"), BorderLayout.NORTH);
    JButton btn = new JButton("Click Me");
    btn.addActionListener(e -> JOptionPane.showMessageDialog(Main.this, "New Child Window"));
    pnl.add(btn, BorderLayout.CENTER);
    this.setContentPane(pnl);
    this.pack();//from www .ja va  2s. com
    this.setLocationRelativeTo(owner);
    this.setAlwaysOnTop(true);
    this.addWindowFocusListener(new WindowFocusListener() {
        public void windowGainedFocus(WindowEvent e) {
        }

        public void windowLostFocus(WindowEvent e) {
            if (SwingUtilities.isDescendingFrom(e.getOppositeWindow(), Main.this)) {
                return;
            }
            Main.this.setVisible(false);
        }
    });
}

From source file:Main.java

public void createUI() {
    JPanel borderPanel = new JPanel(new BorderLayout());

    JLabel northLabel = new JLabel("Nawth");
    borderPanel.add(northLabel, BorderLayout.NORTH);

    JComboBox southCombo = new JComboBox();
    borderPanel.add(southCombo, BorderLayout.SOUTH);

    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS));

    JComboBox firstCombo = new JComboBox();
    centerPanel.add(firstCombo);/*from  w  w  w.j  a v  a2s  . c  o m*/
    centerPanel.add(Box.createVerticalGlue());
    JPanel centerPanelConstrain = new JPanel(new GridBagLayout());
    centerPanelConstrain.add(centerPanel);
    borderPanel.add(centerPanelConstrain, BorderLayout.CENTER);

    getContentPane().add(borderPanel);
    pack();
}

From source file:Main.java

public Main() {
    JComboBox comboBox = new JComboBox();
    comboBox.addItem(new Double(1));
    comboBox.addItem(new Double(2.25));
    comboBox.addItem(new Double(3.5));
    comboBox.setRenderer(new TwoDecimalRenderer(comboBox.getRenderer()));
    comboBox.setEditable(true);//from w w  w . jav a  2  s .  c  o  m

    JFrame frame = new JFrame();
    frame.add(comboBox, BorderLayout.NORTH);

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

From source file:MainClass.java

    public SwingTest() {
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  JButton button = new JButton("Press me");
  button.addActionListener(new ButtonListener());
  this.getContentPane().setLayout(new BorderLayout());
  this.getContentPane().add(button, BorderLayout.SOUTH);
  this.getContentPane().add(field, BorderLayout.NORTH);
  this.pack();/*  w  w w .ja  va2 s .co m*/
  this.setVisible(true);
}

From source file:Main.java

private void go() {
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    JPanel topPanel = new JPanel();
    topPanel.add(new JLabel("boo"));

    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel mainInnerPanel = makeMainInnerPanel();

    JScrollPane scrollPane = new JScrollPane(mainInnerPanel);
    mainPanel.add(scrollPane);/*from   w  w  w.  j  a  v a2  s.  co  m*/
    add(topPanel, BorderLayout.NORTH);
    add(mainPanel, BorderLayout.CENTER);

    pack();
    setVisible(true);
}

From source file:CombinedLayoutManager.java

public CombinedLayoutManager() {
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    pane.add(getHeader(), BorderLayout.NORTH);
    pane.add(getTextArea(), BorderLayout.CENTER);
    pane.add(getButtonPanel(), BorderLayout.SOUTH);
}