Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

applet

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class vi extends java.applet.Applet{
public void init(){}
public void start()
{
Button b = new Button("start");
add(b);
add(b);
add(b);
}
}
Why is button added only once??
Thanx in advance
 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only one button appears because you've created only one button and added it 3 times.
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
donno Leena , wot xactly goes inside , but i also observed da same behaviour
One more thing related to this is , even if u add da same component to many diff containers , even in this case only to da last container to which dis component is being added ,component actually get added .
I somehow don had time to xplore more into dis , so i just remember these 2 points
if someone can xplain wid reason , then dat ll be gr8 help

------------------
Gagan (/^_^\)
 
Ranch Hand
Posts: 171
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are no questions about Applets on the SCJP 2 exam.
Good luck,
Geoffrey
------------------
Sun Certified Programmer for the Java 2 Platform
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applet is a container just like Panel, Frame, Window & etc. You need to know the basics for sure!

------------------
Percy Densmore
-SCJP2 Die Hard Student
[This message has been edited by Percy Densmore (edited September 17, 2001).]
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Percy
We DO knw the basics , da class hierarchy !
N dats y i linked the Lenna's applet prob wid my foll statement
" even if u add da same component to many diff containers , even in this case only to da last container to which dis component is being added ,component actually get added "
So can u , wid all ur basics in place , tell da reason for above stated behaviour?


------------------
Gagan (/^_^\)
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have created only one button and adding it 3 times. Of course only one button will appear.

------------------
Asma Zafar,
Sun Certified Programmer for Java2 Platform
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic