• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Saloon Keeper
Posts: 7590
177
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your valuable suggestions.
 
nils roy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Water! People swim in water! Even tiny ads swim in water:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic