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) {
    final int columnCount = 10;
    final int side = 25;
    final int[][] grid = new int[50][columnCount];

    JPanel panel = new JPanel() {
        public void paintComponent(Graphics g) {
            Font font = new Font("WingDings", Font.PLAIN, 14);
            g.setFont(font);// w w  w  .ja  v a  2 s. c  o m
            int off = 0;
            for (int i = 0; i < 256 * 256; i++) {
                if (font.canDisplay((char) i) == false) {
                    continue;
                }
                off++;
                grid[off / columnCount][off % columnCount] = i;
                int x = off % columnCount * side;
                int y = (off / columnCount) * side + side;
                g.drawString(Character.toString((char) i), x, y);

            }
        }
    };
    JFrame frame = new JFrame();
    panel.setSize(300, 300);
    frame.getContentPane().add(panel);
    frame.setSize(300, 300);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JTextPane textPane = new JTextPane();
    textPane.setText("12345678\n\t1\t2\t3a");
    JScrollPane scrollPane = new JScrollPane(textPane);
    scrollPane.setPreferredSize(new Dimension(700, 100));

    setTabs(textPane, 8);//from  w  w w.ja v  a  2s.  com

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(scrollPane);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTextField component = new JTextField(10);
    JTextField component1 = new JTextField(10);
    component.addFocusListener(new MyFocusListener());
    component1.addFocusListener(new MyFocusListener());
    JFrame f = new JFrame();
    f.setLayout(new FlowLayout());
    f.add(component1);//from  w  w  w  . j  av a  2s. c om
    f.add(component);
    f.pack();
    f.setVisible(true);

}

From source file:NestedJSplitPane.java

public static void main(String[] a) {
    int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT;

    int VERTSPLIT = JSplitPane.VERTICAL_SPLIT;

    boolean continuousLayout = true;

    JLabel label1 = new JLabel("a");
    JLabel label2 = new JLabel("b");
    JLabel label3 = new JLabel("c");
    JSplitPane splitPane1 = new JSplitPane(VERTSPLIT, continuousLayout, label1, label2);
    splitPane1.setOneTouchExpandable(true);
    splitPane1.setDividerSize(2);//  w  ww .  j a v  a2  s.  c o m
    splitPane1.setDividerLocation(0.5);

    JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, splitPane1, label3);
    splitPane2.setOneTouchExpandable(true);
    splitPane2.setDividerLocation(0.4);
    splitPane2.setDividerSize(2);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(splitPane2);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    final JTextPane pane = new JTextPane();
    pane.setText("Some text");

    JButton buttonButton = new JButton("Insert label");
    buttonButton.addActionListener(e -> {
        JLabel label = new JLabel("label");
        label.setAlignmentY(0.85f);//from   www.j ava2  s  . co m
        pane.insertComponent(label);

    });

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(buttonButton, BorderLayout.SOUTH);
    panel.add(pane, BorderLayout.CENTER);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(panel);
    frame.setSize(400, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(300, 200);//from   w w w  .j  ava2 s  .co  m
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.add(new Main());

    frame.setVisible(true);
}

From source file:TextLayoutLineBreakerMeasurer.java

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

    frame.setSize(200, 200);/*from w w w . j  a  v  a 2s. c  o m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    // Read from a URL
    URL url = new URL("http://java.org/source.gif");
    Image image = ImageIO.read(url);

    JFrame frame = new JFrame();
    JLabel label = new JLabel(new ImageIcon(image));
    frame.getContentPane().add(label, BorderLayout.CENTER);
    frame.pack();/*from   w w w  .  j a va 2s . co  m*/
    frame.setVisible(true);
}

From source file:RotateTransformed.java

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

From source file:MainClass.java

public static void main(String[] args) {
    JFrame jf = new JFrame("Demo");
    Container cp = jf.getContentPane();
    MyCanvas tl = new MyCanvas();
    cp.add(tl);/*from w  w  w .  j  a v a2s.  c  o m*/
    jf.setSize(300, 200);
    jf.setVisible(true);
}