Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JQuest: Panel & Window

 
yi miao
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question22:
You need a container to hold six equal-sized button in the three columns of two. This arrangement must persist when the container is resized. Which of the following will create that container?
A. Canvas c=new Canvas(new GridLayout(2,3));
B. Panel p=new Panel(new GridLayout(2,3));
C. Window w=new Window(new GridLayout(2,3));
D. Panel p=new Panel(new GridLayout(3,2));
Obviously, A & D are wrong, since Canvas is not a subclass of container, and D creates a GridLayout with 3 rows, 2 columns.
But I don't know what's the difference here between B & C? Why the correct answer is B, not C? Thanks.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because Window doesn't have a constructor that takes a LayoutManager.
------------------
Tom - SCJP --- Co-Moderator of the Programmer Certification Forums
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic