File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Removing panel borders

 
Chris Zaremba
Ranch Hand
Posts: 54
Eclipse IDE Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
swing.jpg
Example Screen Shot
[Thumbnail for swing.jpg]
 
David Byron
Rancher
Posts: 172
Clojure Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


 
Dennis Grimbergen
Ranch Hand
Posts: 159
IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you forgot to add this:
 
David Byron
Rancher
Posts: 172
Clojure Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
Eclipse IDE Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic