Example usage for javax.swing JFrame setSize

List of usage examples for javax.swing JFrame setSize

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

The width and height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .

Usage

From source file:ImageDuplicity.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setLayout(new BorderLayout());
    Component c = new ImageDuplicity();
    f.add(c, BorderLayout.CENTER);
    f.setSize(200, 250);
    f.setVisible(true);//from   ww  w  .  ja va  2  s .  c o  m
}

From source file:MainClass.java

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

From source file:Main.java

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

    Main demo = new Main();
    frame.setContentPane(demo.createMenuBar());

    frame.setSize(300, 100);
    frame.setVisible(true);/*w w  w. j a  va  2  s .  co m*/
}

From source file:Main.java

public static void main(String[] args) {
    JTextArea ta = new JTextArea();
    ta.setLineWrap(true);/*  w w w.  j a  v a2s  . co m*/

    Action[] actions = ta.getActions();
    JMenuBar menubar = new JMenuBar();
    JMenu actionmenu = new JMenu("Actions");
    menubar.add(actionmenu);

    JMenu firstHalf = new JMenu("1st Half");
    JMenu secondHalf = new JMenu("2nd Half");
    actionmenu.add(firstHalf);
    actionmenu.add(secondHalf);

    int mid = actions.length / 2;
    for (int i = 0; i < mid; i++) {
        firstHalf.add(actions[i]);
    }
    for (int i = mid; i < actions.length; i++) {
        secondHalf.add(actions[i]);
    }

    // Show it . . .
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(ta);
    f.setJMenuBar(menubar);
    f.setSize(300, 200);
    f.setVisible(true);
}

From source file:Applet1c.java

public static void main(String[] args) {
    JApplet applet = new Applet1c();
    JFrame frame = new JFrame("Applet1c");
    // To close the application:
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(applet);/*w w w.  j ava2 s  .  c  o  m*/
    frame.setSize(100, 50);
    applet.init();
    applet.start();
    frame.setVisible(true);
}

From source file:TabExample.java

public static void main(String[] args) {

    JTextPane pane = new JTextPane();
    TabStop[] tabs = new TabStop[4];
    tabs[0] = new TabStop(60, TabStop.ALIGN_RIGHT, TabStop.LEAD_NONE);
    tabs[1] = new TabStop(100, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE);
    tabs[2] = new TabStop(200, TabStop.ALIGN_CENTER, TabStop.LEAD_NONE);
    tabs[3] = new TabStop(300, TabStop.ALIGN_DECIMAL, TabStop.LEAD_NONE);
    TabSet tabset = new TabSet(tabs);

    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.TabSet, tabset);
    pane.setParagraphAttributes(aset, false);
    pane.setText("\tright\tleft\tcenter\tdecimal\n" + "\t1\t1\t1\t1.0\n"
            + "\t200.002\t200.002\t200.002\t200.002\n" + "\t.33\t.33\t.33\t.33\n");

    JFrame frame = new JFrame("TabExample");
    frame.setContentPane(new JScrollPane(pane));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(360, 120);
    frame.setVisible(true);/*  w  ww.j  ava  2 s  .c o m*/
}

From source file:Main.java

public static void main(String args[]) throws BadLocationException {
    JTextPane textPane1 = new JTextPane();

    MutableAttributeSet black = new SimpleAttributeSet();
    MutableAttributeSet red = new SimpleAttributeSet();

    StyleConstants.setForeground(black, Color.black);
    StyleConstants.setForeground(red, Color.red);
    textPane1.setEditorKit(new StyledEditorKit());
    doc1 = textPane1.getDocument();/*ww w.  ja v  a  2s.  c o m*/

    append1("This is a Test!\n");

    attribute = red;
    append1("Hello world! Hello Stackoverflow\n");

    attribute = black;
    append1("the text is black again\n");

    StyledDocument styledDocument = textPane1.getStyledDocument();
    Element element;

    JTextPane textPane2 = new JTextPane();
    textPane2.setEditorKit(new StyledEditorKit());

    doc2 = textPane2.getDocument();
    for (int i = 0; i < styledDocument.getLength(); i++) {
        element = styledDocument.getCharacterElement(i);
        AttributeSet attributeNew = element.getAttributes();
        System.out.println(i);
        append2(styledDocument.getText(i, 1), attributeNew);
    }

    JFrame frame1 = new JFrame();
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame1.setSize(400, 300);
    frame1.getContentPane().add(new JScrollPane(textPane1), BorderLayout.CENTER);
    frame1.setVisible(true);

    JFrame frame2 = new JFrame();
    frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame2.setSize(400, 300);
    frame2.setLocation(300, 0);
    frame2.getContentPane().add(new JScrollPane(textPane2), BorderLayout.CENTER);
    frame2.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    final JButton ok = new JButton("ok");
    JCheckBox cb = new JCheckBox("Enabled", true);
    cb.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (ok.isEnabled())
                ok.setEnabled(false);//from  w  ww .jav  a  2 s  . co  m
            else
                ok.setEnabled(true);
        }
    });

    ButtonModel model = new DefaultButtonModel() {
        public void setEnabled(boolean b) {
            if (b)
                System.out.println("Pressed: true");
            else
                System.out.println("Pressed: false");

            super.setEnabled(b);
        }

        public void setArmed(boolean b) {
            if (b)
                System.out.println("Armed: true");
            else
                System.out.println("Armed: false");

            super.setArmed(b);
        }

        public void setPressed(boolean b) {
            if (b)
                System.out.println("Pressed: true");
            else
                System.out.println("Pressed: false");

            super.setPressed(b);
        }

    };

    ok.setModel(model);

    JFrame f = new JFrame();
    f.setLayout(new FlowLayout());
    f.add(ok);
    f.add(cb);

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

From source file:Hypnosis1.java

public static void main(String[] args) {
    JFrame f = new JFrame("Hypnosis");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new Hypnosis1(4));
    f.setSize(300, 300);
    f.setVisible(true);/*from www.j a v  a2 s .com*/
}

From source file:Main.java

public static void main(String[] args) {
    DocumentFilter dfilter = new UpperCaseFilter();

    JTextArea jta = new JTextArea();
    ((AbstractDocument) jta.getDocument()).setDocumentFilter(dfilter);

    JFrame frame = new JFrame("UpcaseFilter");
    frame.getContentPane().add(jta, java.awt.BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200, 120);
    frame.setVisible(true);/*from   www  .  j ava  2s.  co  m*/
}