473,779 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridbaglayout - mysterious spaces

2 New Member
Hi,
I'm trying to design a kind of calculator GUI using gridbaglayout.
At the top of the calculator will be a couple of menus and then will come the section with all the buttons etc.
Initially, I have designed the menu titles purely as labels (since I haven't figured out how to create actual menus - any help there would be great!) but the final menu item is separated by a mysterious space from the other ones.
Here is the code I've got so far - the "About" label is appearing far to the right of the other labels.

LayoutExample window = new LayoutExample() ;
window.setTitle ("Layout Example Application");
window.pack();
window.setVisib le(true);

public LayoutExample()
{
//setLayout(new GridLayout(1,2) );

p2 = new Panel();
p2.setBackgroun d(Color.gray);
add(p2);
gridBag();
}

public void gridBag()
{
// Set up GridBagConstrai nts and layout and apply it to the panel
GridBagConstrai nts c = new GridBagConstrai nts();
GridBagLayout gridbag = new GridBagLayout() ;
p2.setLayout(gr idbag);

// Create the labels and add them to the panel
Label top = new Label("File");
top.setAlignmen t(Label.CENTER) ;
gridbag.setCons traints(top, c);
p2.add(top);

Label top2 = new Label("Edit");
top2.setAlignme nt(Label.CENTER );
gridbag.setCons traints(top2, c);
p2.add(top2);

Label top3 = new Label("View");
top3.setAlignme nt(Label.CENTER );
gridbag.setCons traints(top3, c);
p2.add(top3);

c.gridwidth = GridBagConstrai nts.REMAINDER;
Label top4 = new Label("About");
top4.setAlignme nt(Label.CENTER );
gridbag.setCons traints(top4, c);
p2.add(top4);

// On next line, create the textarea
TextArea comments = new TextArea(3, 50);
comments.setEdi table(true);
comments.setTex t("Comments:" );
gridbag.setCons traints(comment s, c);
p2.add(comments );

}
Sep 19 '07 #1
0 1130

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

Similar topics

1
5022
by: Rui Pacheco | last post by:
Hi everyone I'm trying to develop an applet using JApplet. As the layout manager I decided to use GridBagLayout. My layout will consist mainly of 7 JComboBox's in a single row and one JTable beneath them. My problem is, I can't even put the JComboBox's on the top of the Applet. Everytime I do the add method, they stay put in the middle of the Applet. I've tried setting GridBagConstraints.gridy = 0 but it didn't do me any good. Any help...
0
1423
by: Peter Wieser | last post by:
this short program does not do as it should!!! when you resize the frame, the weights (3 and 1) would not stay the same. why??? import java.applet.Applet; import java.awt.event.*; import java.util.*; import java.awt.*; import com.sun.j3d.utils.universe.*; import javax.swing.*; import javax.media.j3d.*;
1
1738
by: python473 | last post by:
Friends - I have tried to do abolute positioning using gridbaglayout, but am having no success in jython. One book I have been referencing says that it only works with JPanels. Could someone post a snippet of code that works for a button? I am so close so just a hint would help. Thanks as always. - John
4
3420
by: Viorel | last post by:
For me is a little bit mysterious how work encoding and decoding functions, what is underneath of their calling? Encoding1.GetBytes(string1); in particularly ASCII.GetBytes(string1) Encoding1.GetChars(string1); Encoding1.GetChars(arrayofbytes1);
0
2503
by: SteveS | last post by:
Can anyone help with a mysterious problem that has arisen since 'upgrading' from 8 to 9.2.0.4? The situation is this: Queries that worked fine under 8 are now producing *really* strange results under 9.2.0.4. The queries all involve functions, including built-in functions like NVL. The strangeness is that less than the expected number of rows is returned *or* and ORA-01422 is generated. Here's an example:
2
1779
by: M Wells | last post by:
Hi All, I'm trying to track down a mysterious problem we're experiencing in which updates and inserts to tables in our mssql2k server appear to be 'disappearing.' To explain our situation: We have a web page (written in ASP, if that's relevant) on which we accept enrollment information.
28
2474
by: Glenn Alcott | last post by:
On a page I am working on which has three graphic buttons, there is a small line between two of the buttons which links to the same page as one of the buttons. I have no idea how this line got in there and would appreciate anyone checking it out for a clue that I may be missing. The page is at http://www.ultimateinsurancejobs.com/test2/login1.asp The line is between the Register and Lost Password buttons, and links to the same page as the...
1
2195
by: Bruce W.1 | last post by:
BACKGROUND My ASP.NET app has been running (or rather available) on a server for about 4 months now. The server is at http://www.webhost4life.com/ They don't add cookies to any of the sites they host. The app was created with VS.NET v.7. And the server is running Windows 2000 Advanced Server.
3
2963
by: Jay Levitt | last post by:
On http://www.wellesleycarriagehouse.com, there is no margin around the thumbnail images at bottom. I've verified that Firefox doesn't even THINK there's a margin, using Firebug 0.4. So why is there space around the images in Firefox 1.5 for Windows? Jay Levitt
0
9632
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10302
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8958
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.