473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Nested gridlayout problems

2
Hi,
I am trying to create a grid which contains three rows, within each row there will be various buttons also in gridlayout.
There are 20 buttons in the middle row, 3 in the top and 4 at the bottom. I want the top and bottom buttons to be of comparable size to the buttons in the centre row. However, each row of the gridlayout is the same size so, as a result, the top and bottom buttons are huge and the central ones are squeezed. I don't know how to fix it. Here is the code I've got. Any help would be appreciated:
import java.awt.*;

public class NestedPanel extends Frame {
public NestedPanel(String title) {
super(title);
setLayout(new GridLayout(3,1,0,40));
addPanel1();
addPanel2();
addPanel3();
}
public void addPanel1() {
Panel panel = new Panel();
panel.setLayout(new GridLayout(0,3,15,0));
panel.add(new Button("TButton X"));
panel.add(new Button("TButton Y"));
panel.add(new Button("TButton Z"));
add(panel);
}
public void addPanel2() {
Panel panel = new Panel();
panel.setLayout(new GridLayout(4,5));
for(int i=1;i<=20;i++)
{
panel.add(new Button("Button " + i));
}
add(panel);
}
public void addPanel3() {
Panel panel = new Panel();
panel.setLayout(new GridLayout(0,4,15,30));
panel.add(new Button("BButton X"));
panel.add(new Button("BButton Y"));
panel.add(new Button("BButton Z"));
panel.add(new Button("BButton Q"));
add(BorderLayout.SOUTH,panel);
}
public static void main(String[] args) {
NestedPanel abc =
new NestedPanel("Nested Panel");
abc.setSize(350, 550);
abc.setVisible(true);
}
}
Sep 18 '07 #1
1 2655
JosAH
11,448 Expert 8TB
As you already noticed a Gridlayout allows equal space to all of its components.
Have a look at the new SprintLayout class instead. The API page for this
class even has a link to a Java Tutorial on exactly this layout manager.

kind regards,

Jos
Sep 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: nimmi_srivastav | last post by:
Below you will see an example of a nested conditional expression that this colleague of mine loves. He claims that it is more efficient that a multi-level if-else-if structure. Moreover, our...
2
by: Leszek | last post by:
Hello, Is it possible to create "nested radio button lists" using VS.NET. I mean to create something like that (the following code does not work): <asp:RadioButtonList id="RadioButtonList1"...
0
by: Kenneth | last post by:
Hi, I use VS.NET Enterprice Achitect 2002 version and when I try to create a page in gridlayout all font sizes goes banana in all 'Label' and 'RequiredFieldValidator' objects. TextBoxes,...
5
by: ~~~ .NET Ed ~~~ | last post by:
Hi, As you all know when an ASP.NET web form is created that will include web controls and such, it contains a FORM that that identifies the web form and its containing controls. Well, I have a...
77
by: Peter Olcott | last post by:
http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html The above link shows that C# is 450% slower on something as simple as a nested loop....
1
by: Tina | last post by:
I see that in VS.Net 2005, grid layout is no longer supported. I really liked gridlayout because I could put things exactly where I wanted them. How can we put things exactly where we want them...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
4
by: Wolfgang Draxinger | last post by:
If you know languages like Python or D you know, that nested functions can be really handy. Though some compilers (looking at GCC) provide the extension of nested functions, I wonder, how one...
7
by: brasse | last post by:
Hello! I have been running in to some problems when using contextlib.nested(). My problem arises when using code similar to this: from __future__ import with_statement from contextlib...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.