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[] arg) { Main m = new Main(); m.setVisible(true);/*www .jav a2 s. c o m*/ m.setSize(new Dimension(300, 100)); m.setLocation(50, 50); }
From source file:FontPaint.java
public static void main(String[] args) { FontPanel starPanel = new FontPanel(); JFrame f = new JFrame("Font"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from ww w.ja v a2 s . c o m*/ } }); f.getContentPane().add(starPanel, BorderLayout.CENTER); f.setSize(new Dimension(550, 200)); f.setVisible(true); }
From source file:DashedStrokeDemo.java
public static void main(String s[]) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/* ww w . j av a2 s.co m*/ } }); DashedStrokeDemo p = new DashedStrokeDemo(); f.getContentPane().add("Center", p); p.init(); f.pack(); f.setSize(new Dimension(250, 250)); f.show(); }
From source file:Main.java
public static void main(String s[]) { JFrame frame1 = new JFrame("2D Images "); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.getContentPane().add("Center", new Main()); frame1.pack();/*from w w w. j a v a2 s . co m*/ frame1.setSize(new Dimension(300, 300)); frame1.setVisible(true); }
From source file:Main.java
public static void main(String s[]) { JFrame frame1 = new JFrame("2D Text"); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.getContentPane().add("Center", new Main()); frame1.pack();//from w w w. ja v a 2s . c om frame1.setSize(new Dimension(500, 300)); frame1.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel ui = new JPanel(new BorderLayout(4, 4)); ui.setBorder(new EmptyBorder(6, 6, 6, 6)); JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEADING)); ui.add(controls, BorderLayout.PAGE_START); int s = 100;/*w ww . j a va 2s.c o m*/ Dimension[] sizes = { new Dimension(s * 4, s * 2), new Dimension(s * 6, s * 3), new Dimension(s * 8, s * 4) }; final JComboBox cb = new JComboBox(sizes); controls.add(cb); final JPanel[] panels = new JPanel[sizes.length]; for (int ii = 0; ii < sizes.length; ii++) { Dimension d = sizes[ii]; BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB); JPanel p = new JPanel(new GridLayout()); JLabel l = new JLabel(new ImageIcon(bi)); p.add(l); panels[ii] = p; } ItemListener sizeListener = new ItemListener() { JPanel current = panels[0]; @Override public void itemStateChanged(ItemEvent e) { JPanel next = panels[cb.getSelectedIndex()]; swapComponentsAndResizeUI(ui, current, next); current = next; } }; cb.addItemListener(sizeListener); ui.add(panels[0], BorderLayout.CENTER); JFrame f = new JFrame("Three Sized Panels"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setContentPane(ui); f.pack(); f.setLocationByPlatform(true); f.setVisible(true); }
From source file:AllAvailableFontsComboBox.java
public static void main(String s[]) { JFrame f = new JFrame("FontSelection"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//w w w. ja v a 2 s. c o m } }); AllAvailableFontsComboBox fontSelection = new AllAvailableFontsComboBox(); f.getContentPane().add(fontSelection, BorderLayout.CENTER); f.setSize(new Dimension(350, 250)); f.setVisible(true); }
From source file:AreaIntersect.java
public static void main(String s[]) { JFrame f = new JFrame("Pear"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/* ww w .j a v a 2 s. co m*/ } }); JApplet applet = new AreaIntersect(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(150, 200)); f.show(); }
From source file:Main.java
public static void main(String[] args) { int TIMER_DELAY = 2000; String[] data = { "A", "B", "C", "D" }; DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(data); JComboBox<String> combobox = new JComboBox<>(model); JList<String> jlist = new JList<>(model); new Timer(TIMER_DELAY, new ActionListener() { private int count = 0; public void actionPerformed(ActionEvent e) { model.addElement("count: " + count); count++;/*ww w .j a va 2 s . c o m*/ } }).start(); JPanel comboPanel = new JPanel(); comboPanel.add(combobox); JPanel listPanel = new JPanel(); listPanel.add(new JScrollPane(jlist)); JPanel panel = new JPanel(new GridLayout(1, 0)); panel.add(comboPanel); panel.add(listPanel); panel.setPreferredSize(new Dimension(400, 200)); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(panel); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JTextPane textPane = new JTextPane(); textPane.setText("12345678\n\t1\t2\t3a"); JScrollPane scrollPane = new JScrollPane(textPane); scrollPane.setPreferredSize(new Dimension(700, 100)); setTabs(textPane, 8);// ww w . j a v a 2 s. co m JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(scrollPane); frame.pack(); frame.setVisible(true); }