List of usage examples for javax.swing BorderFactory createLineBorder
public static Border createLineBorder(Color color)
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("Label Demo"); f.setLayout(new FlowLayout()); f.setSize(300, 200);// w w w . ja v a 2 s.com f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("java2s.com"); Border border = BorderFactory.createLineBorder(Color.BLACK); label.setBorder(border); label.setPreferredSize(new Dimension(150, 100)); label.setText("Centered"); label.setHorizontalAlignment(JLabel.CENTER); label.setVerticalAlignment(JLabel.CENTER); f.add(label); f.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame("Label Demo"); f.setLayout(new FlowLayout()); f.setSize(200, 360);//from www. j a v a 2s . c om f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel( "<html>Use HTML to create<br>" + "a multiline message." + "<br>One<br>Two<br>Three"); Border border = BorderFactory.createLineBorder(Color.BLACK); label.setBorder(border); f.add(label); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel label1 = new JLabel("BottomRight", SwingConstants.RIGHT); JLabel label2 = new JLabel("CenterLeft", SwingConstants.LEFT); JLabel label3 = new JLabel("TopCenter", SwingConstants.CENTER); label1.setVerticalAlignment(SwingConstants.BOTTOM); label2.setVerticalAlignment(SwingConstants.CENTER); label3.setVerticalAlignment(SwingConstants.TOP); label1.setBorder(BorderFactory.createLineBorder(Color.black)); label2.setBorder(BorderFactory.createLineBorder(Color.black)); label3.setBorder(BorderFactory.createLineBorder(Color.black)); JFrame frame = new JFrame("AlignmentExample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(new GridLayout(3, 1, 8, 8)); p.add(label1);/*from ww w . j a v a2s .com*/ p.add(label2); p.add(label3); p.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); frame.setContentPane(p); frame.setSize(200, 200); frame.setVisible(true); }
From source file:de.codesourcery.eve.skills.ui.spreadsheet.SpreadSheetTableModel.java
public static void main(String[] args) { final ITableFactory cellFactory = new ITableFactory() { @Override//from w w w. ja v a2 s.c o m public ITableCell createEmptyCell(int row, int column) { return new SimpleCell(); } @Override public TableRow createRow(SpreadSheetTableModel tableModel) { return new TableRow(tableModel); } }; final SpreadSheetTableModel model = new SpreadSheetTableModel(cellFactory); final JTable table = new JTable(model); table.setFillsViewportHeight(true); final JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // table.setPreferredSize( new Dimension(400,200 ) ); table.setBorder(BorderFactory.createLineBorder(Color.black)); frame.getContentPane().add(new JScrollPane(table)); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); model.addRow(new SimpleCell("First row") { public boolean isEditable() { return true; } public void setValue(Object value) { System.out.println("new value: " + value); } }); model.addRow(new SimpleCell("Second row #1"), new SimpleCell("Second row #2")); model.addRow(new SimpleCell("Third row #1"), new SimpleCell("Third row #2"), new SimpleCell("Third row #3")); JTextField tf = new JTextField(); table.setModel(model); table.setDefaultEditor(ITableCell.class, new DefaultCellEditor(tf)); } }); }
From source file:Main.java
/** * Adds a basic black line border around the given component. * @param c - the component to put the border around *//*from w w w .j a va2 s. c o m*/ public static void addLineBorder(JComponent c) { Border lineBorder; lineBorder = BorderFactory.createLineBorder(Color.black); c.setBorder(lineBorder); }
From source file:Main.java
/** * Adds a one pixel border of random color to this and all panels contained in this panel's * child hierarchy.//from ww w.j ava 2 s . c om */ public static void addDebugBorders(JPanel panel) { Color bcolor = new Color(_rando.nextInt(256), _rando.nextInt(256), _rando.nextInt(256)); panel.setBorder(BorderFactory.createLineBorder(bcolor)); for (int ii = 0; ii < panel.getComponentCount(); ii++) { Object child = panel.getComponent(ii); if (child instanceof JPanel) { addDebugBorders((JPanel) child); } } }
From source file:Main.java
public static Border getBorderRed() { return BorderFactory.createLineBorder(Color.red); }
From source file:Main.java
public static Border getBorderGray() { return BorderFactory.createLineBorder(Color.gray); }
From source file:Main.java
public static Border getBorderLightGray() { return BorderFactory.createLineBorder(Color.lightGray); }
From source file:Main.java
/** * @return Default colored line border */ public static Border defaultLineBorder() { return BorderFactory.createLineBorder(Color.GRAY); }