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 static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JToggleButton toggleButton = new JToggleButton("Toggle Button"); // Define ActionListener ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); System.out.println("Action - selected=" + selected + "\n"); }//from w w w. j av a2s .c o m }; // Attach Listeners toggleButton.addActionListener(actionListener); frame.add(toggleButton, BorderLayout.NORTH); frame.setSize(300, 125); frame.setVisible(true); }
From source file:ALineBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Line Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border thinBorder = LineBorder.createBlackLineBorder(); Border thickBorder = new LineBorder(Color.white, 12); Border roundedBorder = new LineBorder(Color.black, 12, true); JButton thinButton = new JButton("1 Pixel"); thinButton.setBorder(thinBorder);/*from w w w. jav a 2 s . c o m*/ JButton thickButton = new JButton("12 Pixel"); thickButton.setBorder(thickBorder); JButton roundedButton = new JButton("Rounded 12 Pixel"); roundedButton.setBorder(roundedBorder); Container contentPane = frame.getContentPane(); contentPane.add(thinButton, BorderLayout.NORTH); contentPane.add(thickButton, BorderLayout.CENTER); contentPane.add(roundedButton, BorderLayout.SOUTH); frame.pack(); frame.setSize(300, frame.getHeight()); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Selecting Toggle"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JToggleButton toggleButton = new JToggleButton("Toggle Button"); // Define ActionListener ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); System.out.println("Action - selected=" + selected + "\n"); }/*w ww.j a va2s . c o m*/ }; // Attach Listeners toggleButton.addActionListener(actionListener); frame.add(toggleButton, BorderLayout.NORTH); frame.setSize(300, 125); frame.setVisible(true); }
From source file:MyComboBoxUI.java
public static void main(String args[]) { String labels[] = { "A", "B", "C", "D" }; JFrame frame = new JFrame("Popup JComboBox"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComboBox comboBox = new JComboBox(labels); comboBox.setUI((ComboBoxUI) MyComboBoxUI.createUI(comboBox)); frame.add(comboBox, BorderLayout.NORTH); JComboBox comboBox2 = new JComboBox(labels); frame.add(comboBox2, BorderLayout.SOUTH); frame.setSize(300, 100);//from w w w .j a va2 s.c o m frame.setVisible(true); }
From source file:ALineBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Line Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border thinBorder = LineBorder.createBlackLineBorder(); Border thickBorder = new LineBorder(Color.WHITE, 12); Border roundedBorder = new LineBorder(Color.BLACK, 2, true); JButton thinButton = new JButton("1 Pixel"); thinButton.setBorder(thinBorder);//from ww w . j av a 2 s. c om JButton thickButton = new JButton("12 Pixel"); thickButton.setBorder(thickBorder); JButton roundedButton = new JButton("Rounded 2 Pixel"); roundedButton.setBorder(roundedBorder); Container contentPane = frame.getContentPane(); contentPane.add(thinButton, BorderLayout.NORTH); contentPane.add(thickButton, BorderLayout.CENTER); contentPane.add(roundedButton, BorderLayout.SOUTH); frame.pack(); frame.setSize(300, frame.getHeight()); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Verifier Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField textField1 = new JTextField(); JTextField textField2 = new JTextField(); InputVerifier verifier = new InputVerifier() { public boolean verify(JComponent comp) { boolean returnValue; JTextField textField = (JTextField) comp; try { Integer.parseInt(textField.getText()); returnValue = true;//w w w.ja v a2 s .co m } catch (NumberFormatException e) { returnValue = false; } return returnValue; } }; textField1.setInputVerifier(verifier); frame.add(textField1, BorderLayout.NORTH); frame.add(textField2, BorderLayout.CENTER); frame.setSize(300, 100); frame.setVisible(true); }
From source file:MovingIconTest.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); JButton b;/*from w w w . jav a 2 s . c o m*/ Icon icon = new PieIcon(Color.red); b = new JButton("Default", icon); contentPane.add(b, BorderLayout.NORTH); b = new JButton("Text Left", icon); b.setHorizontalTextPosition(JButton.LEFT); contentPane.add(b, BorderLayout.SOUTH); b = new JButton("Text Up", icon); b.setHorizontalTextPosition(JButton.CENTER); b.setVerticalTextPosition(JButton.TOP); contentPane.add(b, BorderLayout.EAST); b = new JButton("Text Down", icon); b.setHorizontalTextPosition(JButton.CENTER); b.setVerticalTextPosition(JButton.BOTTOM); contentPane.add(b, BorderLayout.WEST); b = new JButton("Align Bottom Left", icon); b.setHorizontalAlignment(JButton.LEFT); b.setVerticalAlignment(JButton.BOTTOM); contentPane.add(b, BorderLayout.CENTER); frame.setSize(300, 200); frame.show(); }
From source file:CaretSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Caret Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = frame.getContentPane(); JTextArea textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); content.add(scrollPane, BorderLayout.CENTER); final JTextField dot = new JTextField(); dot.setEditable(false);/*from ww w . j a v a2s. c om*/ JPanel dotPanel = new JPanel(new BorderLayout()); dotPanel.add(new JLabel("Dot: "), BorderLayout.WEST); dotPanel.add(dot, BorderLayout.CENTER); content.add(dotPanel, BorderLayout.NORTH); final JTextField mark = new JTextField(); mark.setEditable(false); JPanel markPanel = new JPanel(new BorderLayout()); markPanel.add(new JLabel("Mark: "), BorderLayout.WEST); markPanel.add(mark, BorderLayout.CENTER); content.add(markPanel, BorderLayout.SOUTH); CaretListener listener = new CaretListener() { public void caretUpdate(CaretEvent caretEvent) { dot.setText("" + caretEvent.getDot()); mark.setText("" + caretEvent.getMark()); } }; textArea.addCaretListener(listener); frame.setSize(250, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JTextField textField1 = new JTextField(); JTextField textField2 = new JTextField(); InputVerifier verifier = new InputVerifier() { public boolean verify(JComponent comp) { boolean returnValue; JTextField textField = (JTextField) comp; try { Integer.parseInt(textField.getText()); returnValue = true;/*www .j av a 2s .c om*/ } catch (NumberFormatException e) { returnValue = false; } return returnValue; } }; textField1.setInputVerifier(verifier); JFrame frame = new JFrame("Verifier Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(textField1, BorderLayout.NORTH); frame.add(textField2, BorderLayout.CENTER); frame.setSize(300, 100); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("My Border"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border border = new BlackWhiteBorder(); JButton helloButton = new JButton("Hello"); helloButton.setBorder(border);/*from w w w . ja va 2s.co m*/ JButton braveButton = new JButton("Brave New"); braveButton.setBorder(border); braveButton.setEnabled(false); JButton worldButton = new JButton("World"); worldButton.setBorder(border); Container contentPane = frame.getContentPane(); contentPane.add(helloButton, BorderLayout.NORTH); contentPane.add(braveButton, BorderLayout.CENTER); contentPane.add(worldButton, BorderLayout.SOUTH); frame.setSize(300, 100); frame.setVisible(true); }