if (e.equals ("button1"))
this.setVisible(false);
StudentProfileGui itemloader=new StudentProfileGui();
itemloader.setVisible(true);
if (e.equals ("button2"))
this.setVisible(false);
StudentProfileEditGui itemload=new StudentProfileEditGui();
itemload.setVisible(true);
thats what im using at the min... where the underline it it says void is an invalid type for the action actionPerformed and the other is missing syntax ( )
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
> if (e.equals ("button1"))
this is just totally wrong.
'e' is an actionEvent, so cannot be equal to a button
button1 is probably the variable name for the button,
so should not be enclosed in quotes.
what you probably want is
if(e.getSource().equals(button1))
It looks like you are attempting to switch back and forth between frames,
so you'd probably be better off using a single frame and having the contentPane
set up as a CardLayout (which contains multiple panels, only one panel showing at a time),
then using a JMenu to switch between panels.
Katie Tuffrey
Greenhorn
Joined: Dec 14, 2011
Posts: 6
posted
0
thanks so much for all your help, i managed to sort it earlier! got a new question now but will start a new topic
xx
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
4
posted
0
How did you sort it out? Using getSource() is liable to lead you into non-object-oriented programming.
If there is any more discussion, I think it would sit better on our GUIs forum, so I shall move this thread.
Randall Twede
Ranch Hand
Joined: Oct 21, 2000
Posts: 4095
1
posted
0
Using getSource() is liable to lead you into non-object-oriented programming.
true enough. that is what you do when you have lots of if-else statements in actionPerformed().
still, it is a common practice especially in small projects.