Solved

How do you control the distance between rows in a GridLayout

Posted on 2003-10-26
6
266 Views
Last Modified: 2008-03-06
How do you control the distance between rows in a GridLayout
0
Comment
Question by:rayskelton
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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 125 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java 8 lambda expresssions exception handling 3 91
maven project error 5 56
how to see all occupied ports on windows 10 laptop 15 65
Unhandled exception type Exception 18 31
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

809 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