Example usage for javax.swing JFrame JFrame

List of usage examples for javax.swing JFrame JFrame

Introduction

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

Prototype

public JFrame(String title) throws HeadlessException 

Source Link

Document

Creates a new, initially invisible Frame with the specified title.

Usage

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("Label Demo");
    f.setLayout(new FlowLayout());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("java2s.com");
    label.setEnabled(false);// ww  w.  j a v a 2 s  .  c  o  m

    f.add(label);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("DefaultButton");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button1 = new JButton("Text Button");
    button1.setMnemonic(KeyEvent.VK_B);
    frame.add(button1);//from ww w. ja v  a2  s .c  o m
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame("Adornment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 100);// w  ww  .  jav a2 s . c  o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(final String[] args) {
    JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.getContentPane().setBackground(Color.red);
    frame.setPreferredSize(new Dimension(400, 300));
    frame.pack();/*from   w w  w.  jav a 2s. co  m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Selecting CheckBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JCheckBox checkBox = new JCheckBox("Hi");

    checkBox.getModel().setMnemonic((char) 'H');

    frame.add(checkBox, BorderLayout.NORTH);
    frame.setSize(300, 100);/*from  ww w  .j av a  2 s.  c om*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Selecting CheckBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JCheckBox checkBox = new JCheckBox("Hi");

    checkBox.getModel().setSelected(true);

    frame.add(checkBox, BorderLayout.NORTH);
    frame.setSize(300, 100);//  ww w.ja  v  a  2 s  .  c  o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Selecting CheckBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JCheckBox checkBox = new JCheckBox("Hi");

    checkBox.getModel().setPressed(true);

    frame.add(checkBox, BorderLayout.NORTH);
    frame.setSize(300, 100);// w  w  w.j  a va  2 s.  c o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Selecting CheckBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JCheckBox checkBox = new JCheckBox("Hi");

    checkBox.getModel().setRollover(true);

    frame.add(checkBox, BorderLayout.NORTH);
    frame.setSize(300, 100);/*from   www  .j  a  va 2s .co m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("JLabel Test");

    frame.setSize(300, 200);/* w  w  w.  jav a 2 s. co  m*/
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    ImageIcon imageIcon = new ImageIcon("icon.gif");
    JLabel label = new JLabel(imageIcon);

    frame.add(label);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Selecting CheckBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JCheckBox checkBox = new JCheckBox("Hi");

    checkBox.getModel().setArmed(false);

    frame.add(checkBox, BorderLayout.NORTH);
    frame.setSize(300, 100);//  ww  w .j a va2s  . c o  m
    frame.setVisible(true);
}