List of usage examples for java.awt Dimension Dimension
public Dimension(int width, int height)
From source file:TextArea.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextArea area = new JTextArea(); area.setLineWrap(true);//from www.j a va 2s .c om area.setWrapStyleWord(true); area.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); f.add(new JScrollPane(area)); f.setSize(new Dimension(350, 300)); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS)); JPanel a = new JPanel(); a.setAlignmentX(Component.CENTER_ALIGNMENT); a.setPreferredSize(new Dimension(100, 100)); a.setMaximumSize(new Dimension(100, 100)); // set max = pref a.setBorder(BorderFactory.createTitledBorder("aa")); JPanel b = new JPanel(); b.setAlignmentX(Component.CENTER_ALIGNMENT); b.setPreferredSize(new Dimension(50, 50)); b.setMaximumSize(new Dimension(50, 50)); // set max = pref b.setBorder(BorderFactory.createTitledBorder("bb")); frame.getContentPane().add(a);//from ww w . j a va2 s .com frame.getContentPane().add(b); frame.pack(); frame.setVisible(true); }
From source file:RigidArea.java
public static void main(String[] args) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setBorder(new EmptyBorder(new Insets(40, 60, 40, 60))); panel.add(new JButton("Button")); panel.add(Box.createRigidArea(new Dimension(0, 5))); panel.add(new JButton("Button")); panel.add(Box.createRigidArea(new Dimension(0, 5))); panel.add(new JButton("Button")); panel.add(Box.createRigidArea(new Dimension(0, 5))); panel.add(new JButton("Button")); JFrame f = new JFrame(); f.add(panel);// www . j a va 2 s. c o m f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_ON.java
public static void main(String[] args) { JFrame frame = new JFrame("LCD Text Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(630, 460)); frame.setContentPane(new MyPanel(RenderingHints.VALUE_TEXT_ANTIALIAS_ON)); frame.pack();/*w w w .j a v a 2s. com*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JPanel container = new ScrollablePanel(); container.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); for (int i = 0; i < 20; ++i) { JPanel p = new JPanel(); p.setPreferredSize(new Dimension(50, 50)); p.add(new JLabel("" + i)); container.add(p);/*w ww . j a va 2 s.c o m*/ } JScrollPane scroll = new JScrollPane(container); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(scroll); f.pack(); f.setSize(250, 300); f.setVisible(true); }
From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_GASP.java
public static void main(String[] args) { JFrame frame = new JFrame("LCD Text Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(630, 460)); frame.setContentPane(new MyPanel(RenderingHints.VALUE_TEXT_ANTIALIAS_GASP)); frame.pack();/* w ww. j av a 2 s.c om*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false);/*from ww w .j a v a2 s. c o m*/ frame.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); JPanel navigation_panel_wrap = new JPanel() { @Override public Dimension getPreferredSize() { return new Dimension(250, 700); } }; JPanel content_panel_wrap = new JPanel() { @Override public Dimension getPreferredSize() { return new Dimension(750, 700); } }; content_panel_wrap.setBackground(Color.green); navigation_panel_wrap.setBackground(Color.red); frame.add(navigation_panel_wrap); frame.add(content_panel_wrap); frame.pack(); frame.setVisible(true); }
From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_LCD_HBGR.java
public static void main(String[] args) { JFrame frame = new JFrame("LCD Text Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(630, 460)); frame.setContentPane(new MyPanel(RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR)); frame.pack();/*from ww w .j av a2 s . c o m*/ frame.setVisible(true); }
From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_LCD_VBGR.java
public static void main(String[] args) { JFrame frame = new JFrame("LCD Text Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(630, 460)); frame.setContentPane(new MyPanel(RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR)); frame.pack();//from ww w.ja v a 2s .c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { Main t = new Main(); JPanel mainPanel = new JPanel(new BorderLayout()); JLabel l = new JLabel("hello world"); l.setOpaque(true);/*w w w . ja va 2 s . co m*/ l.setBackground(Color.RED); JPanel extraPanel = new JPanel(new FlowLayout()); l.setPreferredSize(new Dimension(100, 100)); extraPanel.setBackground(Color.GREEN); extraPanel.add(l); mainPanel.add(extraPanel, BorderLayout.CENTER); t.setContentPane(mainPanel); t.setDefaultCloseOperation(EXIT_ON_CLOSE); t.setSize(400, 200); t.setVisible(true); }