List of usage examples for javax.swing JPanel JPanel
public JPanel()
JPanel
with a double buffer and a flow layout. From source file:Main.java
public static void main(String... args) { JFrame f = new JFrame(); JButton button;/*from ww w. j a va 2 s . c o m*/ JPanel p = new JPanel(); button = new JButton("Button"); p.setLayout(null); button.setBounds(40, 100, 100, 60); p.add(button); f.add(p); // setLayout(null); f.setDefaultCloseOperation(3); f.setSize(400, 400); f.setVisible(true); }
From source file:Main.java
public static void main(String s[]) { JWindow win = new JWindow(); JPanel pan = new JPanel(); win.add(pan, "Center"); pan.setLayout(new FlowLayout()); pan.add(new JButton("Hello")); win.setSize(200, 200);//w w w .ja v a 2 s . c o m win.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) { JFrame f = new JFrame(); final JPanel p1 = new JPanel(); p1.add(new JLabel("GlassPane Example")); JButton show = new JButton("Show"); p1.add(show);//from w w w . j ava 2 s . c o m p1.add(new JButton("No-op")); f.getContentPane().add(p1); final JPanel glass = (JPanel) f.getGlassPane(); glass.setVisible(true); glass.setLayout(new GridBagLayout()); JButton glassButton = new JButton("Hide"); glass.add(glassButton); f.setSize(150, 80); f.setVisible(true); show.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { glass.setVisible(true); p1.repaint(); } }); glassButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { glass.setVisible(false); p1.repaint(); } }); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); Integer[][] board = { { 1, 1, 1, 1, 2, 0, 0, 0, 0 }, { 0, 0, 5, 0, 1, 0, 0, 2, 4 }, { 1, 0, 0, 4, 0, 0, 0, 3, 8 }, { 0, 0, 0, 6, 1, 0, 0, 3, 7 }, { 0, 0, 4, 5, 3, 8, 9, 4, 0 }, { 8, 0, 0, 0, 1, 7, 0, 4, 0 }, { 7, 4, 0, 0, 1, 6, 0, 3, 1 }, { 6, 1, 0, 0, 1, 0, 3, 3, 0 }, { 0, 0, 0, 0, 1, 1, 1, 1, 0 } }; String col[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; JTable table = new JTable(board, col); panel.add(table, BorderLayout.CENTER); frame.add(panel);// w w w . j a va2 s . c o m frame.setSize(800, 500); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:Main.java
public static void main(String... args) throws Exception { JPanel panel = new JPanel(); panel.setOpaque(true);/*w w w .j ava 2 s . c o m*/ panel.setBackground(Color.RED); java.net.URL url = new java.net.URL("http://www.java2s.com/style/download.png"); ImageIcon image = new ImageIcon(url); JLabel label = new JLabel("LABEL", image, JLabel.RIGHT); panel.add(label); JOptionPane.showMessageDialog(null, panel, "Modified JOptionPane : ", JOptionPane.PLAIN_MESSAGE); }
From source file:Main.java
public static void main(String[] args) throws Exception { JLabel label = new JLabel("java2s.com"); JPanel panel = new JPanel(); panel.add(label);//w w w .j ava 2s . c o m panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JOptionPane.showMessageDialog(null, panel); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); JScrollPane listScrollPane = new JScrollPane(); String[] stringArray = { "Testing", "This", "Stuff" }; JList<String> rowList = new JList<>(stringArray); rowList.setVisibleRowCount(2);/*from w w w . j a va 2s.c om*/ listScrollPane.setViewportView(rowList); panel.setLayout(new BorderLayout()); panel.add(listScrollPane); frame.add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { Object lazyValue = new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return new JPanel(); }/* ww w .j av a 2 s .c o m*/ }; UIManager.put("key", lazyValue); Object value = UIManager.get("key"); }
From source file:FlowLayoutExample.java
public static void main(String[] args) { JPanel panel = new JPanel(); JTextArea area = new JTextArea("text area"); area.setPreferredSize(new Dimension(100, 100)); JButton button = new JButton("button"); panel.add(button);/* www . j a va 2 s . com*/ panel.add(new JScrollPane(area)); JFrame f = new JFrame(); f.add(panel); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { String[] items = { "1|9|2", "1|9|1", "1|4|7" }; JList list = new JList(items); JPanel panel = new JPanel(); panel.add(new JScrollPane(list)); JOptionPane.showMessageDialog(null, panel); }