This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A BorderLayout BUG ??

Pravin Panicker
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I'd posted this question before but nobody tried to compile and run this code and jumped to conclusions.
O.K I'm adding 3 buttons to CENTER of a BorderLayout.
I've set Bounds for 2 buttons.Added them first and then a third button to the center.
Ideally i should get only the 3rd button occupying the whole of the frame.BorderLayout does not honour preferred size of the component in the center.
But presto! I'm getting three buttons .The first two exactly as per bounds set over the third.
Please run this small code and see for yourself.
Kindly enlighten me on this one!
import java.awt.*;
import java.awt.event.*;
class Border extends Frame
Button b1 = new Button("Button#1");
Button b2 = new Button("Button#2");
Button b3 = new Button("Button#3");
addWindowListener(new ExitWindow());
add(b1,BorderLayout.CENTER );// try
add(b3,BorderLayout.CENTER);// different
add(b2,BorderLayout.CENTER);// sequences
public static void main(String[] args)
Border b = new Border();
class ExitWindow extends WindowAdapter
public void windowClosing(WindowEvent e)
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic