Swing

I would like to get the code for the action command ,ie when I click a button in a JFrame such as login button, I want to go to the next page/frame.What is the code for that .Hope some one will help.Thanks.
[220 byte] By [mgrahula] at [2007-11-26 13:59:35]
# 1

JButton updBt = new JButton("My Button");

updBt.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

// Call method or do what you want here

}

});

ProZa at 2007-7-8 1:40:27 > top of Java-index,Desktop,Core GUI APIs...
# 2

> > JButton updBt = new JButton("My Button");

> updBt.addActionListener(new ActionListener() {

>public void actionPerformed(ActionEvent e) {

>// Call method or do what you want here

> }

> });

>

// Call method or do what you want here:

if (ae.getActionCommand().equals(My Button))

I want to get the code after this. I am trying to get the code for the last hours and was not able to get hope some one will helo me.

Thanks

mgrahula at 2007-7-8 1:40:27 > top of Java-index,Desktop,Core GUI APIs...
# 3

try this but u have to implement the ActionListener after that it will work

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Test extends JFrame implements ActionListener{

public JButton testBtn ;

public Test(){

testBtn = new JButton("Test");

testBtn.addActionListener(this);

}

public void actionPerformed(ActionEvent e){

String command = e.getActionCommand();

if(command.equals("Test")){

System.out.println("Hello im pressed");

}

}

}

and what ever u do in actionperformed function u like by pressing it and calling that function

null

zerocooola at 2007-7-8 1:40:27 > top of Java-index,Desktop,Core GUI APIs...