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[] args) {
    JFrame frame1 = new JFrame();
    frame1.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame1.setUndecorated(true);/*from   w ww  .  j av a  2 s . c om*/
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame1.setVisible(true);

    JDialog nonModalDialog = new JDialog(frame1, "Non-Modal Dialog", ModalityType.MODELESS);
    nonModalDialog.add(Box.createRigidArea(new Dimension(200, 200)));
    nonModalDialog.pack();
    nonModalDialog.setVisible(true);

    JDialog modalDialog = new JDialog(frame1, "Modal Dialog", ModalityType.APPLICATION_MODAL);
    modalDialog.add(Box.createRigidArea(new Dimension(200, 200)));
    modalDialog.pack();
    modalDialog.setVisible(true);

}

From source file:Main.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new Main());
    f.pack();/*from  w  w w  .  j a  va  2 s .  c  o m*/
    f.setSize(new Dimension(300, 200));
    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    new Main().initContainer(frame);
    frame.pack();/*ww  w.j  a v a  2s  .  co m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    SpringLayout layout = new SpringLayout();
    JPanel p = new JPanel(layout);
    p.setBorder(BorderFactory.createLineBorder(Color.GREEN, 10));

    JLabel l1 = new JLabel("label: width=90%", SwingConstants.CENTER);
    l1.setBorder(BorderFactory.createLineBorder(Color.RED, 1));
    JButton l2 = new JButton("button: width=50%");

    Spring panelw = layout.getConstraint(WIDTH, p);

    SpringLayout.Constraints c1 = layout.getConstraints(l1);
    c1.setX(Spring.constant(0));// ww w . j ava 2  s .co  m
    c1.setY(Spring.constant(20));
    c1.setWidth(Spring.scale(panelw, 0.9f));
    p.add(l1);

    SpringLayout.Constraints c2 = layout.getConstraints(l2);
    c2.setWidth(Spring.scale(panelw, 0.5f));
    layout.putConstraint(SOUTH, l2, -20, SOUTH, p);
    layout.putConstraint(EAST, l2, -20, EAST, p);
    p.add(l2);

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.getContentPane().add(p);
    f.setSize(320, 240);
    f.setVisible(true);
}

From source file:InvestmentTable.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            JFrame frame = new InvestmentTableFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
        }/*from  w w w  .  j ava  2s. c  o  m*/
    });
}

From source file:MainClass.java

public static void main(String args[]) {
    Object rows[][] = { { "A", "a" }, { "B", "b" }, { "E", "e" } };
    Object headers[] = { "Upper", "Lower" };
    JTable table = new JTable(rows, headers);
    table.setTableHeader(null);/*from   w  ww. j  a  v  a2 s  .  c o m*/
    JScrollPane scrollPane = new JScrollPane(table);
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:TableDemoApplet.java

public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(3);
            createGUI(frame.getContentPane());
            frame.pack();//from www  .  ja v  a2  s.c om
            frame.setVisible(true);
        }
    });
}

From source file:MyCanvas.java

public static void main(String args[]) {
    JFrame mainFrame = new JFrame("Graphics demo");
    mainFrame.getContentPane().add(new MyCanvas());
    mainFrame.pack();//www .  j  a  va  2 s .c o  m
    mainFrame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel topPanel = new JPanel();
    topPanel.setPreferredSize(new Dimension(200, 200));
    topPanel.setBackground(Color.WHITE);

    JTextArea chatArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(chatArea);

    JPanel mainPanel = new JPanel(new BorderLayout(5, 5));
    mainPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    mainPanel.add(topPanel, BorderLayout.CENTER);
    mainPanel.add(scrollPane, BorderLayout.SOUTH);

    chatArea.getDocument().addDocumentListener(new DocumentListener() {

        @Override/* ww w. j  av a2s .c o m*/
        public void insertUpdate(DocumentEvent e) {
            updateLineCount();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateLineCount();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateLineCount();
        }

        private void updateLineCount() {
            int lineCount = chatArea.getLineCount();
            if (lineCount <= 4) {
                chatArea.setRows(lineCount);
                mainPanel.revalidate();
            }
        }
    });

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

From source file:TransparentRectangles.java

public static void main(String[] args) {

    JFrame frame = new JFrame("Transparent Rectangles");
    frame.add(new TransparentRectangles());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(600, 100);/*ww w .  j  a  v  a2  s .  co  m*/
    frame.setVisible(true);
}