Solved

Java Button Link

Posted on 1997-06-02
4
193 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 150 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

708 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

18 Experts available now in Live!

Get 1:1 Help Now