Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

use of null with setLayout statement

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have read that if we give setLayout(null) the default layout
is disabled.then we have to use setBounds method to layout
the components.but on trying with setbounds no component was visible in the applet.
kindly help???
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to Swing / JFC/ AWT, as it has nothing to do with certification. If you post more info there perhaps we can help. In particular, if you post the code which you're currently using (after removing any lengthy parts which are irrelevant to the problem) then hopefully we can see why it's not working.
 
Sathish Babu Adluru Subas
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it will work perfectly if use the foll. way
...
JPanel p = new JPanel();
JLabel aa = new JLabel("Hello");
p.setLayout(null);
p.add(aa);
aa.setBounds(100,100,100,20);
...
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sathish Babu Adluru Subas:
it will work perfectly if use the foll. way

the way u told i understood but i am not using swing.
i am just creating a textfield and textarea
pl. tell the use there.
thanks
srijan

...
 
Sathish Babu Adluru Subas
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the same order should be followed in both AWT/Swing.like if u use AWT the code must be...
...
Panel p = new Panel();
TextArea aa = new TextArea(10);
p.setLayout(null);
p.add(aa);
aa.setBounds(100,100,100,20);
...
got it,huh?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

thanks for being involved. the problem was with ordering of statements.
i will be bothering u in future too.......
srijan
 
paul wheaton
Trailboss
Posts: 22072
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about the rest of you, but it seems the 1.1 layout managers have problems. In applets, I use the null layout stuff described here all the time since it is more reliable.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!