ログアウトできない?
というわけで、もはや古いかもしれないですが、ログアウトボタンが無効になっている。ログアウト画面を作りましたw
とはいえ、見てるうちにきりととあすなのやりとりとかだんだんうざくなってくるのはおじさんだけだろうかw
Logoutクラス
-------------------------------------------------------------------------------------------
package sample37;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Logout extends JFrame implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
//ボタンなどが押された時の処理を描く(イベントドリブンという?)
String eventName = e.getActionCommand();
//確認
System.out.println(eventName);
if("cancel".equals(eventName)){
this.setVisible(false);
//特に意味はないですが、終了時に数値を通知できます。
System.exit(99);
}
}
public Logout() {
init();
}
private void init() {
//コンポーネントの入れ物
Container container = this.getContentPane();
JButton btnLogout = new JButton("ログアウト");
JButton btnCancel = new JButton("キャンセル");
//コンポーネントのおおきさ
btnLogout.setSize(100, 30);
btnCancel.setSize(100, 30);
//コンポーネントの場所
btnLogout.setLocation(100, 100);
btnCancel.setLocation(250, 100);
//イベント実行時のきりわけに
btnLogout.setActionCommand("logout");
btnCancel.setActionCommand("cancel");
//<b>ログアウトボタンを使用不能に</b>
btnLogout.setEnabled(false);
//イベントの登録
btnLogout.addActionListener(this);
btnCancel.addActionListener(this);
JPanel pnl = new JPanel();
pnl.add(btnLogout);
pnl.add(btnCancel);
container.add(pnl);
this.setTitle("ろぐあうと?");
this.setSize(600, 400);
this.setLocation(200, 200);
this.setVisible(true);
}
public static void main(String args[]) {
// SentakuFrame frame =
new Logout();
}
}
-------------------------------------------------------------------------------------------
アマゾンでソードアートオンラインを買うなら?したからおなしゃす。