*
The moose likes Applets and the fly likes How to get put a JPanel into a webpage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Reply locked New topic
Author

How to get put a JPanel into a webpage

Andrew Cho
Ranch Hand

Joined: Jun 29, 2011
Posts: 50
hey all,

I have a java program that extends JPanel, and i've tried putting it into a JApplet and into HTML, an Applet into HTML, and a JApplet into HTML using frontpage and nothing seems to work. could anyone tell me how to or give me code for putting a JPanel into a webpage?

Thanks a bunch,
Andrew
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

To put Java code into a web page, you use an applet. In the 21st century a JApplet is the preferred method. (Not JNLP, so I will move the post to the forum about applets.) But I'm surprised you ask for code; obviously you have tried some things already. So the suggestion that you should throw all of those things away completely, disregarding all of the error messages you surely must have had, doesn't make much sense.

So let's start with what you have so far. Presumably you've already tracked down applet tutorials on the web and are working from them?
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

I'll give you a hint : Extend JApplet, not JPanel...This is the easiest solution...

cc11rocks


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Andrew Cho
Ranch Hand

Joined: Jun 29, 2011
Posts: 50
Thanks guys,

I actually figured out that its not a problem with applets or panels. I have been doing that right the whole time. The problem is that in my program, i retrieve data from a SQL database. When I run the program just through a JFrame, it works fine, but when I try to run it through a JApplet, it doesn't work.

I tried tests as well, having basically the exact same code in a normal class file that uses main, and in a JApplet. In the non-applet program, getting data from the database works flawlessly, but in the applet, it cant get the connection.

Should I continue to ask for answers in this post, or should i start a new one? (I'm kind of new to the ranch)

thanks,
Andrew
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

New post here: http://www.coderanch.com/t/545127/Applets/java/JApplet-not-connecting-SQL-database.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to get put a JPanel into a webpage
 
Similar Threads
How to launch a webpage from a browser from an application and an applet
Adding Jpanel to Japplet
webpage error
JApplet and JPanel Stretching
JPanel - Screen Size