Java - How can I edit the size and position of a button using Swing?

Posted by mino on Stack Overflow See other posts from Stack Overflow or by mino
Published on 2012-01-18T01:18:11Z Indexed on 2012/06/25 9:16 UTC
Read the original article Hit count: 230

Filed under:
|
|
|
|

I have the following code but I'd like to structure several buttons of certain sizes. I'm just wondering how to do this as I've Googled it and found several different methods but none seem to work. Any advice?

import javax.swing.*;

public class GUI {

    public static void main(String[] args) {

        JFrame window = new JFrame();
        window.setSize(500, 500);
        window.setTitle("My Application");

        JButton button = new JButton("click me");
        window.add(button);

        window.setVisible(true);

    }

}

© Stack Overflow or respective owner

Related posts about java

Related posts about swing