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);
}
}
It looks like you are taking your first steps into swing. The questions that you are asking belong to an area of gui design called layout. Exactly how you set the position of your button depends hea ily on the layout. I would suggest that you find a swing tutorial and run through it. I started with the Java Swing Trail: http://download.oracle.com/javase/tutorial/uiswing
In the Java api documents look for BorderLayout and GridLayout. They are the easiest to start with.