Results 1 to 3 of 3

Thread: Gidbag Question

  1. #1
    zardos is offline Member
    Join Date
    Jan 2011
    Posts
    8
    Rep Power
    0

    Default Gidbag Question

    hello, am tying to get this effect


    Using a gridBagLayout, but i cant get the textFiled to be longer then the Label?

    Java Code:
    pane.setLayout(new GridBagLayout());
    	GridBagConstraints c = new GridBagConstraints();
    	c.fill = GridBagConstraints.HORIZONTAL;
    	
    	label = new JLabel("Label 1");
    	c.gridx = 0;
    	c.gridy = 0;
    	pane.add(label, c);
    	
    	
    
        input = new JTextField("");
        c.weighty = 1.0;
    	c.gridwidth = 3;   //3 columns wide
    	c.gridx = 1;
    	c.gridy = 0;
    	input.setSize(40,input.getHeight());
    	pane.add(input, c);
    I knew am a complete noob, and cant find anny tutorials for doing this, but if i can figure out how to only do this i think am golden, all workes well if i add 3 tabels ontop, but i dont want that :/

    Thanks!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default

    Use weightx, not gridwidth. And construct your JTextFields with an int columnsize.

    db

  3. #3
    zardos is offline Member
    Join Date
    Jan 2011
    Posts
    8
    Rep Power
    0

    Default

    Thank you Darryl!
    You dont know how much this ment to me, it is rediculus but i was a bit down to day, u saved my day! :)
    Love selfless people like u,
    thank!

Similar Threads

  1. Question concerning question marks and colons
    By jim01 in forum New To Java
    Replies: 17
    Last Post: 01-14-2011, 01:05 AM
  2. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 09:49 AM
  3. Question about what this do.
    By Syfer in forum New To Java
    Replies: 1
    Last Post: 07-03-2010, 09:35 AM
  4. RMI question
    By alvandrood in forum New To Java
    Replies: 1
    Last Post: 09-14-2009, 01:36 PM
  5. question
    By zizou147 in forum New To Java
    Replies: 13
    Last Post: 07-04-2008, 08:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •