List of usage examples for java.awt Container add
public Component add(Component comp)
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Justified Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder leftBorder = BorderFactory.createTitledBorder("Left"); leftBorder.setTitleJustification(TitledBorder.LEFT); JButton leftButton = new JButton(); leftButton.setBorder(leftBorder);/*w ww. j a v a 2s .c o m*/ Container contentPane = frame.getContentPane(); contentPane.add(leftButton); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("Justified Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border loweredBorder = BorderFactory.createLoweredBevelBorder(); JButton loweredButton = new JButton("Lowered"); loweredButton.setBorder(loweredBorder); Container contentPane = frame.getContentPane(); contentPane.add(loweredButton); frame.setSize(300, 200);//from w w w .j a va 2 s . c o m frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Positioned Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder belowTopBorder = BorderFactory.createTitledBorder("BelowTop"); belowTopBorder.setTitlePosition(TitledBorder.BELOW_TOP); JButton belowTopButton = new JButton(); belowTopButton.setBorder(belowTopBorder); Container contentPane = frame.getContentPane(); contentPane.add(belowTopButton); frame.setSize(300, 200);//from www. j a v a 2 s. c om frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Positioned Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom"); aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM); JButton aboveBottomButton = new JButton(); aboveBottomButton.setBorder(aboveBottomBorder); Container contentPane = frame.getContentPane(); contentPane.add(aboveBottomButton); frame.setSize(300, 200);/*from w w w . j a v a2 s. co m*/ 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 ww . j a v 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:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Justified Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border myRaisedBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.PINK, Color.RED); JButton myRaisedButton = new JButton("My Raised"); myRaisedButton.setBorder(myRaisedBorder); Container contentPane = frame.getContentPane(); contentPane.add(myRaisedButton); frame.setSize(300, 200);//w ww . j av a 2s .co m frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("Justified Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border myRaisedBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED); JButton myRaisedButton = new JButton("My Raised"); myRaisedButton.setBorder(myRaisedBorder); Container contentPane = frame.getContentPane(); contentPane.add(myRaisedButton); frame.setSize(300, 200);/*from w w w . java2 s . co m*/ frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Justified Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder centerBorder = BorderFactory.createTitledBorder("Center"); centerBorder.setTitleJustification(TitledBorder.CENTER); JButton centerButton = new JButton(); centerButton.setBorder(centerBorder); Container contentPane = frame.getContentPane(); contentPane.add(centerButton); frame.setSize(300, 200);/*from w w w . ja va 2s .co m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { SpinnerNumberModel model = new SpinnerNumberModel(0.0, -1000.0, 1000.0, 0.1); JSpinner s = new JSpinner(model); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(s); s.setEditor(editor);/*ww w.j a v a2 s .c om*/ JTextField stepText = new JTextField(10); JButton bStepSet = new JButton("Set Step"); bStepSet.addActionListener(e -> { Double val = Double.parseDouble(stepText.getText().trim()); model.setStepSize(val); }); JFrame f = new JFrame(); Container c = f.getContentPane(); c.add(s); JPanel southPanel = new JPanel(); southPanel.add(stepText); southPanel.add(bStepSet); c.add(southPanel, BorderLayout.SOUTH); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("Justified Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border myRaisedBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.PINK, Color.RED, Color.PINK, Color.RED); JButton myRaisedButton = new JButton("My Raised"); myRaisedButton.setBorder(myRaisedBorder); Container contentPane = frame.getContentPane(); contentPane.add(myRaisedButton); frame.setSize(300, 200);//from www.j a v a 2s. co m frame.setVisible(true); }