List of usage examples for javax.swing BorderFactory createTitledBorder
public static TitledBorder createTitledBorder(Border border)
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("Double Title"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder topBorder = BorderFactory.createTitledBorder("Top"); topBorder.setTitlePosition(TitledBorder.TOP); TitledBorder doubleBorder = new TitledBorder(topBorder, "Bottom", TitledBorder.RIGHT, TitledBorder.BOTTOM); JButton doubleButton = new JButton(); doubleButton.setBorder(doubleBorder); Container contentPane = frame.getContentPane(); contentPane.add(doubleButton, BorderLayout.CENTER); frame.setSize(300, 100);/*from w w w .j a v a 2s .c o m*/ 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);//from w w w.j a v a 2 s .com TitledBorder rightBorder = BorderFactory.createTitledBorder("Right"); rightBorder.setTitleJustification(TitledBorder.RIGHT); JButton rightButton = new JButton(); rightButton.setBorder(rightBorder); 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:TitledPostBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Positioned Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder aboveTopBorder = BorderFactory.createTitledBorder("AboveTop"); aboveTopBorder.setTitlePosition(TitledBorder.ABOVE_TOP); JButton aboveTopButton = new JButton(); aboveTopButton.setBorder(aboveTopBorder); TitledBorder topBorder = BorderFactory.createTitledBorder("Top"); topBorder.setTitlePosition(TitledBorder.TOP); JButton topButton = new JButton(); topButton.setBorder(topBorder);//from w w w . j a v a2 s. c om TitledBorder belowTopBorder = BorderFactory.createTitledBorder("BelowTop"); belowTopBorder.setTitlePosition(TitledBorder.BELOW_TOP); JButton belowTopButton = new JButton(); belowTopButton.setBorder(belowTopBorder); TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom"); aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM); JButton aboveBottomButton = new JButton(); aboveBottomButton.setBorder(aboveBottomBorder); TitledBorder bottomBorder = BorderFactory.createTitledBorder("Bottom"); bottomBorder.setTitlePosition(TitledBorder.BOTTOM); JButton bottomButton = new JButton(); bottomButton.setBorder(bottomBorder); TitledBorder belowBottomBorder = BorderFactory.createTitledBorder("BelowBottom"); belowBottomBorder.setTitlePosition(TitledBorder.BELOW_BOTTOM); JButton belowBottomButton = new JButton(); belowBottomButton.setBorder(belowBottomBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(3, 2)); contentPane.add(aboveTopButton); contentPane.add(aboveBottomButton); contentPane.add(topButton); contentPane.add(bottomButton); contentPane.add(belowTopButton); contentPane.add(belowBottomButton); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("JProgressBar Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JProgressBar progressBar = new JProgressBar(); progressBar.setValue(25);/*w w w . j a va2 s . c om*/ progressBar.setStringPainted(true); Border border = BorderFactory.createTitledBorder("Reading..."); progressBar.setBorder(border); f.add(progressBar, BorderLayout.NORTH); f.setSize(300, 100); f.setVisible(true); }
From source file:TitledPostBorder.java
public static void main(String args[]) { JFrame frame = new JFrame("Positioned Titled Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TitledBorder aboveTopBorder = BorderFactory.createTitledBorder("AboveTop"); aboveTopBorder.setTitlePosition(TitledBorder.ABOVE_TOP); JButton aboveTopButton = new JButton(); aboveTopButton.setBorder(aboveTopBorder); TitledBorder topBorder = BorderFactory.createTitledBorder("Top"); topBorder.setTitlePosition(TitledBorder.TOP); JButton topButton = new JButton(); topButton.setBorder(topBorder);// w w w . j a v a2s .com TitledBorder belowTopBorder = BorderFactory.createTitledBorder("BelowTop"); belowTopBorder.setTitlePosition(TitledBorder.BELOW_TOP); JButton belowTopButton = new JButton(); belowTopButton.setBorder(belowTopBorder); TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom"); aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM); JButton aboveBottomButton = new JButton(); aboveBottomButton.setBorder(aboveBottomBorder); TitledBorder bottomBorder = BorderFactory.createTitledBorder("Bottom"); bottomBorder.setTitlePosition(TitledBorder.BOTTOM); JButton bottomButton = new JButton(); bottomButton.setBorder(bottomBorder); TitledBorder belowBottomBorder = BorderFactory.createTitledBorder("BelowBottom"); belowBottomBorder.setTitlePosition(TitledBorder.BELOW_BOTTOM); JButton belowBottomButton = new JButton(); belowBottomButton.setBorder(belowBottomBorder); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(3, 2)); contentPane.add(aboveTopButton); contentPane.add(aboveBottomButton); contentPane.add(topButton); contentPane.add(bottomButton); contentPane.add(belowTopButton); contentPane.add(belowBottomButton); frame.setSize(300, 200); 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"); Border thatBorder1 = new LineBorder(Color.RED); 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 ww . j a v a 2s . com 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:FlatCheckBox.java
public static void main(String args[]) { JFrame frame = new JFrame("Flat CheckBox Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new GridLayout(0, 1)); Border border = BorderFactory.createTitledBorder("Pizza Toppings"); panel.setBorder(border);/*from w w w . j a va 2s . c om*/ JCheckBox check = new JCheckBox("Anchovies"); check.setBorderPaintedFlat(true); panel.add(check); check = new JCheckBox("Garlic"); panel.add(check); check = new JCheckBox("Onions"); check.setBorderPaintedFlat(true); panel.add(check); check = new JCheckBox("Pepperoni"); panel.add(check); check = new JCheckBox("Spinach"); check.setBorderPaintedFlat(true); panel.add(check); JButton button = new JButton("Submit"); Container contentPane = frame.getContentPane(); contentPane.add(panel, BorderLayout.CENTER); contentPane.add(button, BorderLayout.SOUTH); frame.setSize(300, 200); 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 ww w. j av a 2 s. c om*/ 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:Main.java
public static void main(String args[]) { String title = (args.length == 0 ? "CheckBox Sample" : args[0]); JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new GridLayout(0, 1)); Border border = BorderFactory.createTitledBorder("Pizza Toppings"); panel.setBorder(border);// w w w . jav a 2s . c om JCheckBox check = new JCheckBox("Anchovies"); panel.add(check); check = new JCheckBox("Garlic"); panel.add(check); check = new JCheckBox("Onions"); panel.add(check); check = new JCheckBox("Pepperoni"); panel.add(check); check = new JCheckBox("Spinach"); panel.add(check); JButton button = new JButton("Submit"); Container contentPane = frame.getContentPane(); contentPane.add(panel, BorderLayout.CENTER); contentPane.add(button, BorderLayout.SOUTH); frame.setSize(300, 200); 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);//from w ww .ja v a 2 s.com 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); }