Example usage for javax.swing JFrame setVisible

List of usage examples for javax.swing JFrame setVisible

Introduction

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

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Window depending on the value of parameter b .

Usage

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    Box form = Box.createVerticalBox();
    form.add(new JLabel("Name:"));
    form.add(new JTextField("User Name"));

    form.add(new JLabel("Birthday:"));
    JFormattedTextField birthdayField = new JFormattedTextField(new SimpleDateFormat("MM/dd/yy"));
    birthdayField.setValue(new Date());
    form.add(birthdayField);/*from ww  w  .  jav a 2 s. co m*/

    form.add(new JLabel("Age:"));
    form.add(new JFormattedTextField(new Integer(32)));

    form.add(new JLabel("Hairs on Body:"));
    JFormattedTextField hairsField = new JFormattedTextField(new DecimalFormat("###,###"));
    hairsField.setValue(new Integer(100000));
    form.add(hairsField);

    form.add(new JLabel("Phone Number:"));
    JFormattedTextField phoneField = new JFormattedTextField(new MaskFormatter("(###)###-####"));
    phoneField.setValue("(314)888-1234");
    form.add(phoneField);

    JFrame frame = new JFrame("User Information");
    frame.getContentPane().add(form);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String s[]) {
    JFrame frame = new JFrame("Scroll Bar Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new MainClass());
    frame.setSize(200, 200);//w  w w  .j  a  v  a  2 s. c o m
    frame.setVisible(true);
}

From source file:Main.java

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

    frame.add(new Main());
    frame.setSize(200, 300);/*from   w w w  .  jav  a2  s .c o m*/
    frame.setLocationByPlatform(true);
    frame.setVisible(true);
}

From source file:TreeSelectionOption.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);/*ww w .j ava 2s  . com*/
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:GrayImage.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.add(new GrayImage());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 400);//from   w w  w . j a  v  a2  s  . c  o m
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:Main.java

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

    JLabel label = new JLabel("<html>bold <br> plain</html>");
    frame.add(label);//from w  w  w.java  2  s .co m

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

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.getContentPane().add(new Main().makeUI());
    frame.setSize(320, 240);// w  w  w  . j a  v  a 2 s  . c o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JToolBar toolbar = new JToolBar(JToolBar.VERTICAL);

    JButton selectb = new JButton(new ImageIcon("select.gif"));
    JButton freehandb = new JButton(new ImageIcon("freehand.gif"));
    JButton shapeedb = new JButton(new ImageIcon("shapeed.gif"));
    JButton penb = new JButton(new ImageIcon("pen.gif"));

    toolbar.add(selectb);//w w  w  . jav  a2 s  .c  o m
    toolbar.add(freehandb);
    toolbar.add(shapeedb);
    toolbar.add(penb);

    JFrame f = new JFrame();
    f.add(toolbar, BorderLayout.WEST);

    f.setSize(250, 350);
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:Text.java

public static void main(String[] args) {
    Text text = new Text();
    JFrame frame = new JFrame("Sonnet 55");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(text);/*from ww  w  .j ava2  s.c om*/
    frame.setSize(500, 470);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel gui = new JPanel(new BorderLayout());
    gui.setPreferredSize(new Dimension(400, 100));

    JDesktopPane dtp = new JDesktopPane();
    gui.add(dtp, BorderLayout.CENTER);

    JButton newFrame = new JButton("Add Frame");

    ActionListener listener = new ActionListener() {
        private int disp = 10;

        @Override//from w  w w  .  j  av a  2 s  . com
        public void actionPerformed(ActionEvent e) {
            JInternalFrame jif = new JInternalFrame();
            dtp.add(jif);
            jif.setLocation(disp, disp);
            jif.setSize(100, 100);
            disp += 10;
            jif.setVisible(true);
        }
    };
    newFrame.addActionListener(listener);

    gui.add(newFrame, BorderLayout.PAGE_START);

    JFrame f = new JFrame();
    f.add(gui);
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.setLocationByPlatform(true);

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