action listener problem

I have created the following code and i want the "btnCreate" to open the frame eqstring, i have tried to implement the action listener and it compiles but when i run it the button does nothing

pnlCreate.add(btnCreate);

pnlSimpleExample.add(btnSimpleExample);

pnlHardExample.add(btnHardExample);

pnlTitle.add(new Label("MAIN MENU"));

pnlTitle.setFont(new Font("Arial", Font.BOLD, 36));

// Setup Main Frame

f.getContentPane().setLayout(new BorderLayout());

f.getContentPane().add(pnlCreate, BorderLayout.SOUTH);

f.getContentPane().add(pnlSimpleExample, BorderLayout.WEST);

f.getContentPane().add(pnlHardExample, BorderLayout.EAST);

f.getContentPane().add(pnlTitle, BorderLayout.NORTH);

this.setSize(300, 300);

btnCreate.addActionListener(

new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

eqstring mainFrame = new eqstring();

}

});

}

[983 byte] By [murtle2k_07a] at [2007-11-26 22:09:18]
# 1
Try adding mainFrame.setVisible(true) after its declaration in actionPerformed.
ignignokt84a at 2007-7-10 10:55:58 > top of Java-index,Java Essentials,Java Programming...
# 2
what does constructing a eqstring() do? If its just a frame, you aren't calling pack or setVisible(true).
robtafta at 2007-7-10 10:55:58 > top of Java-index,Java Essentials,Java Programming...
# 3

> eqstring mainFrame = new eqstring();

How are we supposed to know what this line of code does (other than invoke the constructor of the "eqstring" class)?

Are you saying you don't believe it is executing the above code? Or just that it "doesn't do anything" that you can see anyway?

Debug it! Put some tracing code above or below that line, so you can "watch" in a sense that it actually did execute it.

warnerjaa at 2007-7-10 10:55:58 > top of Java-index,Java Essentials,Java Programming...
# 4
By the way, it's pretty rude of you to have attached 10 dukes to your other thread: http://forum.java.sun.com/thread.jspa?threadID=5150107and not award them, nor even say a simple "thank you".I bet you do the same thing here.
warnerjaa at 2007-7-10 10:55:58 > top of Java-index,Java Essentials,Java Programming...
# 5

I think warnerja is stressed and really thinks you should check out this [url=http://forum.java.sun.com/rewards.jspa?&threadID=5150158&messageID=9562382&dukes=10&doActions=rewardtrue&actionButton=Reward+Duke+Stars]very helpful Java tool[/url] that you can put your code into and it will tell you what you did wrong.

robtafta at 2007-7-10 10:55:58 > top of Java-index,Java Essentials,Java Programming...
# 6

ok, warnerja i posted the question before i left for work, i have now only just got in and come back to the computer. . . . so im sorry that my saying thankyou/awarding the dukes didnt come soon enough. But i do appreciate the help people are offering here.

Im pretty new to java . . . basically i have created the interface and on the first page i have a button that i want open another page. The code i have pasted to show you is what i have taken from a text book . . . for the action listener.

murtle2k_07a at 2007-7-10 10:55:58 > top of Java-index,Java Essentials,Java Programming...
# 7

> I think warnerja is stressed and really thinks you

> should check out this

> [url=http://forum.java.sun.com/rewards.jspa?&threadID=

> 5150158&messageID=9562382&dukes=10&doActions=rewardtru

> e&actionButton=Reward+Duke+Stars]very helpful Java

> tool[/url] that you can put your code into and it

> will tell you what you did wrong.

:-)

warnerjaa at 2007-7-10 10:55:58 > top of Java-index,Java Essentials,Java Programming...