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:Main.java
public void prepareGUI() { buzz.addActionListener(new BuzzActionListener(this)); setSize(300, 200);/*from w w w . jav a2s. c o m*/ getContentPane().add(buzz, BorderLayout.NORTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:Main.java
private void init() { this.setLayout(new BorderLayout()); JPanel topPanel = new JPanel(); final JLabel topLabel = new JLabel("North"); topPanel.add(topLabel);/*from www. j a va 2s.c o m*/ this.add(topPanel, BorderLayout.NORTH); JTabbedPane tabbedPane = new JTabbedPane(); JPanel firstTabCont = new JPanel(); firstTabCont.add(new JLabel("First")); tabbedPane.addTab("First", firstTabCont); JPanel secondTabCont = new JPanel(); secondTabCont.add(new JLabel("Second")); tabbedPane.addTab("Second", secondTabCont); this.add(tabbedPane, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(); final JLabel bottomLabel = new JLabel("South"); bottomPanel.add(bottomLabel); this.add(bottomPanel, BorderLayout.SOUTH); tabbedPane.addChangeListener(evt -> { JTabbedPane pane = (JTabbedPane) evt.getSource(); int selectedIndex = pane.getSelectedIndex(); if (selectedIndex == 0) { topLabel.setText(""); topLabel.setText("Hi"); bottomLabel.setText(""); bottomLabel.setText("Bye"); } else { topLabel.setText(""); topLabel.setText("Bye"); bottomLabel.setText(""); bottomLabel.setText("Hi"); } }); this.pack(); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); }
From source file:PngIcon.java
public PngIcon() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton bt = new JButton(new ImageIcon("dtmail.png")); JLabel lab = new JLabel(new ImageIcon("dtterm.png")); bt.setFocusPainted(false);// w w w. j ava2 s .c o m frame.add(bt, BorderLayout.NORTH); frame.add(lab, BorderLayout.SOUTH); frame.setBounds(50, 50, 200, 200); frame.setVisible(true); }
From source file:JWindowNoTitleBar.java
public JWindowNoTitleBar() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().add(new JLabel("About"), BorderLayout.NORTH); window.getContentPane().add(new JLabel("Label", SwingConstants.CENTER), BorderLayout.CENTER); JButton b = new JButton("Close"); window.getContentPane().add(b, BorderLayout.SOUTH); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setVisible(false);/*from w w w . jav a 2s .c o m*/ } }); window.pack(); window.setBounds(50, 50, 200, 200); b = new JButton("About..."); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setVisible(true); } }); getContentPane().add(b); pack(); }
From source file:Main.java
public Main() { formatText.setColumns(20);//from w w w . ja v a2 s . co m formatText.setText("00:00"); setLayout(new BorderLayout()); add(new JLabel("Enter only numbers"), BorderLayout.NORTH); add(formatText, BorderLayout.CENTER); }
From source file:BorderLayout1.java
public void init() { Container cp = getContentPane(); cp.add(BorderLayout.NORTH, new JButton("North")); cp.add(BorderLayout.SOUTH, new JButton("South")); cp.add(BorderLayout.EAST, new JButton("East")); cp.add(BorderLayout.WEST, new JButton("West")); cp.add(BorderLayout.CENTER, new JButton("Center")); }
From source file:Main.java
public Main() { textField.setText("Hit Enter to Add Text to Text Pane"); getContentPane().add(textField, BorderLayout.NORTH); textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Document doc = textPane.getDocument(); doc.insertString(doc.getLength(), " " + textField.getText(), null); textField.setText("");//clear Dimension d = textPane.getPreferredSize(); Rectangle r = textPane.modelToView(textPane.getDocument().getLength()); d.height = r.y + r.height; textPane.setPreferredSize(d); getContentPane().validate(); } catch (Exception e2) { }/*w w w .ja v a2 s.c o m*/ } }); JPanel south = new JPanel(); textPane = new JTextPane(); textPane.setText("Some \ntext"); textPane.setEditable(false); textPane.setPreferredSize(new Dimension(120, 23)); south.add(textPane); getContentPane().add(south, BorderLayout.SOUTH); }
From source file:Main.java
public Main() { Container content = getContentPane(); content.setBackground(Color.white); JSlider slider1 = new JSlider(); slider1.setBorder(BorderFactory.createTitledBorder("JSlider without Tick Marks")); content.add(slider1, BorderLayout.NORTH); JSlider slider2 = new JSlider(); slider2.setBorder(BorderFactory.createTitledBorder("JSlider with Tick Marks")); slider2.setMajorTickSpacing(20);/*ww w . j a v a 2 s . c o m*/ slider2.setMinorTickSpacing(5); slider2.setPaintTicks(true); content.add(slider2, BorderLayout.CENTER); JSlider slider3 = new JSlider(); slider3.setBorder(BorderFactory.createTitledBorder("JSlider with Tick Marks & Labels")); slider3.setMajorTickSpacing(20); slider3.setMinorTickSpacing(5); slider3.setPaintTicks(true); slider3.setPaintLabels(true); content.add(slider3, BorderLayout.SOUTH); setSize(300, 300); setVisible(true); }
From source file:Main.java
public Main() { box.setBackground(Color.RED); box.addFocusListener(getFocusListener()); JTextField f = new JTextField(); add(box, BorderLayout.SOUTH); add(f, BorderLayout.NORTH); pack();/*from www .j av a 2s . co m*/ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); }
From source file:Main.java
public Main() { Object[] items = { Color.red, Color.green, Color.blue }; JComboBox comboBox = new JComboBox(items); comboBox.setRenderer(new ColorRenderer(comboBox)); getContentPane().add(comboBox, BorderLayout.NORTH); add(new JTextField(), BorderLayout.SOUTH); }