Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java Button Link

Posted on 1997-06-02
4
Medium Priority
?
258 Views
Last Modified: 2010-04-16
How you setup a link, in java. When you click a button it will go to a hyperlink. I'm using Visual Cafe, I have my Button setup and my link setup. I used an Interaction Wizard between the two, and what I like to do is when I click this button it will go to this URL. Is there a single line of command or two, if I click this button it will go to a URL.
0
Comment
Question by:zomega
  • 2
4 Comments
 

Author Comment

by:zomega
ID: 1221153
Since I'm here, How to you open a file and write into a file. To the server??
0
 

Author Comment

by:zomega
ID: 1221154
Edited text of question
0
 
LVL 6

Accepted Solution

by:
jpk041897 earned 300 total points
ID: 1221155
Eegarding your first question:

Use ShowDocument()

The showDocument() member is documented as follows:

void showDocument(URL url, String target)

· Requests that the browser show the specified document in a particular location either a browser window or a Netscape frame.

Options for target:
Value Document Displayed in:

· "_self" Current Frame
· "_parent" Parent Frame
· "_top" Top-most Frame
· "_blank" In a new and unnamed browser window
· "aNameofYourChoice" Creates a new browser window with the specified name. You may later display other documents in this window by using the same name as the target.

If you use "_self" as a target, the document will be loaded on the same Browser window in both IE and Netscape.

Don't be misslead by the frame part, if your document does not use frames, it will assume that the _self frame is the current page.

Regarding your second question

The simplest way tio do this is by assigning a URLConnection to a stream. A rather general eaxample would be:

String url = "http://" + getCodeBase().getHost() + "/file.dat";
DataInputStream data;
String line;

try{
try{
URL theURL = new URL("http", getCodeBase().getHost(), 80, "/rooms.dat");

data = new DataInputStream(new BufferedInputStream( theURL.openStream()));
while ((line = data.readLine()) != null) {
// whatever you want to do with the data
}
}catch( MalformedURLException e ) {
// process file not found error
}
}catch (IOException e) {
//Process I/O error
}
}

Of course, the type of stream you use will depend on exactly what it is that you want to do.

Writing to the URL is accomplished in the same fashion, just use writeLine instead of readLine.

For somewhat extensive coverage on the different types of streams you can use (and their methods) see:

http://www.mcp.com/que/et/se_java2e/18javafi.htm 


Just remember to asosiate a URLConection to whatever Stream type you decide to use.
0
 

Expert Comment

by:bill.m
ID: 1221156
If you don't care about Internet Explorer support, then
JavaScript supports that by just assigning a value to
the "location" variable (window.location).

But the aspect of LiveConnect that you'd have to use
(involving JSObject) is only supported under Netscape Nav 3.0.
(LiveConnect is the protocol for communicating between
Java and JavaScript.

I recall encountering something in Java (w/o JS) to
do it, but I can't remember at the moment.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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:
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.
Suggested Courses

971 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