Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown


Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the following program...
import java.awt.*;
public class MyFrame
public static void main(String[] args)
Frame fr = new Frame();
Panel p = new Panel();
Button b1 = new Button("North");
Button b2 = new Button("South");
fr.add("North", p);
fr.add("South", b2);
on resizing width of North will not change.why???
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The buttons are added to the panel using FlowLayout (the default layout for Panels). FlowLayout honors the preferred size of the component, and will not resize the component even when its container changes size. The panel is added to the Frame using BorderLayout. On resizing the Frame, the panel might get resized, but the button in the panel is not affected. Infact, that is the primay advantage of adding components to a Panel, as opposed to adding it directly to the Frame.
Hope I could clear your doubt.
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic