Re: string to URL and URL to string
On Sep 1, 12:54 am, Andrew Thompson <andrewtho...@gmail.com> wrote:
On Sep 1, 2:05 pm, bH <bherbs...@hotmail.com> wrote:
...
(and here's me, 'doing a Roedy' by jumping back in
when I something else interesting.*)
//Eventually I hope to include this statement from the
//original applet
//getAppletContext().showDocument(theURL);
Is your project intended for 1.6+? If so, I
would strongly recommend using Desktop.browse(URI)
instead of the normal applet method.
In a sandboxed applet, it will fall back to using
showDocument(URL), but it will also work in a desktop
application (or a webstart launched app.).
Here is an example of a LinkLabel using Desktop
<http://sdnshare.sun.com/view.jsp?id=2316>
* That statement was not intended to be offensive
to anyone. If it is, please explain why.
--
Andrew Thompsonhttp://pscode.org/
Hi Andrew and Roedy,
I looked at the "LinkedLabel.java" and I presently use
jdk1.5.0_12. So the import java.awt.Desktop; is a problem.
And I am reluctant to get the Java 1.6+ for the reason I did
download it once only to regret that I did and had to step
back to the jdk1.5.0_12
Now, regarding "Hybrid.java" I have the program and
attempted to run it. As a standalone it goes nowhere
because it has no "main" and what is "fireup", never
have seen that before? So I have to ask"what goes where?"
A few hints, please.
I think that it is a wrapper for an applet. I need an
explanatiion, please or a samle of what it looks like when
it is written in/outside of an applet. I have a sample
applet here below.
TIA,
bH
Here is my sample applet:
import java.applet.*;
import java.awt.*;
public class test1 extends Applet {
Image image;
public void init() {
image = getImage(getClass().getResource
("images/bird.gif"));
}
public void paint(Graphics g) {
g.drawImage(image,0,0,this);
g.setColor(Color.RED);
g.drawString("test1",20,20);
}
}
Roedy's Hybrid.java is below:
import java.applet.Applet;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* Converts a Applet into an Application.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0, 2006-03-07 Created with IntelliJ IDEA.
*/
public final class Hybrid
{
// -------------------------- PUBLIC STATIC METHODS
--------------------------
/**
* Fire up the Applet as an application
*
* @param title title for frame usually TITLE_STRING+ "
" +
VERSION_STRING
* @param applicationWidth width of frame, usually APPLET_WIDTH
* @param applicationHeight height of frame body, usually
APPLET_HEIGHT
*/
public static void fireup( final Applet applet,
final String title,
final int applicationWidth,
final int applicationHeight )
{
final Frame frame = new Frame( title );
// allow some extra room for the frame title bar.
frame.setSize( applicationWidth + 16, applicationHeight + 36 );
frame.addWindowListener( new WindowAdapter()
{
/**
* Handle request to shutdown.
*
* @param e event giving details of closing.
*/
public void windowClosing( WindowEvent e )
{
applet.stop();
applet.destroy();
System.exit( 0 );
}// end WindowClosing
}// end anonymous class
);// end addWindowListener line
frame.add( applet );
applet.init();
frame.validate();
frame.setVisible( true );
applet.start();
}
}