List of usage examples for javax.swing BorderFactory createCompoundBorder
public static CompoundBorder createCompoundBorder(Border outsideBorder, Border insideBorder)
From source file:Main.java
License:asdf
public static void main(String[] argv) { LineBorder border1 = new LineBorder(Color.red); TitledBorder border2 = new TitledBorder("asdf"); Border newBorder = BorderFactory.createCompoundBorder(border1, border2); JButton component = new JButton("button"); component.setBorder(newBorder);//from www . ja va 2 s .c om }
From source file:Borders.java
public static void main(String[] args) { JFrame frame = new JFrame("Borders"); int center = SwingConstants.CENTER; JLabel labelOne = new JLabel("raised BevelBorder", center); labelOne.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); JLabel labelTwo = new JLabel("EtchedBorder", center); labelTwo.setBorder(BorderFactory.createEtchedBorder()); JLabel labelThree = new JLabel("MatteBorder", center); labelThree.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink)); JLabel labelFour = new JLabel("TitledBorder", center); Border etch = BorderFactory.createEtchedBorder(); labelFour.setBorder(BorderFactory.createTitledBorder(etch, "Title")); JLabel labelFive = new JLabel("TitledBorder", center); Border low = BorderFactory.createLoweredBevelBorder(); labelFive//from ww w.j av a 2s. c om .setBorder(BorderFactory.createTitledBorder(low, "Title", TitledBorder.RIGHT, TitledBorder.BOTTOM)); JLabel labelSix = new JLabel("CompoundBorder", center); Border one = BorderFactory.createEtchedBorder(); Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue); labelSix.setBorder(BorderFactory.createCompoundBorder(one, two)); frame.setLayout(new GridLayout(3, 2)); frame.add(labelOne); frame.add(labelTwo); frame.add(labelThree); frame.add(labelFour); frame.add(labelFive); frame.add(labelSix); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void addBorderSpaces(JComponent com) { com.setBorder(/*from w w w .j a v a2 s.co m*/ BorderFactory.createCompoundBorder(com.getBorder(), BorderFactory.createEmptyBorder(2, 4, 2, 4))); }
From source file:Main.java
public static Border createTitleBorder(final String title) { final Border tb = BorderFactory.createTitledBorder(title); final Border eb = BorderFactory.createEmptyBorder(0, 5, 5, 5); return BorderFactory.createCompoundBorder(tb, eb); }
From source file:Main.java
public static Border getTitledBorder(String title) { return BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(etchedBorder, title), empty10Border);/*ww w. j a v a 2 s. c o m*/ }
From source file:Main.java
/** * Default textfield design.//from ww w .j a va2s. c om * * @param requireMinWidth Whether the textfield should have a default min. width set. * @param contents Initial contents. * @return */ public static JTextField defaultTextField(boolean requireMinWidth, String contents) { JTextField jtf = new JTextField(contents); if (requireMinWidth) jtf.setPreferredSize(new Dimension(400, jtf.getPreferredSize().height)); jtf.setBorder(BorderFactory.createCompoundBorder(defaultLineBorder(), BorderFactory.createEmptyBorder(0, 5, 0, 0))); return jtf; }
From source file:Main.java
public static CompoundBorder getCompoundBorder(String text) { return BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(text), BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:Main.java
public Main() { JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5)); simplePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder())); simplePanel.add(new JLabel("Examples"), JLabel.CENTER); add(simplePanel);//from ww w . java 2 s.c o m }
From source file:Main.java
/** * Sets a title for the given component by surrounding it with a CompoundBorder * /*from ww w .j av a 2s .c o m*/ * @param component the component * @param title the title of the component */ public static void setTitle(JComponent component, String title) { component.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title), BorderFactory.createEmptyBorder(5, 5, 5, 5))); }
From source file:CompoundBorderLineLineBorder.java
public CompoundBorderLineLineBorder() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); JLabel label;/*from www . j av a2s . c om*/ label = new JLabel("Compound - red inside green lines"); label.setBorder(BorderFactory.createCompoundBorder(new LineBorder(Color.green), new LineBorder(Color.red))); panel.add(label); getContentPane().add(panel); pack(); }