Solved

AppletContext sample

Posted on 2000-02-23
6
756 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now