Solved

AppletContext sample

Posted on 2000-02-23
6
757 Views
Last Modified: 2006-11-17
Anyone out there have an example of an applet which uses the AppletContext stuff to load a URL into a new browser window? I've been banging my head against this to no avail and would like to see some source from someone who has either done it or has one of those phone-book size Java manuals with a handy example to plagiarize.

100 points for a quick sample.


TIA

Marty
0
Comment
Question by:mravell
6 Comments
 
LVL 7

Expert Comment

by:Ravindra76
ID: 2551652
getAppletContext().showDocument(url, "XXX")

Here xxx is the target frame.
Since there is no frame at all, it will open a new window

url is the url U have to give in the format

http://yourserver:serverport/file
0
 

Author Comment

by:mravell
ID: 2552173
Hi Ravindra,

Can you post some actual applet code? I got this much from the Java Doc already.

Do I have to implement the AppletContext interface or something?

Some actual working source is what I'm really after. Please assume ignorance on my part!



Regards
M
0
 
LVL 8

Expert Comment

by:diakov
ID: 2552293
If your program is an applet, it already has a valid AppletContext and ravindra76's example is actually a piece of code.

Cheers,
  Nik
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 2

Accepted Solution

by:
muraliram earned 100 total points
ID: 2553461
Dear friend,


if(e.getSource()==b1)
{
try{
URL url=new URL("http://www.yoursite.com/your.html");
}
catch(MalformedURLException e){}
getAppletContext().showDocument(url,"_blank");
}
will work properly
Don't forget to modify the code as per your need.
0
 
LVL 1

Expert Comment

by:vishone
ID: 2560711

 Hi mravell, Didn't you try the piece of code given by Ravindra?





0
 
LVL 7

Expert Comment

by:Ravindra76
ID: 2560875

Run this code as

Jump.html :-

Note: put this jump.html and Jump.class in ur webserver document root.

for me it is http://localhost/jump.html

<HTML><HEAD></HEAD><BODY>
 <APPLET CODE="Jump.class"
         HEIGHT=100
         WIDTH=300>
 </APPLET></BODY></HTML>

Jump.java


import java.awt.*;
import java.applet.*;
import java.net.*;

public class Jump extends Applet {
      Button btnJump;

      public void init() {

            btnJump = new Button("JUMP To");
            add(btnJump);
      }
      public boolean action(Event e,Object o) {

            if ( e.target.equals(btnJump)) {
                  try {
                  getAppletContext().showDocument(new URL("http://www.yahoo.com"),"xxx");
                  }
                  catch ( Exception ee) {
                        System.out.println("Malformed URL");
                  }
            }
            return false;

      }
}
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question