How Can Java Applet Display HTML?

I believe there is a JavaScript function: ‘ShowDocument(URL,targetFrame)’ Is there a way to replicate this in Java?

I realize that in the future the solution may materialize when a relationship between Java and JavaScript develops. I presume Java would then have the ability to access JavaScript variables and functions.

Here’s the standard technique for displaying a Web page and reading itsHTML:

import java.awt.*;import java.applet.*;import*;import*;public class Browse extends Applet {   private TextField path;   // private ErrorFrame f = new ErrorFrame();   URL source;   TextArea display = new TextArea(8, 40); // 8 lines x 40 chars   String next;   AppletContext context;   public void init() {      setBackground(;      add(path = new TextField(“”, 30));      Panel p = new Panel();      p.add(new Button(“SHOW HTML”));      p.add(new Button(“HIDE HTML”));      add(p);      add(display);      context = getAppletContext();   }   public boolean action(Event e, Object arg) {            if ( == path) {         try {            String file = path.getText();            source = new URL(getCodeBase(), file);            context.showDocument(source, “_self”);         }         catch(MalformedURLException mue) {         //   f.error(mue);         }         return true;      }      else if (arg.equals(“SHOW HTML”)) {         try {            DataInputStream in = new DataInputStream(source.openStream());            // erase display            display.setText(“”);            while(null != (next = in.readLine()))               display.appendText(next + “/n”);            in.close();            return true;         }         catch(IOException ioe) {           // f.error(ioe);         }      }      else if (arg.equals(“HIDE HTML”)) {         display.setText(“”);         return true;      }      return false;   }} 

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS