How Lauch a web page html from jframe

I have one app;c:\app\JAVA.jarAnd inside of this folder has a file called help.htmc:\app\help.htmHow can I lauch this page (help.htm) from JFrame (.. maybe an actionPerfomed)?I just wanna lauch. The page will be showed on the browser of client.
[286 byte] By [dreampeppers99a] at [2007-10-3 8:26:19]
# 1

1. Create a JButton.

2. Add an ActionListener to the JButton

3. To the listener, add this code:

JDialog dialog = new JDialog(MyFrame.this, true);

JEditorPane editorPane = new JEditorPane();

editorPane.setEditable(false);

java.net.URL helpURL = MyFrame.class.getResource(

"/my_dir/help.html");

if (helpURL != null)

{

try

{

editorPane.setPage(helpURL);

}

catch (IOException e)

{

System.err.println("Attempted to read a bad URL: " + helpURL);

}

}

dialog.getContentPane().add(editorPane);

dialog.setSize(400, 350);

dialog.setLocationRelativeTo(MyFrame.this);

dialog.setVisible(true);

Note: there are a couple of things you can do to make the code a little nicer but I'll leave that as an exercise for you.

filestreama at 2007-7-15 3:32:41 > top of Java-index,Java Essentials,New To Java...
# 2
thanks a lot.Realy you help me !!!!
dreampeppers99a at 2007-7-15 3:32:41 > top of Java-index,Java Essentials,New To Java...
# 3
JDialog dialog = new JDialog(MyFrame.this, true);What does myFrame.this mean? I looked in the JFrame class, and there is no 'this' field listed. Shouldn't that just be MyFrame?
7studa at 2007-7-15 3:32:41 > top of Java-index,Java Essentials,New To Java...
# 4

> JDialog dialog = new JDialog(MyFrame.this,

> true);

> What does myFrame.this mean? I looked in the JFrame

> class, and there is no 'this' field listed.

> Shouldn't that just be MyFrame?

Why don't you try it out?

import javax.swing.*;

public class MyFrame extends JFrame implements ActionListener

{

//code in here

myButton.setActionCommand("cmd");

myButton..addActionListener(this);

//more code

public void actionPerformed(ActionEvent ae)

{

if( "cmd".equals(ae.getActionCommand()) )

{

JDialog ...

}

...

filestreama at 2007-7-15 3:32:41 > top of Java-index,Java Essentials,New To Java...
# 5

> What does myFrame.this mean? I looked in the JFrame

> class, and there is no 'this' field listed.

> Shouldn't that just be MyFrame?

"this" always refers to the current instance of the current object, right? So instead of:

setTitle("Hello World");

you can do something like:

this.setTitle("Hello World");

(Although, why would you?)

But, let's suppose you do something like this:

public class MyClass {

private String test = "test1";

private class ThreadEntryPoint implements Runnable {

private String test = "test2";

public void run() {

System.out.println("test = " + this.test);

...

ThreadEntryPoint entryPoint = new ThreadEntryPoint();

entryPoint.run();

...

Is this going to print test1 or test2? The answer is "test2", since that's the "test" variable defined in the inner class. But, since ThreadEntryPoint was not declared as a static class, if the inner class didn't have a "test" variable, the reference to "test" could refer to the outter variable. If you remove the "test2" variable in the code above, it will still compile and print "test1".

But what if you wanted to print "test1" without removing "test2"? This is where the mechanism you are inquiring about comes in; it allows you to reference variables in outter classes which are occluded by variables in the inner class. So, you could write something like:

System.out.println("TheadEntryPoint.test = " + TheadEntryPoint.this.test);

System.out.println("MyClass.test = " + MyClass.this.test);

Jason_Waltona at 2007-7-15 3:32:41 > top of Java-index,Java Essentials,New To Java...
# 6
Jason:Thanks for that reply. I wanted the poster to see the error in compilation and then investigate; Socratic license if you will.
filestreama at 2007-7-15 3:32:41 > top of Java-index,Java Essentials,New To Java...
# 7
>This is where the mechanism you are inquiring about > comes in; it allows you to reference variables in outer > classes which are occluded by variables in the inner class.Thanks. :)
7studa at 2007-7-15 3:32:41 > top of Java-index,Java Essentials,New To Java...
# 8

> Jason:

>

> Thanks for that reply. I wanted the poster to see

> the error in compilation and then investigate;

> Socratic license if you will.

:) Sorry if I stepped on your toes. I just wasn't sure the mechanism would be "obvious" from a compiler error, especially if you're new to Java or OO programming in general.

Jason_Waltona at 2007-7-15 3:32:41 > top of Java-index,Java Essentials,New To Java...