Forums Register Login

Clickable picture to another URL for an applet?

+Pie Number of slices to send: Send
Okay so I have a few questions about an applet I'm making.

First is is there a way to click on a picture in the applet which would bring us to another URL on the site? Basically this applet is going to give recommendations on the product, and I Think it would be a cool idea to click on the picture of another link that will be able to send me to the URL? Also I remember when I took a basic HTML class that when we made the applet it was using the class file? Can Jar's be used as well?


Thanks,

~JO
+Pie Number of slices to send: Send
Yes, you can use jar files in applet to bundle all the class files. That's what the archive attribute in the applet tag is for: http://docs.oracle.com/javase/tutorial/deployment/applet/html.html

You can certainly interpret any UI action (such as a click on an image) as a trigger to take the user to some other web site. That's what the java.applet.AppletContext#showDocument(java.net.URL) method is for.
+Pie Number of slices to send: Send
Thanks! I notice they say with or without JNLP. How would I make a JNLP file? What are the advantages? I notice there is a log console that pops up whenever I run a .JNLP but is that all?

Thanks!



Now I could just create a new panel within the frame that could contain this URL according to this?

showDocument
void showDocument(URL url,
String target)
Requests that the browser or applet viewer show the Web page indicated by the url argument. The target argument indicates in which HTML frame the document is to be displayed. The target argument is interpreted as follows:
Target Argument Description
"_self" Show in the window and frame that contain the applet.
"_parent" Show in the applet's parent frame. If the applet's frame has no parent frame, acts the same as "_self".
"_top" Show in the top-level frame of the applet's window. If the applet's frame is the top-level frame, acts the same as "_self".
"_blank" Show in a new, unnamed top-level window.
name Show in the frame or window named name. If a target named name does not already exist, a new top-level window with the specified name is created, and the document is shown there.
An applet viewer or browser is free to ignore showDocument.

I think the best would be to bring us to the item while keeping us on the recommending page, I guess I could extend the applet size after clicking? Is that possible?
+Pie Number of slices to send: Send
 

Now I could just create a new panel within the frame that could contain this URL according to this?


The web page would be displayed in the instead of the one containing the applet, or in a new browser window (depending on the value of the "target" parameter"). It's not displayed as part of the applet.

I think the best would be to bring us to the item while keeping us on the recommending page, I guess I could extend the applet size after clicking? Is that possible?


It's not possible to enlarge the applet, but you can open a new browser window via a "_blank" target parameter.
+Pie Number of slices to send: Send
 

Ulf Dittmer wrote:

Now I could just create a new panel within the frame that could contain this URL according to this?


The web page would be displayed in the instead of the one containing the applet, or in a new browser window (depending on the value of the "target" parameter"). It's not displayed as part of the applet.

I think the best would be to bring us to the item while keeping us on the recommending page, I guess I could extend the applet size after clicking? Is that possible?


It's not possible to enlarge the applet, but you can open a new browser window via a "_blank" target parameter.




So basically when I activate it there is no way to have the web page open with the App?
+Pie Number of slices to send: Send
I don't understand what you mean by "have the web page open with the App".
+Pie Number of slices to send: Send
Applets have many restrictions. At this point I'd question the need for an applet in the first place. Are there other things you need to do that only an applet can provide? Or are you just trying to avoid HTML and JavaScript?
+Pie Number of slices to send: Send
 

Bear Bibeault wrote:Applets have many restrictions. At this point I'd question the need for an applet in the first place. Are there other things you need to do that only an applet can provide? Or are you just trying to avoid HTML and JavaScript?



I'm doing a job for someone and this is what they wanted, HTML/Javascript would probably be better in this case since it's an easy task; however I think this is also a perfect opportunity to learn more about applets and such since I will need to make one for a future project once it's completed.


What I meant is, is there a way to open the link while still having the App open in the same window? A new window is probably going to be the easiest if not though.
+Pie Number of slices to send: Send
The web page either opens in the same window -in which case the page containing the applet is displaced- or in a new window. There are no other alternatives.
+Pie Number of slices to send: Send
 

Ulf Dittmer wrote:The web page either opens in the same window -in which case the page containing the applet is displaced- or in a new window. There are no other alternatives.



Gotcha thanks .

I did however see in JavaFX's Ensemble that it had a section that it would open up a page within the frame designated for each project, but I'm assuming that is different?


http://www.oracle.com/technetwork/java/javafx/samples/index.html
+Pie Number of slices to send: Send
You can embed a Swing web viewing component in your applet and load the web page into that. But the most common one (Swing's own JEditorPane) is horribly limited in the HTML it can display -HTML 3.2, no CSS, no JavaScript- which usually means that any recent web page will not display correctly.

But why would you use such an approach if you have a proper browser available that can display anything you throw at it? You shouldn't use applets for things they aren't meant for. (And, in fact, these days you should hardly use applets at all.)
+Pie Number of slices to send: Send
Ulf is correct; displaying HTML in a frame in an applet in an HTML page is madness.

I ask again: why is an applet needed? Using applets in the modern Web at this point is sort of like trying to use a vacuum tube in a flat-screen TV.
+Pie Number of slices to send: Send
HAah okay, was just curious how that was done, thanks. I will just open another window open. Also Bear like I said that's what he wants, I could do it in JS if needed. Like I said before I have another application that is going to be very complex that cannot be done in JS, so an applet will be needed for that. I rather learn what's needed now for that, even if Applets are a relatively dead path. Unless of course there is a better way to display my JAVA code in a webpage?
+Pie Number of slices to send: Send
No
We begin by testing your absorbancy by exposing you to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1203 times.
Similar Threads
Help on Applet idea
help w/ game involving threads and drawImage
icons facing in wrong direction
Saving a picture of an applet
the position of component in applet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:51:53.