Why is this not working please?
I want to make the button open another class(frame) but this doesnt seem to be working. Can anyone help me please. Thankyou x
JButton btnA = new JButton("");
btnA.addActionListener(///here it says identifier expected?
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
classframe mainFrame = new classframe();
mainFrame.setVisible(true);
}
[417 byte] By [
puzz_sol2a] at [2007-11-26 22:25:36]

paste the code exactly as it is in your java file and use code formatting tags.
How do i do that though please? I'm using Microsoft Visual Studio J# and I don't know about tagging it? thanks
> How do i do that though please? I'm using Microsoft> Visual Studio J# and I don't know about tagging it?> thanksreally? yuk. what for? I'd rather nail my scrotum to a tree than use that
1) paste the code into message area2) select the code3) press "code" button above message area
> ...I'm using Microsoft Visual Studio J#...That is not Java. I'm not saying it's a bad product or not, just that you're in the wrong forums to ask about that.
> > How do i do that though please? I'm using
> Microsoft
> > Visual Studio J# and I don't know about tagging
> it?
> > thanks
>
> really? yuk. what for? I'd rather nail my scrotum to
> a tree than use that
I only used that because when i originally coded my program it automatically saved there and I'm used to it. It's either that or JEdit
Thanks hellbinder I'll try that and I'm going to switch programming resources for everyone else that disagrees with MVS. lol.Thanks guys
> > > How do i do that though please? I'm using
> > Microsoft
> > > Visual Studio J# and I don't know about tagging
> > it?
> > > thanks
> >
> > really? yuk. what for? I'd rather nail my scrotum
> to
> > a tree than use that
>
>
>
> I only used that because when i originally coded my
> program it automatically saved there and I'm used to
> it. It's either that or JEdit
but it doesn't actually produce real java
Thanks hellbinder I'll try that and I'm going to switch programming resources for everyone else that disagrees with MVS. lol.Thanks guys
> > ...I'm using Microsoft Visual Studio J#...
The J# not actually Java and something may differ between the two languages (mostly now that the Java 1.5 and 1.6 have been released).
Unless you have a really evil boss who makes you work on .net or else you really need to integrate your code to a .net project then I sugest you use the Java provided by Sun!
As an editor you can use anything from TextPad to Eclipse (and all can be downloaded for free).
Regards,
Sim085
> I want to make the button open another class(frame)
> but this doesnt seem to be working. Can anyone help
> me please. Thankyou x
>
> JButton btnA = new JButton("");
>
> btnA.addActionListener(///here it says identifier
> expected?
>
> new ActionListener()
>
> {
>
> public void actionPerformed(ActionEvent e)
>
> {
>
> classframe mainFrame = new classframe();
>
> mainFrame.setVisible(true);
>
> }
The problem seems to be that you did not close your statement with ); otherwise the code seems to be ok.
I have wrriten the code again:btnA.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
classframe mainFrame = new classframe();
mainFrame.setVisible(true);
}
}); // You need to add this line.
Regards,
Sim085
I thought it was not pasted all. I would dump every compiler that would show error "identifier expected here" when that was a case of closing a bracket
hellbinder - What do you mean by message area. Im pretty new to all this. Sorry for being a pain :-)
> hellbinder - What do you mean by message area. Im> pretty new to all this. Sorry for being a pain :-)You just wrote that in the message area :)
kajbja at 2007-7-10 11:26:34 >

JButton btnA = new JButton("");btnA.addActionListener( ///here it says identifier expected?new ActionListener(){public void actionPerformed(ActionEvent e){classframe mainFrame = new classframe();mainFrame.setVisible(true);} );[
You have forgotten points 2 and 3
I had those brackets just never pasted them into the forum sorry Sim085. also Kajbj and hellbinder I was bein dead dosy and thought you wer talking about MVSJ# not the fourm (sorry, believe me I'm not blond).
anyways tried the message area and code button thing and still nowt doing.
I think the problem is the fact that I'm using a JFrame. my other page has a different layout and my button takes me there just fine. this one can't be accessed though
JButton btnA = new JButton("");
btnA.addActionListener( ///here it says identifier expected?
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
classframe mainFrame = new classframe();
mainFrame.setVisible(true);
}
> sorry, believe me I'm not blond.
What do you want to say by that!? don't you have feelings for blonds :P :)
> I think the problem is the fact that I'm using a
> JFrame. my other page has a different layout and my
> button takes me there just fine. this one can't be
> accessed though
Do you have all the necessary imports?
Regards,
Sim085
I would assume you are missing a closing bracket somewhere. Double check the code around your error line and check for proper closing of brackets.
that just a side line. ignore it.anyway I think I do, but I might just forget the panel and use a frame instead. It means more messing about with my button declarations but I think I'll just do that.Thanks a lot x