Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet (Basic): how to run two applet in one program?

 
nils roy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after runnig below program it giving output: applet xyz is ruunig. i want to run both applet abc and xyz . how i can run both applet? [ Multithreading in applet ]

note: if i set access specifier public to abc class it giving error (abc is public, should be declared in a file named abc.java) any solution please.


 
Tim Moores
Bartender
Posts: 3137
50
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way to run two applets is to put two "applet" tags on the HTML page. Your code should *never* call the constructor, nor should it have the "main" method, since that is used by standalone apps, not applets.
 
Paul Clapham
Sheriff
Posts: 21583
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nils roy wrote:after runnig below program it giving output: applet xyz is ruunig. i want to run both applet abc and xyz . how i can run both applet? [ Multithreading in applet ]


Welcome to the Ranch, nils!

That code... it isn't even the way to run one applet. You don't run applets from the main() method from a standalone, but like Tim said you run them from an HTML page. Or at least you used to do that back when browsers still supported applets. If you're learning Java on your own and you've got to a place in your book which talks about applets, I'd suggest just skipping that chapter and going on to the next topic. But if you're enrolled in a course and you can't skip over the applets part, well I don't know. Applets are basically dead now and there's very little reason to learn about them at all any more.
 
nils roy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your valuable suggestions.
 
nils roy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul ,
yes you are right i am learning java my own.
and

Paul Clapham wrote: Applets are basically dead now and there's very little reason to learn about them at all any more.


so should i move to jframe ??? basically i want to know.. to build window base application which things/topics should i need to learn??

 
Tim Moores
Bartender
Posts: 3137
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're just starting with GUI programming, then JavaFX is the way to go. Head over to https://docs.oracle.com/javase/tutorial/index.html for an introduction.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic