Example usage for javax.swing JFrame setPreferredSize

List of usage examples for javax.swing JFrame setPreferredSize

Introduction

In this page you can find the example usage for javax.swing JFrame setPreferredSize.

Prototype

public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component to a constant value.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setPreferredSize(new Dimension(300, 280));

    Main ch = new Main();
    ch.setDate(new Date());
    frame.getContentPane().add(ch);//w  w  w  .  j  a  v  a  2  s. c  o  m
    frame.setUndecorated(true);

    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setPreferredSize(new Dimension(300, 280));

    Main ch = new Main();
    frame.getContentPane().add(ch);/*from w  w w . j  a v  a 2 s. co  m*/
    frame.setUndecorated(true);

    MoveMouseListener mml = new MoveMouseListener(ch);
    ch.addMouseListener(mml);
    ch.addMouseMotionListener(mml);

    frame.pack();
    frame.setVisible(true);
}

From source file:WindowsLookAndFeelDemo.java

public static void main(String[] args) {
    try {//from  w w  w.  ja v  a  2  s  .c o m
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception e) {
        e.printStackTrace();
    }
    JLabel label = new JLabel("Label");
    JTextField field = new JTextField("www.java2s.com!");
    JList list = new JList(new String[] { "A", "B", "C" });
    JScrollPane listPane = new JScrollPane(list);
    listPane.setPreferredSize(new Dimension(250, 100));

    JScrollPane treePane = new JScrollPane(new JTree());
    treePane.setPreferredSize(new Dimension(250, 100));
    JButton button = new JButton("Click me");

    JPanel cp = new JPanel();
    cp.add(label);
    cp.add(field);
    cp.add(listPane);
    cp.add(treePane);
    cp.add(button);

    JFrame frame = new JFrame();
    frame.setTitle("Windows Look and Feel Demo");
    frame.setPreferredSize(new Dimension(280, 300));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(cp);
    frame.pack();
    frame.setVisible(true);

}

From source file:GTKLookAndFeelDemo.java

public static void main(String[] args) {
    try {/*from  www.ja v  a2s  .  co  m*/
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
    } catch (Exception e) {
        e.printStackTrace();
    }
    JLabel label = new JLabel("Label");
    JTextField field = new JTextField("www.java2s.com!");
    JList list = new JList(new String[] { "A", "B", "C" });
    JScrollPane listPane = new JScrollPane(list);
    listPane.setPreferredSize(new Dimension(250, 100));

    JScrollPane treePane = new JScrollPane(new JTree());
    treePane.setPreferredSize(new Dimension(250, 100));
    JButton button = new JButton("Click me");

    JPanel cp = new JPanel();
    cp.add(label);
    cp.add(field);
    cp.add(listPane);
    cp.add(treePane);
    cp.add(button);

    JFrame frame = new JFrame();
    frame.setTitle("Windows Look and Feel Demo");
    frame.setPreferredSize(new Dimension(280, 300));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(cp);
    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 w w  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();// ww w.  j  a v  a2s  .c  o  m
    frame.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();/*from  w w w .  ja  v a2 s  . c  om*/
    frame.setVisible(true);
}

From source file:TextQualityDemo.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_OFF));
    frame.pack();//from w w  w . ja  va 2 s.co  m
    frame.setVisible(true);
}

From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_LCD_HRGB.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_HRGB));
    frame.pack();//from   w w w. j a  v  a 2 s  .c  om
    frame.setVisible(true);
}

From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_LCD_VRGB.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_VRGB));
    frame.pack();/*from ww  w  . j  av a  2  s.c  om*/
    frame.setVisible(true);
}