Solved

Open a web page

Posted on 2000-04-12
8
254 Views
Last Modified: 2012-06-27
Hi,
How do I open a web page, using a JLabel or whatever.
0
Comment
Question by:s_lavie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 2708866
>> open a web page

how to implement hyperlink or ... ?
0
 
LVL 2

Expert Comment

by:anand29
ID: 2710052
what you are writing applet or application.
0
 
LVL 1

Accepted Solution

by:
samers earned 25 total points
ID: 2710698
I don't think label has to do with hyberlink
if u r using Applet here's how u can go to a new URL or HTML file:

AppletContext ac = this.getAppletContext();
ac.showDocument(URL, "where to show it");

this :  is the reference to the Applet that currently running.

showDocument() has 2 parameter,

1- the URL u want to open.
2- where u want to open it
   ex:  "_Blanck" means in a new window.
        "_self" in the current window.




0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:s_lavie
ID: 2710747
Yes, implement a hyperlink.
I'm writing both an applet and an application.

0
 
LVL 2

Expert Comment

by:anand29
ID: 2712987
U can use showDocument of AppletContext in the case of applet.

But in the case of aplication where you are trying to open a URL??

And also to give the hyperlink effect i.e. Hand Curser etc. You can use Mouse events with changed curser.And you can change the curser by setCurser method.
hope i understood your question correctly.
0
 

Expert Comment

by:kbeier
ID: 2718650
Hi s lavie,

If you want to launch a URL from an application in the system's default browser, try using the BrowserLauncher class, which you can use freely and download freely from:

http://www.stanford.edu/~ejalbert/software/BrowserLauncher/

BrowserLauncher is a class that provides one static method, openURL(String url), which opens the default web browser for the current user of the system to the given URL.  You can look at the sourcecode for BrowserLauncher too if you want to use it :-), and it saves you from having to work out how to launch default browsers on various platforms using Rintime.exec().

As for launching the URL with a "hyperlink" in your application, why not extend JLabel so that it looks like a hyperlink and acts like a hyperlink.  The class's constructor could take a string, an "unvisited" link color, a "visited" link color, and a URL string (you could use a mutator method to reset the colors of the JLabel when dealing with mouse events, as well as changing the cursor as suggested by anand29).
0
 

Expert Comment

by:Agla
ID: 2725994
s_lavie,

u can study the tutorial on how to use the JTree class(Swing). It involves opening a webpage(html)..

Agla
0
 

Expert Comment

by:Agla
ID: 2725996
s_lavie,

u can study the tutorial on how to use the JTree class(Swing). It involves opening a webpage(html)..

Agla
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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:
Suggested Courses

738 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