私は3つのクラスを持っています.1つはメインクラス、もう1つはawt + swingを使って4つのボタンで基本ウィンドウを作るGUIクラスです。Java ActionListenerクラスで変数を見つけることができません。
//BEGIN ADD ACTION LISTENERS
handle_events event_handler=new handle_events();
home_b.addActionListener(event_handler);
my_account_b.addActionListener(event_handler);
my_history_b.addActionListener(event_handler);
exit_b.addActionListener(event_handler);
//END ADD ACTION LISTENERS
マイhandle_eventsクラスには、次のようになります。
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
class handle_events implements ActionListener
{
public handle_events(){}
public void actionPerformed(ActionEvent e)
{
if(e.getSource==home_b) {do stuff;}
//etc
}
}
//END EVENT HANDLER CLASS
問題はhome_bは関係なく、私は何をすべきかの、のActionListenerクラスによって発見することができないということです。あなたのすべての協力に感謝します。
Javaの命名規則を覚えておいてください。 – kleopatra