Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2005

Tip: Looking for answers? Try searching our database.

How to include JFrame program in HTML document.

Thread view: 
Mahesh Reddy - 12 Feb 2005 02:45 GMT
Hi Java Professionals,

Could anyone tell me how to include a JFrame program in an HTML document. I
know that an applet can be added to an HTML document by using <APPLET
CODE="xyz.class"> tag, but I don't have an idea of how to include a JFrame
program in HTML document.
Please help me.
Thanks,
Mahesh
IchBin - 12 Feb 2005 03:36 GMT
> Hi Java Professionals,
>
[quoted text clipped - 5 lines]
> Thanks,
> Mahesh

You could add code to your Java program to run as an JApplet or
Application.

Signature

Thanks in Advance...
IchBin
__________________________________________________________________________

'The meeting of two personalities is like the contact of two chemical
substances:
 if there is any reaction, both are transformed.'
-  Carl Gustav Jung,  (1875-1961),  psychiatrist and psychologist

Mahesh Reddy - 12 Feb 2005 03:56 GMT
Thanks for ur reply.
But,I already extend JFrame. So, I wouldn't be able to extend JApplet.
I could do the same application with JApplet too(for including it in HTML
document), but the window wouldn't look as good as doing with JFrame.
So, could u plz suggest any means of including a JFrame program in HTML
document.
Andrew Thompson - 12 Feb 2005 15:05 GMT
> So, could u plz suggest any means of including a JFrame program in HTML
> document.

[j]applet.[getContentPane.]add( jframe.getContentPane() );

That will include the content of the application UI in an applet.

There might be problems with menubars, as well as a lot of the
things applications do (things like System.exit(0), new File("blah") ).

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

IchBin - 12 Feb 2005 04:06 GMT
>> Hi Java Professionals,
>>
[quoted text clipped - 10 lines]
> You could add code to your Java program to run as an JApplet or
> Application.

As an applet it will be able to start because of the init()
and as a Application because of the main.

Extend you program Class with Applet:

Add a Applet init() method to be used as an applet or be called from
your main method to bill your GUI as an application.

In in the main method  define your JFrame.

         Frame frame = new Frame( );
         applet.init();
         frame.add(applet);
         frame.validate();
         frame.setVisible(true);
         applet.start();
         frame.addWindowListener (
         new WindowAdapter()
            {
            public void windowClosing(WindowEvent e)
               {
               applet.stop();
               applet.destroy();
               System.exit(0);
               }
            } //
         ); //
Signature


Thanks in Advance...
IchBin
__________________________________________________________________________

'The meeting of two personalities is like the contact of two chemical
substances:
 if there is any reaction, both are transformed.'
-  Carl Gustav Jung,  (1875-1961),  psychiatrist and psychologist



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.