Define somewhere the consts :
private static final int BUTTON_LOCATION_X = 300; // location x
private static final int BUTTON_LOCATION_Y = 50; // location y
private static final int BUTTON_SIZE_X = 140; // size height
private static final int BUTTON_SIZE_Y = 50; // size width
and then below :
JButton startButton = new JButton("Click Me To Start!");
// startButton.setBounds(300, 50,140, 50 );
startButton.setBounds(BUTTON_LOCATION_X
, BUTTON_LOCATION_Y,
BUTTON_SIZE_X,
BUTTON_SIZE_Y );
contentPane.add(startButton);
where contentPane
is the Container
object that holds the entire frame :
JFrame frame = new JFrame("Some name goes here");
Container contentPane = frame.getContentPane();
I hope this helps , works great for me ...