Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do you control the distance between rows in a GridLayout

Posted on 2003-10-26
6
Medium Priority
?
271 Views
Last Modified: 2008-03-06
How do you control the distance between rows in a GridLayout
0
Comment
Question by:rayskelton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:smitty22
ID: 9624365
You can construct your layout with:  GridLayout(int rows, int cols, int hgap, int vgap), where vgap is the pixel distance between rows, and similarly hgap is the distance between columns.

You can also specify the gaps later with setHgap and setVGap.
0
 

Author Comment

by:rayskelton
ID: 9624417
I have tried this with no affect. Any ideas why this would not work?
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9625481
How do you mean it didn't work?  Could you post some code?

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rayskelton
ID: 9631109
I am displaying JLabels in a Dialog of queried information and asking confirmation. My GridLayout is in the form of GridLayout(3,2,1,1) and my dialog is sized  setSize(400, 150). Arg 3 and 4 of GridLayout do not appear to control the content the way I would like. The code displays with very large gaps between the grid rows. I can control this spacing to some extent by adjusting arg 2 of setSize(). Below is a code snippet. There may not be a problem, just it is working in a different form than I am expection. If so, how do I control the spacing between grids?
-----------------------
      final JPanel mainPanel = new JPanel(new BorderLayout());
      final JPanel buttonGroupPanel = new JPanel();
     
      JPanel editPanel = new JPanel(new GridLayout());

      // get the edit pane
      editPanel = getEditPane();

      JPanel buttonPanel = new JPanel();
      // decision processing buttons
      buttonPanel = getButtonPane();
     
      mainPanel.add(editPanel);
      mainPanel.add(buttonPanel, BorderLayout.SOUTH);
      c.add(mainPanel);

      JFrame frame = new JFrame();
      Window window = new Window(frame);
      setLocation(CenterWindow.getPosition(window));
      setSize(400, 150);
      show();
------------------------------

 private JPanel getEditPane()
{
     
     JPanel editPanel = new JPanel(new GridLayout(3,2,1,1));
     .......

}
0
 
LVL 15

Accepted Solution

by:
jimmack earned 500 total points
ID: 9640632
Sorry for the late response.  I've had two days where my system couldn't resolve the EE URL :-(

What do you add to the editPanel inside the getEditPane() method?

Two other observations:

Change the following:

>>      JPanel editPanel = new JPanel(new GridLayout());
>>
>>      // get the edit pane
>>      editPanel = getEditPane();

to:

        JPanel editPanel = getEditPane();

I'm not sure what you are doing with the following:

>>      JFrame frame = new JFrame();
>>      Window window = new Window(frame);
>>      setLocation(CenterWindow.getPosition(window));
>>      setSize(400, 150);
>>      show();

Shouldn't this be:

        JFrame frame = new JFrame();
        frame.getContentPane().add(mainPanel);
        frame.setSize(400, 150);
        frame.show();
0
 

Author Comment

by:rayskelton
ID: 9646102
i'll try yor approach. It looks good,so will close out this ticket.
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This video teaches viewers about errors in exception handling.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question