Forums Register Login

Frame for my window

+Pie Number of slices to send: Send
Hi everybody..
Well I have some problem in adding a frame to my panel..can anybody help me out in that...
I will explain u exaclty what I want..
See there is a user login... as soon as the user submits his login & password.. and if he is a valid user........after validation a frame must pop up...which will have 3 panels and cardlayout which are nothing but the different steps..what i have done is I have called all 3 functions from the init() which are nothing but 3 different panels.. all I need to do is to add the 3 panels in the frame so that whenevr the user logs in and after validation a pop up should come....which will look as if its an application....
Can i call a function from the frame...if yes how???
Can somebody please help me out in this as I have to implement it ...
Kajol
[This message has been edited by Kajol Shroff (edited March 10, 2001).]
[This message has been edited by Kajol Shroff (edited March 10, 2001).]
+Pie Number of slices to send: Send

.....problem in adding a frame to my panel..
To the best of my knowledge, Frame (among others) is a top
level container and Panel is NOT.
You can add a Panel to a Frame, but not vice-versa.
Also, I din't follow your second half of the qstn. What are
you doing after init'ing the three Panels?
To add these three panels to the Frame you could do it using
the add() method.
regds.
- satya
+Pie Number of slices to send: Send
Hi Satya,
Thanks for ur reply..
The second half says..
See what I have done is I have used three panels and CardLayout.. what i do is that each panel is a Step so when I do next a new panel opens and so i can say precvious too so that the previous panel opens..
What I need to do is I need to add these 3 panels in the Frame so as it appears like a Pop up kind of window..
I have used add() only..
So please let me know ..if its still confusing you..
Kajol
+Pie Number of slices to send: Send
HI Everybody...
I am not getting any replies ....have I asked something which is not answerable...
Kajol
+Pie Number of slices to send: Send
You said earlier that you are adding components from an init() method. Are you calling this method yourself (from a constructor) or are you expecting it to be automatically called as in an applet? You should add all components in the constructor, only use an init() method in an applet.
Hope that helps.
+Pie Number of slices to send: Send
Hi Daniel,
Yes i have called the methods in the init method ...see my program is like this ...
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class TestCard1 extends Applet implements ActionListener
{
Button btnLogin = null ;
Button btnExit = null ;
Button btnBack = null ;
Panel firstPanel = null ;
Panel secondPanel = null ;

public void init()
{
firstPanel = new Panel();
secondPanel = new Panel();
CardLayout cardLayout = new CardLayout();
this.setLayout ( cardLayout );
formFirstPanel( firstPanel );
formSecondPanel( secondPanel );
this.add( firstPanel , "Option");
this.add( secondPanel , "Login");
this.setSize(200,400);
cardLayout.show( this, "Option");
this.show(true);
}
void formFirstPanel( Panel firstPanel )
{
btnLogin = new Button ("Login");
btnExit = new Button ("Exit");
btnLogin.addActionListener( this );
btnExit.addActionListener( this );
firstPanel.add (btnLogin);
firstPanel.add (btnExit);
}

void formSecondPanel( Panel secondPanel )
{
TextField name = new TextField(25);
TextField password = new TextField(25);
btnBack = new Button("Back");
secondPanel.add (name);
secondPanel.add (password);
secondPanel.add (btnBack);
btnBack.addActionListener(this);
}

public void actionPerformed(ActionEvent e)
{
if ( e.getSource () == btnLogin )
{
CardLayout c1 = ( CardLayout ) this.getLayout();
c1.show( this , "Login" );
}
if ( e.getSource () == btnBack )
{
CardLayout c1 = ( CardLayout ) this.getLayout();
c1.show( this , "Option" );
}
if ( e.getSource () == btnExit )
{
System.exit (0);
}
}
/* public static void main( String[] str )
{
TestCard1 card = new TestCard1();
card.init();
}*/
}
Here i am calling two methds formFirstPanel( Panel firstPanel ) & formSecondPanel( Panel firstPanel )....right
So now what i want is I need to put this two metods in a frame i.e. it should appear as if a pop up window is opened
Please help me out...
Can a metod be added in a frame..
Kajol
[This message has been edited by Kajol Shroff (edited March 13, 2001).]
[This message has been edited by Kajol Shroff (edited March 13, 2001).]
+Pie Number of slices to send: Send
Kajol,
Here is what you would do to make it open in a frame. I have commented all the lines I have added or changed so you can follow what I have done.

HTH,
-Nate
+Pie Number of slices to send: Send
Hi Nathan,
Thanks a lot..
I got some hint out of it..
But tell me ... if i keep the first page in applet and may start with the second page in frame.. i mean if when i say login ( which will be i applet ) then when i press the submit button the frame should pop up ... hope u get me..
Cann u get backt to me on this..
Thnaks
Naveen
+Pie Number of slices to send: Send
Kajol,
All you would have to do is create the frame and it's contents in the Applet's init() method, then in the ActionListener for your "Login" button do something like this :

HTH,
-Nate
Something must be done about this. Let's start by reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1292 times.
Similar Threads
Reg focus events
Can anybody help with exception
Servlets connection
Want to insert image in frame
Application to be implemented???
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:18:58.