List of usage examples for javax.swing JButton setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
From source file:AnEtchedBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Etched Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = new EtchedBorder(EtchedBorder.RAISED); Border loweredBorder = new EtchedBorder(EtchedBorder.LOWERED); JButton raisedButton = new JButton("Raised"); raisedButton.setBorder(raisedBorder); JButton loweredButton = new JButton("Lowered"); loweredButton.setBorder(loweredBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2, 5, 5)); contentPane.add(raisedButton);/*from w w w . java2s.c o m*/ contentPane.add(loweredButton); frame.setSize(300, 100); frame.setVisible(true); }
From source file:ASoftBevelBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Soft Bevel Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = new SoftBevelBorder(SoftBevelBorder.RAISED); Border loweredBorder = new SoftBevelBorder(SoftBevelBorder.LOWERED); JButton raisedButton = new JButton("Raised"); raisedButton.setBorder(raisedBorder); JButton loweredButton = new JButton("Lowered"); loweredButton.setBorder(loweredBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2)); contentPane.add(raisedButton);/* ww w .j a v a 2s . c o m*/ contentPane.add(loweredButton); frame.setSize(300, 100); 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); JButton thickButton = new JButton("12 Pixel"); thickButton.setBorder(thickBorder);//from w w w. ja v a2 s. c om 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:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Justified Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border greenBorder = BorderFactory.createLineBorder(Color.GREEN, 2); Border blueBorder = BorderFactory.createLineBorder(Color.BLUE, 2); Border magentaBorder = BorderFactory.createLineBorder(Color.MAGENTA, 2); Border twoColorBorder = new CompoundBorder(magentaBorder, blueBorder); Border threeColorBorder = new CompoundBorder(twoColorBorder, greenBorder); JButton rainbowButton = new JButton("Rainbow"); rainbowButton.setBorder(threeColorBorder); Container contentPane = frame.getContentPane(); contentPane.add(rainbowButton);//from www . j ava 2s.c o m frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Line Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border roundedBorder = new LineBorder(Color.BLACK, 12, true); JButton roundedButton = new JButton("Rounded 12 Pixel"); roundedButton.setBorder(roundedBorder); Container contentPane = frame.getContentPane(); contentPane.add(roundedButton, BorderLayout.SOUTH); frame.pack();/* w w w . j av a 2s . c o m*/ frame.setSize(300, frame.getHeight()); frame.setVisible(true); }
From source file:ATitledBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border thisBorder = BorderFactory.createTitledBorder("Easy"); Icon thatIcon = new ImageIcon("diamond.gif"); Border thatBorder1 = new MatteBorder(18, 20, 18, 20, thatIcon); Border thatBorder2 = new TitledBorder(thatBorder1, "Harder"); Font font = new Font("Serif", Font.ITALIC, 12); Border thatBorder = new TitledBorder(thatBorder2, "Harder", TitledBorder.LEFT, TitledBorder.ABOVE_BOTTOM, font, Color.red);/*from w w w .j a v a2 s .c o m*/ JButton thisButton = new JButton("Easy"); thisButton.setBorder(thisBorder); JButton thatButton = new JButton("Harder"); thatButton.setBorder(thatBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2)); contentPane.add(thisButton); contentPane.add(thatButton); frame.setSize(300, 200); frame.setVisible(true); }
From source file:TitledJustBorder.java
public static void main(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); TitledBorder rightBorder = BorderFactory.createTitledBorder("Right"); rightBorder.setTitleJustification(TitledBorder.RIGHT); JButton rightButton = new JButton(); rightButton.setBorder(rightBorder);//from ww w . java 2 s. c om TitledBorder centerBorder = BorderFactory.createTitledBorder("Center"); centerBorder.setTitleJustification(TitledBorder.CENTER); JButton centerButton = new JButton(); centerButton.setBorder(centerBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(3, 1)); contentPane.add(leftButton); contentPane.add(rightButton); contentPane.add(centerButton); frame.setSize(300, 200); frame.setVisible(true); }
From source file:ABevelBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Bevel Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border raisedBorder = BorderFactory.createRaisedBevelBorder(); Border loweredBorder = BorderFactory.createLoweredBevelBorder(); Border myRaisedBorder = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.pink, Color.red); Border myLoweredBorder = BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.pink, Color.red); JButton raisedButton = new JButton("Raised"); raisedButton.setBorder(raisedBorder); JButton loweredButton = new JButton("Lowered"); loweredButton.setBorder(loweredBorder); JButton myRaisedButton = new JButton("My Raised"); myRaisedButton.setBorder(myRaisedBorder); JButton myLoweredButton = new JButton("My Lowered"); myLoweredButton.setBorder(myLoweredBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(2, 2, 5, 5)); contentPane.add(raisedButton);/*from ww w . j a v a 2 s . c o m*/ contentPane.add(loweredButton); contentPane.add(myRaisedButton); contentPane.add(myLoweredButton); frame.setSize(300, 100); 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); JButton thickButton = new JButton("12 Pixel"); thickButton.setBorder(thickBorder);//from w w w . j a v a 2s .co m 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:MainClass.java
public static void main(String[] a) { JFrame frame = new JFrame("Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border thisBorder = BorderFactory.createTitledBorder("Easy"); Icon thatIcon = MetalIconFactory.getFileChooserHomeFolderIcon(); Border thatBorder1 = new MatteBorder(18, 20, 18, 20, thatIcon); Border thatBorder2 = new TitledBorder(thatBorder1, "Harder"); Font font = new Font("Serif", Font.ITALIC, 12); Border thatBorder = new TitledBorder(thatBorder2, "Hardest", TitledBorder.LEFT, TitledBorder.ABOVE_BOTTOM, font, Color.RED);// www. j a v a2s . co m JButton thisButton = new JButton("Easy"); thisButton.setBorder(thisBorder); JButton thatButton = new JButton("Harder"); thatButton.setBorder(thatBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(1, 2)); contentPane.add(thisButton); contentPane.add(thatButton); frame.setSize(300, 200); frame.setVisible(true); }