• 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

linking between applet pages

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,
i have an applet with many buttons. i wanna be able to press a button and directs it to another page.
it is kinda like clicking a link in a webpage. i am not sure how to do this. can you please tell me how?

this is what i did in the button's actionPerformed:



thanks in advance!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming that by "page" you mean another web page, that's what the Applet class's showDocument method does.
 
nasha shaharan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no..not a webpage. it's an applet also.
 
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
Is the applet on the same web page? Then it should be visible already. If It's on a different web page, then showDocument is the way to go.
 
nasha shaharan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
same web page..how can it be visible? i need to click a button, say: View Profile. then it will take me to another applet called Profile.
just like a website. can you tell me more?
 
Ranch Hand
Posts: 77
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect the best approach to this is to convert Hello class to a JPanel and add it and the other GUI elements to a CardLayout. Here is a short example.

 
nasha shaharan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the example, Andrew! i will look into it and study more about cardlayout.
i'm wondering why i can't link to other applet in the same page, when my login page can do that whenever i hit the login button. when i log in successfully, the page changes to the content page.

this is my login page code:



and this is the code for the other applet when 'enter' button is pressed:


please help because i'm confused...



 
Andrew Thompson
Ranch Hand
Posts: 77
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

nasha shaharan wrote:..i'm wondering why i can't link to other applet in the same page, ...



Probably because that makes about as much sense as "Why can't I banana card hat manifesto?".

Or to put that another way, I don't have the 1st idea about what your 'requirement' is supposed to mean. Links are either to other pages, other resources like images or ZIP archives, or anchors in the same page. There is no such thing as a 'link to an applet'.

Can you give us the URL of a web page that behaves as your applets are supposed to work?
 
nasha shaharan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It's like a website with a login page. after login, press the enter button and the applet called ButtonView takes the place of the login applet.
then in the ButtonView applet will have 3 buttons which do different things and they will open other applets as well.

the login to buttonView successfully linked, but the buttons in buttonView cannot open their respective applets.

just take a look at my code...

i don't want to use showDocuments because it will use different web pages. i only want one webpage, but the applets in one place, responding to whatever button being pressed.
or is this not possible? an applet contents cannot be changed? but in login page it was successful...maybe the panel from buttonView that was called?

sorry because i don't know a lot about applets..thanks for your help
 
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
CardLayout is definitely the way to go.
 
nasha shaharan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh CardLayout..can cardlayout contain applets in various sizes?
 
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
Being a layout, CardLayout does not contain applets but Panels or JPanels. You'll have to rewrite your code so that it is a single applet. And no, all panels in a CardLayout are of the same size. But that shouldn't be a problem.
 
nasha shaharan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for explaining..so, the panels will be in the same size of the applet? the panels will be on top of each other then?
 
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
That would be a conceptualisation. The important point is that a single panel will be visible at any given time.
 
nasha shaharan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
okay thanks! i'll go and learn more about cardlayout.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://download.oracle.com/javase/tutorial/uiswing/layout/card.html
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic