CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2001
    Location
    Madrid-Spain
    Posts
    1,123

    Question Newbie question about layouts

    Hi!

    I want to do my application like I show in attachment (I did it with setBounds), but I want layouts.

    If I use:
    getContentPane().setLayout (new GridLayout (3,2, 10, 5));

    The result are texfield, buttons, etc too big.
    Any ideas?
    Attached Images Attached Images
    I am Miss Maiden... Miss Iron Maiden :-D

  2. #2
    Join Date
    Jan 2003
    Location
    Israel
    Posts
    137
    Hi Irona,
    I didn't look at your attached file -- but I assume you are trying to create a GUI using swing.

    "GridLayout" makes each component in each cell (of the grid) the same size. What I usually do is first add my "JButton" to a "JPanel" (since the default layout manager for "JPanel" is "FlowLayout" -- which uses the "JButton"'s preferred size), and then add the "JPanel" to the 'content pane'. Example:

    JButton button = new JButton();
    JPanel panel = new JPanel();
    panel.add(button);
    getContentPane.add(panel);

    There is an "Effective Layout Management" short course available from here:

    http://developer.java.sun.com/develo.../AWTLayoutMgr/

    Hope this helps you.

    Good Luck,
    Avi.

  3. #3
    Join Date
    May 2001
    Location
    Madrid-Spain
    Posts
    1,123
    Originally posted by abramia
    Hi Irona,
    I didn't look at your attached file -- but I assume you are trying to create a GUI using swing.

    "GridLayout" makes each component in each cell (of the grid) the same size. What I usually do is first add my "JButton" to a "JPanel" (since the default layout manager for "JPanel" is "FlowLayout" -- which uses the "JButton"'s preferred size), and then add the "JPanel" to the 'content pane'. Example:

    JButton button = new JButton();
    JPanel panel = new JPanel();
    panel.add(button);
    getContentPane.add(panel);

    There is an "Effective Layout Management" short course available from here:

    http://developer.java.sun.com/develo.../AWTLayoutMgr/

    Hope this helps you.

    Good Luck,
    Avi.
    Yes, it helps me... thank you very much for your hint and for the link
    I am Miss Maiden... Miss Iron Maiden :-D

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