• Post Reply Bookmark Topic Watch Topic
  • New Topic

ref to setlayout(null)  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

dear sir,
the following code is creating trouble
TextField name;
TextArea pass;
public void init()
{

setLayout(null);
name.setBounds(10,10,280,25);
pass.setBounds(10,50,280,150);
append.setBounds(10,210,75,25);
clear.setBounds(100,210,75,25);
name=new TextField();
pass=new TextArea();
add(name);
add(pass);
add(clear);
add(append); please guide(no output on the applet)
srijan.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
give
allocate memory to textfield and then use setBounds().
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that you're not even executing the init method, since if you were you'd get a NullPointerException for each setBounds that you execute before the component is initialized. That is,
<code><pre> name.setBounds(10,10,280,25);</pre></code>
can't be before
<code><pre> name=new TextField();</pre></code>
because name is null at first. If this didn't cause an error, you have a more serious problem. I'm assuming your code at least compiles, although there is no declaration for pass or append in the code you show here. You need to be more careful to give us correct code if you want to find the problem.
A guess - look at the HTML you use to display the applet. Compare it with an example from whatever basic Java book you have. Are you displaying an applet at all? Try including the line
<code><pre> setBackground(Color.red);</pre></code>
in your init method - that my make it clearer if the applet is being displayed at all in the big blank spot on your screen.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi all,
thanks for replies.
the problem was with the order as u all pointed out.
but surprising thing is the program gets compiled and nothing
is dispayed on the applet.pl explain that
srijan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!