Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setResizable & BorderLayout  RSS feed

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got an awt frame which is set to BorderLayout(0,0) and I've got a panel in the "North" and "Center".
When I call setResizable(false) on this frame, I get a 1 pixel margin on the right side.
Why is this happening?
I'm using JDK 1.3.1 on Win.
Thanks,
Drew
 
Ola gharably
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your using borderlayout this means you are extending JFrame, try this code:
BorderLayout layout = new BorderLayout(0,0);
Container c = getContentPane();
c.setLayout(layout);
JPanel p1,p2;
p1 = new JPanel();
p2 = new JPanel();
Now whatever you like to add to p1 and p2 add them and after that write:
c.add(p1, BorderLayout.NORTH);
c.add(p2, BorderLayout.CENTER);
But make sure first you add all your components like buttons, comboboxes, whatever on the right Layout, but take care that whatever component you want on the North or Center borderlayout you SHOULD put them on panel1 ( p1 ) and panel2 ( p2).
I don't know what you have done , it may be what i already said you didn't explain exactly what you did hope that would help .. good luck
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No he could still be using AWT... AWT still uses BorderLayout.

Though that still doesn't explain why it happens... I don't see this on JDK 1.4.1_01 on my Win2K box... but I may just not be looking closely enough. How did you detect the 1 pixel difference? Through code (one of the sizing methods), or visual inspection?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!