Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

linking between applet pages

 
nasha shaharan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • 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!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
no..not a webpage. it's an applet also.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Andrew Thompson
Ranch Hand
Posts: 77
5
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CardLayout is definitely the way to go.
 
nasha shaharan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh CardLayout..can cardlayout contain applets in various sizes?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
okay thanks! i'll go and learn more about cardlayout.
 
Ulf Dittmer
Rancher
Posts: 42968
73
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic