This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff 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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP 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: 172

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:



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

Joined: Nov 04, 2009
Posts: 146

you forgot to add this:


SCJP, SCWCD, SCJD
David Byron
Rancher

Joined: Jan 20, 2009
Posts: 172

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Removing panel borders