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() throws HeadlessException 

Source Link

Document

Constructs a new frame that is initially invisible.

Usage

From source file:MessagePopUps.java

public static void main(String[] a) {
    JFrame parent = new JFrame();

    JOptionPane.showMessageDialog(parent, "Printing complete");
    //    JOptionPane.showInternalMessageDialog(parent, "Printing complete");

}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String htmlLabel = "<html><sup>HTML</sup> <sub><em>Label</em></sub><br>"
            + "<font color=\"#FF0080\"><u>Multi-line</u></font>";
    JLabel label = new JLabel(htmlLabel);

    System.out.println(label.getText());

    frame.add(label);/*from   w ww  .  ja v  a 2 s. c o  m*/

    frame.setSize(300, 200);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {

    JFrame frame = new JFrame();

    frame.setVisible(true);/*  w  w w.  ja  va  2 s .  c  om*/

    String message = JOptionPane.showInputDialog(frame, "Would this be enough?.", "My dialog asks....",
            JOptionPane.INFORMATION_MESSAGE);

    System.out.println("Got " + message);

    frame.dispose();
}

From source file:Absolute.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setLayout(null);/*from w  w w . j  ava  2s  .c o m*/

    JButton ok = new JButton("OK");
    ok.setBounds(50, 150, 80, 25);

    JButton close = new JButton("Close");
    close.setBounds(150, 150, 80, 25);

    f.add(ok);
    f.add(close);

    f.setSize(300, 250);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    // Create a frame
    JFrame frame = new JFrame();

    // Get default close operation
    int op = frame.getDefaultCloseOperation(); // HIDE_ON_CLOSE

    // Set to exit on close
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    // Create a frame
    JFrame frame = new JFrame();

    // Get default close operation
    int op = frame.getDefaultCloseOperation(); // HIDE_ON_CLOSE

    // Set to ignore the button
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

}

From source file:MainClass.java

public static void main(final String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTextArea leftTextArea = new JTextArea();
    frame.add(leftTextArea);/*from ww w.j  a v a  2  s  .  co m*/
    leftTextArea.paste();

    frame.setSize(250, 150);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JFrame frame = new JFrame();
    String message = "message";
    String text = JOptionPane.showInputDialog(frame, message);
    if (text == null) {
        // User clicked cancel
    }//  w  ww .j  a v a  2 s  .c o m

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JFrame frame = new JFrame();
    String message = "message";
    int answer = JOptionPane.showConfirmDialog(frame, message);
    if (answer == JOptionPane.YES_OPTION) {
        // User clicked YES.
    } else if (answer == JOptionPane.NO_OPTION) {
        // User clicked NO.
    }//  www. java2  s  .  c om
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.getContentPane().setBackground(Color.PINK);
    frame.setSize(200, 200);/*  w ww  .ja v a  2s  . co  m*/
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}