Thread: GUI size
View Single Post
Old Jun 26th, 2005, 4:48 PM   #8
squishiful
Programmer
 
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4 squishiful is on a distinguished road
If you want to set the exact location and size of a component use the following code:
//imports
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Component;

//code
JPanel pnl = new JPanel();
pnl.setLayout(null);
JButton btn = new JButton();
//sets the size and location of a component
//[component].setBounds(int x, int y, int width, int height);
btn.setBounds(50, 50, 100, 30);
pnl.add(btn);
add(pnl);

Very helpful if you want absolute control.
__________________
I steal hippos...
squishiful is offline   Reply With Quote