• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Clickable picture to another URL for an applet?

 
Ranch Hand
Posts: 356
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jay Orsaw
Ranch Hand
Posts: 356
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Jay Orsaw
Ranch Hand
Posts: 356
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand what you mean by "have the web page open with the App".
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Jay Orsaw
Ranch Hand
Posts: 356
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jay Orsaw
Ranch Hand
Posts: 356
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.)
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jay Orsaw
Ranch Hand
Posts: 356
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic