List of usage examples for java.awt BorderLayout NORTH
String NORTH
To view the source code for java.awt BorderLayout NORTH.
Click Source Link
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("JSpinner Dates"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model1 = new SpinnerListModel(); JSpinner spinner1 = new JSpinner(model1); JLabel label1 = new JLabel("None"); 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);//w w w .ja va 2 s .c om frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("java2s.com"); JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(label);//from w ww .j a v a2s . co m JPanel buttons = new JPanel(new GridLayout(0, 1)); for (int index = 0; index < 10; index++) { buttons.add(new JButton(String.valueOf(index))); } JPanel right = new JPanel(new BorderLayout()); right.add(buttons, BorderLayout.NORTH); frame.add(right, BorderLayout.EAST); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:BorderLayoutExample.java
public static void main(String[] args) { BorderSample bs = new BorderSample(); bs.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = bs.getContentPane(); pane.setLayout(new BorderLayout()); JLabel label = new JLabel("North", JLabel.CENTER); label.setFont(new Font("Courier", Font.BOLD, 36)); label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); pane.add(label, BorderLayout.NORTH); label = new JLabel("South", JLabel.CENTER); label.setFont(new Font("Courier", Font.BOLD, 36)); label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); pane.add(label, BorderLayout.SOUTH); label = new JLabel("East", JLabel.CENTER); label.setFont(new Font("Courier", Font.BOLD, 36)); label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); pane.add(label, BorderLayout.EAST); label = new JLabel("West", JLabel.CENTER); label.setFont(new Font("Courier", Font.BOLD, 36)); label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); pane.add(label, BorderLayout.WEST); label = new JLabel("Center", JLabel.CENTER); label.setFont(new Font("Courier", Font.BOLD, 36)); label.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); pane.add(label, BorderLayout.CENTER); bs.setSize(400, 300);//from w w w.ja va 2 s.c om bs.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Label Focus Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField);//from w w w . j av a 2 s . com panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); frame.add(new JButton("Somewhere Else"), BorderLayout.SOUTH); frame.setSize(250, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String TITLE = "Full Screen Test"; JFrame f = new JFrame(TITLE); JDesktopPane jdp = new JDesktopPane(); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice dev = env.getDefaultScreenDevice(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JInternalFrame jif = new JInternalFrame(TITLE, true, true, true); jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.NORTH); jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.CENTER); jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.SOUTH); jif.pack();/*from w w w . j a v a 2s . c o m*/ jif.setLocation(100, 100); jif.setVisible(true); jdp.add(jif); f.add(jdp, BorderLayout.CENTER); dev.setFullScreenWindow(f); }
From source file:Main.java
public static void main(String[] args) { JFrame parentFrame = new JFrame(); parentFrame.setSize(500, 150);/*from w w w .j a v a2s. co m*/ JLabel jl = new JLabel(); jl.setText("Count : 0"); parentFrame.add(BorderLayout.CENTER, jl); parentFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); parentFrame.setVisible(true); final JDialog dlg = new JDialog(parentFrame, "Progress Dialog", true); JProgressBar dpb = new JProgressBar(0, 500); dlg.add(BorderLayout.CENTER, dpb); dlg.add(BorderLayout.NORTH, new JLabel("Progress...")); dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dlg.setSize(300, 75); dlg.setLocationRelativeTo(parentFrame); Thread t = new Thread(new Runnable() { public void run() { dlg.setVisible(true); } }); t.start(); for (int i = 0; i <= 500; i++) { jl.setText("Count : " + i); dpb.setValue(i); if (dpb.getValue() == 500) { dlg.setVisible(false); System.exit(0); } try { Thread.sleep(25); } catch (InterruptedException e) { e.printStackTrace(); } } dlg.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); textField.setHorizontalAlignment(JTextField.CENTER); label.setLabelFor(textField);/*from ww w . j a va 2s . com*/ panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); frame.setSize(250, 150); frame.setVisible(true); }
From source file:LabelFor.java
public static void main(String args[]) { JFrame f = new JFrame("LabelFor Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = f.getContentPane(); JLabel label = new JLabel("Username"); JTextField textField = new JTextField(); label.setDisplayedMnemonic(KeyEvent.VK_U); label.setLabelFor(textField);//from w w w. j av a 2 s . c o m Container box = Box.createHorizontalBox(); box.add(label); box.add(textField); content.add(box, BorderLayout.NORTH); content.add(new JButton("Submit"), BorderLayout.SOUTH); f.setSize(300, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Label Focus Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name: "); label.setDisplayedMnemonic(KeyEvent.VK_N); JTextField textField = new JTextField(); label.setLabelFor(textField);// w ww. java2 s . c o m panel.add(label, BorderLayout.WEST); panel.add(textField, BorderLayout.CENTER); frame.add(panel, BorderLayout.NORTH); frame.setSize(250, 150); frame.setVisible(true); textField.setText("Loooooooooooooooooooooooooooooooooooooooooooooooooooooooong"); BoundedRangeModel model = textField.getHorizontalVisibility(); int extent = model.getExtent(); textField.setScrollOffset(extent); System.out.println("extent:" + extent); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JPasswordField Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = f.getContentPane(); content.setLayout(new BorderLayout()); Box rowOne = Box.createHorizontalBox(); rowOne.add(new JLabel("Username")); rowOne.add(new JTextField()); Box rowTwo = Box.createHorizontalBox(); rowTwo.add(new JLabel("Password")); rowTwo.add(new JPasswordField()); content.add(rowOne, BorderLayout.NORTH); content.add(rowTwo, BorderLayout.SOUTH); f.setSize(300, 200);// ww w .j a v a 2 s . co m f.setVisible(true); }