CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    105

    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?

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: JTextField setBounds

    Quote Originally Posted by Alexz003 View Post
    ... 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
  •  





Click Here to Expand Forum to Full Width

Featured