This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Removing panel borders Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Removing panel borders" Watch "Removing panel borders" New topic
Author

Removing panel borders

Chris Zaremba
Ranch Hand

Joined: Nov 22, 2010
Posts: 54

Suddenly my application has come together and I'm just going through cleaning everything up for submission but I've hit on a problem. The following code is an example



I want to get rid of the margin/inset/padding shown in green in the example screen shot to get the left sides of the text boxes to line up. I've tried adding empty borders and a few other things but can't get rid of it.



Does anyone have an answer?



[Thumbnail for swing.jpg]



SCJA, OCPJP, OCMJD
David Byron
Rancher

Joined: Jan 20, 2009
Posts: 171

Chris Zaremba wrote:I want to get rid of the margin/inset/padding shown in green in the example screen shot to get the left sides of the text boxes to line up. I've tried adding empty borders and a few other things but can't get rid of it.


According to the API, there's a constructor that allows you to specify those gaps:
The API wrote:
FlowLayout(int align, int hgap, int vgap)
Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps.


Try:



SCJD 6, OCPJP7, Baroque Potion, G+
Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 140

you forgot to add this:


SCJP, SCWCD, SCJD
David Byron
Rancher

Joined: Jan 20, 2009
Posts: 171

Dennis Grimbergen wrote:you forgot to add this:

The green margin is actually occurring on topPanel, which has a FlowLayout, not on TestingMargin, which has a GridBagLayout. So importing java.awt.Insets and then specifying

actually has no effect whatsoever on his unwanted space.
Chris Zaremba
Ranch Hand

Joined: Nov 22, 2010
Posts: 54

Thank you very much. The hgap and vgap settings do control this. It's easy when you know what you're looking for.
 
 
subject: Removing panel borders
 
Similar Threads
text box - GridBagLayout
GridbagLayout
GridBagLayout problem
GridBagConstraints Problem
? File I/O (and-or) for each loop