l.setBorder(new LineBorder(Color.RED, 2)); return l; JPanel p = new JPanel(new GridLayout(2,2,4,4)); p.setBackground(Color.black); p.setBorder(new EmptyBorder(4,4,4,4)); border.add(getLabel( "Border", SwingConstants.CENTER), BorderLayout.CENTER); p.add(border); gridbag.add(getLabel("GridBag")); p.add(gridbag); p.add(box); JFrame f = new JFrame("Streeeetch me.."); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(p); f.pack(); f.setLocationByPlatform(true); f.setVisible(true);
add(jScrollPane1); public void run() { JPanel pan = new FileDropList(); pan.setBorder(new LineBorder(Color.BLACK)); JOptionPane.showMessageDialog(null, pan);
public static void main(String[] _args) { JFrame f=new JFrame("test BuSplit2Pane"); JButton c1=new JButton("1"); JButton c2=new JButton("2"); c1.setBorder(new LineBorder(Color.black,2)); c2.setBorder(new LineBorder(Color.black,2)); BuSplit2Pane sp=new BuSplit2Pane(c1,c2); sp.setBorder(new LineBorder(Color.red,2)); f.getContentPane().add("Center",sp); f.setSize(300,200); f.show(); f.setLocation(200,100); } }
public static void main(final String[] args) { final ColorTable[] luts = { ColorTables.FIRE, ColorTables.ICE, ColorTables.SPECTRUM, ColorTables.RED, ColorTables.GREEN, ColorTables.BLUE, ColorTables.CYAN, ColorTables.MAGENTA, ColorTables.YELLOW, ColorTables.GRAYS, ColorTables.REDGREEN, ColorTables.RGB332 }; final JFrame frame = new JFrame(); frame.setTitle("LUTs"); final JPanel pane = new JPanel(); frame.setContentPane(pane); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); for (final ColorTable lut : luts) { final SwingColorBar colorBar = new SwingColorBar(lut); colorBar.setBorder(new LineBorder(Color.black)); pane.add(colorBar); } frame.pack(); frame.setVisible(true); }
this.setBorder(BorderFactory.createCompoundBorder( new LineBorder(Color.blue), new EmptyBorder(5, 5, 5, 5))); textLabel.setUI(myUI); textLabel.setFont(new Font("Serif", Font.ITALIC, 24)); this.add(sizeLabel); this.add(textLabel); this.addComponentListener(new ComponentAdapter() { JFrame f = new JFrame("LayoutTest"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(this); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true);
public static void main(String[] _args) { JFrame f=new JFrame("test BuSplit3Pane"); JButton c1=new JButton("1"); JButton c2=new JButton("2"); JButton c3=new JButton("3"); c1.setBorder(new LineBorder(Color.black,2)); c2.setBorder(new LineBorder(Color.black,2)); c3.setBorder(new LineBorder(Color.black,2)); BuSplit3Pane sp=new BuSplit3Pane(c1,c2,c3,VERTICAL); sp.setBorder(new LineBorder(Color.red,12)); f.getContentPane().add("Center",sp); f.setSize(300,200); f.show(); f.setLocation(500,100); } }
public static void main(final String[] args) { final ColorTable[] luts = { ColorTables.FIRE, ColorTables.ICE, ColorTables.SPECTRUM, ColorTables.RED, ColorTables.GREEN, ColorTables.BLUE, ColorTables.CYAN, ColorTables.MAGENTA, ColorTables.YELLOW, ColorTables.GRAYS, ColorTables.REDGREEN, ColorTables.RGB332 }; final JFrame frame = new JFrame(); frame.setTitle("LUTs"); final JPanel pane = new JPanel(); frame.setContentPane(pane); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); for (final ColorTable lut : luts) { final SwingColorBar colorBar = new SwingColorBar(lut); colorBar.setBorder(new LineBorder(Color.black)); pane.add(colorBar); } frame.pack(); frame.setVisible(true); }
import java.awt.*; import javax.swing.*; import javax.swing.border.*; public class LaunchPanel extends JPanel { private JButton startButton; public LaunchPanel() { int width = 200, height = 100; setPreferredSize(new Dimension(width, height)); setLayout(new GridBagLayout()); startButton = new JButton("Start"); add(startButton); setBorder( new LineBorder(Color.RED, 2)); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, new LaunchPanel()); } }); } }
setFont(getFont().deriveFont(Font.BOLD, 13)); setContentAreaFilled(false); setBorder(null); setCursor(new Cursor(Cursor.HAND_CURSOR)); setBorder(new EmptyBorder(50, 50, 50, 50)); // setting the insets new LineBorder(Color.white, 2), new EmptyBorder(2, 5, 2, 2)); usrNameFeild.setBorder(compundBorder); add(usrNameLabel, labCnst); add(usrNameFeild, txtCnst); add(passwordLabel, labCnst); add(passFeild, txtCnst); JFrame frame = new JFrame("Demo: LogIn Dialogue"); frame.add(new MainContainer()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);
private JFrame frame = new JFrame(); setLayout(new FlowLayout(FlowLayout.RIGHT)); add(label); add(new MainPanel(), BorderLayout.CENTER); add(new BorderPanel(), BorderLayout.PAGE_START); setBorder(new LineBorder(Color.BLACK, 5)); frame.setUndecorated(true); frame.add(new OutsidePanel()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); p.add(f); frame.add(p); frame.pack(); frame.setVisible(true); lastFocusableIndex = 0; sl.setFocused(false); autoSuggestionPopUpWindow.setVisible(false); setFocusToTextField(); autoSuggestionPopUpWindow.setVisible(false); setFocusToTextField(); suggestionsPanel.add(suggestionLabel); setBorder(new LineBorder(suggestionBorderColor)); } else { setBorder(null);
setBorder(new LineBorder(Color.BLUE, 3)); setBackground(Color.WHITE); setBounds(0, 0, 100, 100); JFrame f = new JFrame("Swing Hello World"); f.add(mc); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setVisible(true);
gui.setBorder(new EmptyBorder(5, 5, 5, 5)); JToolBar tools = new JToolBar(); tools.setFloatable(false); gui.add(tools, BorderLayout.PAGE_START); tools.add(new JButton("New")); // TODO - add functionality! tools.add(new JButton("Save")); // TODO - add functionality! tools.add(new JButton("Restore")); // TODO - add functionality! tools.addSeparator(); chessBoard.setBorder(new LineBorder(Color.BLACK)); gui.add(chessBoard); new ChessBoardWithColumnsAndRows(); JFrame f = new JFrame("ChessChamp"); f.add(cb.getGui()); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setLocationByPlatform(true); f.pack(); f.setVisible(true);
JButton b = new JButton(); b.setBackground(Color.red); b.setBorder(new LineBorder(Color.black, 2)); b.setPreferredSize(new Dimension(600, 10)); panel = new JPanel(new GridLayout(0, 1)); panel.add(b); f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(panel, "Center"); f.add(getCheckBoxPanel(), "South"); f.setLocation(200, 200); f.pack(); f.setVisible(true); JButton b = new JButton(); b.setBackground(Color.red); b.setBorder(new LineBorder(Color.black, 2)); b.setPreferredSize(new Dimension(600, 10)); panel.add(b); f.pack();
import java.awt.*; import javax.swing.*; import javax.swing.border.LineBorder; import javax.swing.plaf.ColorUIResource; public class TableGridProb2 { public static void main(String[] args) { UIManager.put("Table.gridColor", new ColorUIResource(Color.gray)); EventQueue.invokeLater(new Runnable() { @Override public void run() { JFrame frame = new JFrame("Table Grid Prob2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane sp = new JScrollPane(new JTable(20, 5)); JPanel p = new JPanel(new GridLayout()); p.setBorder(new LineBorder(Color.green, 4)); p.add(sp); frame.getContentPane().add(p); frame.pack(); frame.setVisible(true); } }); } }
import java.awt.*; import javax.swing.*; import javax.swing.border.*; public class RoundedLineBorder extends JPanel { public RoundedLineBorder() { super(true); setLayout(new BorderLayout()); JLabel label = new JLabel("Rounded Corners"); label.setHorizontalAlignment(JLabel.CENTER); LineBorder line = new LineBorder(Color.blue, 2, true); label.setBorder(line); add(label, BorderLayout.CENTER); } public static void main(String s[]) { JFrame frame = new JFrame("Rounded Line Border"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500, 200); frame.setContentPane(new RoundedLineBorder()); frame.setVisible(true); } }
private JFrame frame = new JFrame(); frame.add(ui); ui.setBorder(new LineBorder(Color.CYAN, 3)); toolPanel.setBorder(new LineBorder(Color.ORANGE, 3)); ui.add(toolPanel, BorderLayout.PAGE_START); for (int i = 0; i < 3; i++) { toolPanel.add(new JButton("Button " + i)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); // pack will make it as small as it can be. frame.setVisible(true);
import javax.swing.*; import javax.swing.border.*; import java.awt.*; class TitledBorderDemo implements Runnable { public static void main(String[] args) { SwingUtilities.invokeLater(new TitledBorderDemo()); } @Override public void run() { JFrame frame = new JFrame(); JPanel panel = new JPanel(); panel.setBackground(Color.gray); panel.setBorder(new TitledBorder(new LineBorder(Color.white), "Title")); panel.add(new JButton("Button")); panel.add(new JLabel("Label")); frame.add(panel); frame.pack(); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.LineBorder; public class RoundedLineBorder extends JPanel { public RoundedLineBorder() { super(true); JLabel label = new JLabel("<html>Stack<br/>Overflow</html>"); LineBorder line = new LineBorder(Color.blue, 1, true); // color, thickness, rounded label.setBorder(line); add(label, BorderLayout.CENTER); } public static void main(String s[]) { JFrame frame = new JFrame("Rounded Line Border"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500, 200); frame.setContentPane(new RoundedLineBorder()); frame.setVisible(true); } }
@Override public void run() { final JFrame frame = new JFrame("Test frame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); label.setBorder(new LineBorder(Color.BLUE, 2)); //Adding a border for clarity. containerPanel.add(label); frame.getContentPane().add(containerPanel); //or: frame.setContentPane(containerPanel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);