if (e.equals ("button1"))
StudentProfileGui itemloader=new StudentProfileGui();
if (e.equals ("button2"))
StudentProfileEditGui itemload=new StudentProfileEditGui();
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 ( )
Joined: Jun 09, 2003
> 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
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.
Joined: Dec 14, 2011
thanks so much for all your help, i managed to sort it earlier! got a new question now but will start a new topic
Joined: Oct 13, 2005
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.
Joined: Oct 21, 2000
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.