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:Main.java

public static void main(String s[]) {
    JFrame frame = new JFrame("List Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new Main());
    frame.pack();/*  w  ww .jav a 2  s  .  com*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String argv[]) {
    Main pane = new Main();
    for (int n = 1; n <= 4; n += 1) {
        pane.appendNaive(Color.black, String.valueOf(n) + ' ');
    }/*from   w  w w. j av a2  s.co  m*/
    JFrame f = new JFrame("ColorPane example");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(new JScrollPane(pane));
    f.setSize(600, 400);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JTextArea textArea = new JTextArea(10, 30);
    AbstractDocument doc = (AbstractDocument) textArea.getDocument();
    doc.setDocumentFilter(new EndOfLineFilter());

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(textArea));
    frame.pack();/* w w  w .  ja  v  a  2s  .c  o  m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        @Override/*from   www  .jav  a  2 s  . c  om*/
        public void run() {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(new MyPanel());
            f.pack();
            f.setVisible(true);
        }
    });
}

From source file:Main.java

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

From source file:MainClass.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new ButtonDemo());
    f.setSize(500, 500);//from w ww.jav a 2 s. c o m
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JTextField textField = new JTextField("Prefix_", 20);
    textField.setNavigationFilter(new NavigationFilterPrefixWithBackspace(7, textField));
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(textField);
    frame.pack();/*from  w w w.  j a  va2 s  .  c om*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    MaskFormatter formatter = new MaskFormatter("###-##-####");
    JFormattedTextField tf = new JFormattedTextField(formatter);
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(tf, BorderLayout.NORTH);
    JButton clickBtn = new JButton("Click me!");
    clickBtn.addActionListener(e -> {
        if (!tf.getText().matches(formatter.getMask())) {
            System.err.println("Your Input does not match the pattern!");
        } else {/* www  .  ja v  a 2  s .  c  o m*/
            System.out.println(tf.getText());
        }
    });
    panel.add(clickBtn, BorderLayout.SOUTH);
    JFrame f = new JFrame();

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(panel, BorderLayout.CENTER);
    f.setSize(800, 600);
    f.setVisible(true);
}

From source file:PaneInsertionMethods.java

public static void main(String[] args) {

    final JTextPane pane = new JTextPane();

    pane.replaceSelection("text");
    pane.insertIcon(new ImageIcon("imageName.gif"));
    pane.insertComponent(new JButton("Click Me"));

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(pane, BorderLayout.CENTER);
    frame.setSize(360, 180);//w  w w.ja v a 2 s.c om
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    int TIMER_DELAY = 2000;
    String[] data = { "A", "B", "C", "D" };

    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(data);

    JComboBox<String> combobox = new JComboBox<>(model);
    JList<String> jlist = new JList<>(model);

    new Timer(TIMER_DELAY, new ActionListener() {
        private int count = 0;

        public void actionPerformed(ActionEvent e) {
            model.addElement("count: " + count);
            count++;//from  w  w w.java 2s. c  om
        }
    }).start();

    JPanel comboPanel = new JPanel();
    comboPanel.add(combobox);

    JPanel listPanel = new JPanel();
    listPanel.add(new JScrollPane(jlist));

    JPanel panel = new JPanel(new GridLayout(1, 0));
    panel.add(comboPanel);
    panel.add(listPanel);
    panel.setPreferredSize(new Dimension(400, 200));

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(panel);
    f.pack();
    f.setVisible(true);
}