List of usage examples for java.awt Dimension Dimension
public Dimension(int width, int height)
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel() { @Override//from w ww . j a v a 2 s.co m protected void paintComponent(Graphics g) { super.paintComponent(g); int y = 0; for (int size = 4; size <= 24; size += 2) { g.setFont(new Font("Arial", Font.BOLD, size)); g.drawString("Name", 0, y); int heightOfFont = g.getFontMetrics().getHeight(); y += heightOfFont; } } @Override public Dimension getPreferredSize() { return new Dimension(300, 300); } }; frame.add(panel); frame.setLocationByPlatform(true); frame.setVisible(true); frame.pack(); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<Vector<String>> rowData = new Vector<Vector<String>>(); Vector<String> columnName = new Vector<String>(Arrays.asList("Column 1")); for (int i = 0; i < 2000; i++) { rowData.add(new Vector<String>(Arrays.asList(Integer.toString(i)))); }// w ww . j a va 2s .c om JTable table = new JTable(rowData, columnName); JScrollPane scrollPane = new JScrollPane(table); JScrollBar vertical = scrollPane.getVerticalScrollBar(); vertical.setPreferredSize(new Dimension(0, 0)); f.add(scrollPane); f.pack(); f.setVisible(true); JViewport view = scrollPane.getViewport(); Component[] components = view.getComponents(); for (int i1 = 0; i1 < components.length; i1++) { if (components[i1] instanceof JTable) { System.out.println("got"); } } }
From source file:Main.java
public static void main(String[] args) { final JFrame frame = new JFrame(Main.class.getSimpleName()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel btmPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.weighty = 1.0;/* ww w . j a va2 s .com*/ gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.NORTH; JButton comp = new JButton("Panel-1"); btmPanel.add(comp, gbc); JButton comp2 = new JButton("Panel-2"); btmPanel.add(comp2, gbc); JButton comp3 = new JButton("Panel-3"); comp3.setPreferredSize(new Dimension(comp.getPreferredSize().width, comp.getPreferredSize().height + 10)); btmPanel.add(comp3, gbc); frame.add(btmPanel); frame.pack(); frame.setVisible(true); }
From source file:LabelForComboBox.java
public static void main(String[] a) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*ww w . j a v a 2s . co m*/ } }); f.getContentPane().add(new LabelForComboBox()); f.pack(); f.setSize(new Dimension(300, 200)); f.show(); }
From source file:Main.java
public static void main(String[] args) { try {/*from w w w.j a v a2s . c om*/ bg = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); } catch (Exception ex) { System.out.println(ex); } JPanel tabPanel = new JPanel(new GridBagLayout()) { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(bg, 0, 0, getWidth(), getHeight(), this); } @Override public Dimension getPreferredSize() { return new Dimension(400, 300); } }; JPanel buttons = new JPanel(new GridLayout(4, 1, 15, 15)); buttons.setOpaque(false); for (int i = 0; i < 4; i++) { buttons.add(new JButton("Button")); } tabPanel.add(buttons); JTabbedPane tabPane = new JTabbedPane(); tabPane.add("Panel with Bachground", tabPanel); JFrame frame = new JFrame(); frame.setContentPane(tabPane); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] arg) { Main m = new Main(); m.setVisible(true);/*from ww w .j av a 2s . c om*/ m.setSize(new Dimension(600, 300)); m.validate(); }
From source file:BasicStrokeDemo.java
public static void main(String s[]) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from ww w.ja v a 2 s.co m*/ } }); BasicStrokeDemo p = new BasicStrokeDemo(); f.getContentPane().add("Center", p); p.init(); f.pack(); f.setSize(new Dimension(250, 250)); f.show(); }
From source file:ThickStrokeDemo.java
public static void main(String s[]) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from w w w. ja v a2 s .c om*/ } }); ThickStrokeDemo p = new ThickStrokeDemo(); f.getContentPane().add("Center", p); p.init(); f.pack(); f.setSize(new Dimension(250, 250)); f.show(); }
From source file:GradientPaintDemo.java
public static void main(String s[]) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from ww w .jav a 2 s . co m } }); GradientPaintDemo p = new GradientPaintDemo(); f.getContentPane().add("Center", p); p.init(); f.pack(); f.setSize(new Dimension(250, 250)); f.show(); }
From source file:MyLookAndFeel.java
public static void main(String[] arg) throws Exception { Main m = new Main(); m.setVisible(true);/*from w w w . ja v a 2 s . co m*/ m.setSize(new Dimension(300, 150)); m.validate(); }