CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Java and JSP (http://www.codingforums.com/forumdisplay.php?f=54)
-   -   Trying to display in a jframe an html file from my computer (http://www.codingforums.com/showthread.php?t=270749)

tornskyz 08-17-2012 06:39 PM

Trying to display in a jframe an html file from my computer
 
Hi, i've been working on this for months and i've tried so many different things. can anyone help me with this?

Fou-Lu 08-17-2012 07:08 PM

You can't. HTML needs an object embedded into it, but JFrame isn't interpretable. Use an applet instead.

tornskyz 08-17-2012 07:17 PM

Care to explain?

Fou-Lu 08-17-2012 07:30 PM

JFrame's cannot be rendered through HTML. You need to embed an object of type applet instead.
Applet can handle a JFrame, so you just need to wrap your JFrame in an applet class instead. See this tutorial for more applet information: http://docs.oracle.com/javase/tutori...let/index.html

tornskyz 08-17-2012 07:34 PM

okay so another question:

what if i create an html file and i want to call it using:


File file = new File("insert file path");

would that work, or is the applet the only way to do it?

Fou-Lu 08-18-2012 04:36 PM

I don't understand what you are looking to do here. If you open a file with an IO handling method, you retrieve it as text. It'll only do something if you parse it and handle it in some fashion.
If you want to run it over http embeded in an html file, use an applet. If you want to handle it as server code over http, use a servlet or JSP. If you want to handle a desktop application capable of communicating over http, then look at writing a JFrame and establish http connections.


All times are GMT +1. The time now is 05:40 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.