Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display of HTML pages from an Applet.

 
Cecilia Jane
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a problem, can anybody help me solve it?
I have created a program in which I have a GUI for username,password and Login. I am able to view it in the appletviewer.
I have given a validation to check the name and password. I want to interlink java web pages which a .html file found in my 'C' drive that is, if I click the "Login" button, it should take me
to a different page like a hyper link.
I have created a html file on my hard disk, which I want be displayed by clicking a button.

Thanks in advance.
Cecilia.
 
Cecilia Jane
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am new to javaranch. I posted a question a couple of days ago. I haven't received any reply as yet. Is my question not clear or is the question a tough one?
Kindly reply.
Cecilia.
 
java puneri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
To show a HTML page from applet we use
getAppletContext().showDocument(url,target);
url = location path of html page to be shown!
target = _self = same window
_blank = new window
refer jdk help regarding showDocument!
May you try this which eventhandling of button !
Careful while creating URL object. It should be created using
getCodeBase();

Cheers
PuneGuy
 
Deepak Yadav
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dear
I am sending you the code for your problem.Hope it works...
Thanks Deepak
Code......

import java.awt.*;
import java.applet.* ;
import java.net.*;
/*<applet code = "ShowHtml" height=300 width=300> </applet>*/
public class ShowHtml extends Applet
{
public void start()
{
/* Create an Applet Context */
AppletContext ac = getAppletContext();
/*Create a url which points to your file in the hard disc*/
String url ="file:/c:/dees/User.java";
try
{

ac.showDocument(new URL(url));

}
catch(MalformedURLException e)
{
System.err.println("Url Not Correct");
}
}
}


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic