-
January 29th, 2010, 08:57 PM
#1
JTextField setBounds
ok so i am trying to create a program but when i try set its bounds, i always get a small box each time...
Code:
JTextField ip = new JTextField();
ip.setVisible(true);
ip.setBounds(10,10,40,40);
c.gridx=1;
c.gridy=1;
ip.requestFocus();
frame.add(panel);
//Labels
JLabel ipAdd = new JLabel("Internet Protocal");
//panel.add(ipAdd);
panel.add(ip);
am i doing something wrong, i have tried many different numbers for the bounds and it just doesn't want to work. What is a good size text area?
-
January 30th, 2010, 06:34 AM
#2
Re: JTextField setBounds
Originally Posted by Alexz003
... i have tried many different numbers for the bounds and it just doesn't want to work.
Setting the bounds relocates and resizes the component in the absence of any layout managers. If you are using a layout manager (which you will be unless you explicitly set it null), you'll find that only max, min, and preferred size are respected - otherwise the layout manager couldn't do its job. I would suggest setting the preferred size to the size you want and letting the layout manager handle the positioning. See Laying Out Components Within a Container.
What is a good size text area?
That depends what you want to use it for, and the design of your application.
That’s what’s cool about working with computers. They don’t argue, they remember everything, and they don’t drink all your beer...
Paul Leary
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|