List of usage examples for javax.swing BorderFactory createEmptyBorder
public static Border createEmptyBorder(int top, int left, int bottom, int right)
From source file:Main.java
public static void addBorderSpaces(JComponent com) { com.setBorder(//from w ww. j a v a 2s .co m BorderFactory.createCompoundBorder(com.getBorder(), BorderFactory.createEmptyBorder(2, 4, 2, 4))); }
From source file:Main.java
/** * Default textfield design.//w ww .ja v a2 s .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 JComponent wrapEmptyBorder(Component content, int top, int left, int bottom, int right) { return wrapBorder(content, BorderFactory.createEmptyBorder(top, left, bottom, right)); }
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:EmptyBorderForLabel.java
public EmptyBorderForLabel() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); JLabel label;// w w w. j a v a 2 s. com label = new JLabel("Empty"); label.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); panel.add(label); getContentPane().add(panel); pack(); }
From source file:Main.java
public Main() { JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5)); simplePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JLabel simpleLabel = new JLabel("SIMPLE BORDERS", JLabel.CENTER); simplePanel.add(simpleLabel);//from w ww.ja v a2s.c o m add(simplePanel); }
From source file:Main.java
public Main() { JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5)); simplePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JLabel titleLabel = new JLabel("TITLE BORDERS", JLabel.CENTER); titleLabel.setForeground(Color.red.darker()); add(simplePanel);/*from w w w .jav a2s.co m*/ }
From source file:Main.java
/** * Sets a title for the given component by surrounding it with a CompoundBorder * /*from ww w . j a v a 2 s. 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:SampleButton.java
public SampleButton() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(new BorderLayout()); p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JButton b = new JButton("Test"); b.setHorizontalTextPosition(SwingConstants.LEFT); b.setIcon(new ImageIcon("r.gif")); b.setRolloverIcon(new ImageIcon("b.gif")); b.setRolloverEnabled(true);/*w ww. j av a 2 s. c om*/ b.setMnemonic('t'); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Button pressed"); } }); p.add(b); getContentPane().add(p); pack(); }
From source file:Main.java
public Main() { int rows = BTN_LABELS.length; int cols = BTN_LABELS[0].length; int gap = 4;//from w w w. ja va 2 s. c o m mainPanel.setBorder(BorderFactory.createEmptyBorder(gap, gap, gap, gap)); mainPanel.setLayout(new GridLayout(rows, cols, gap, gap)); for (String[] btnLabelRow : BTN_LABELS) { for (String btnLabel : btnLabelRow) { JButton btn = createButton(btnLabel); mainPanel.add(btn); } } }