getActionCommandは解決できないかフィールドではありません
というエラーが出るのですが、何が原因なのでしょうか?
今私が書いているプログラムを載せておきます。
コード import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class ap2 extends Panel implements ActionListener{ APP parent; Judge judge_main = new Judge(); Player player_main1[] = new Player[ap1.player]; //--------------------------------------------------------------------------- Label lab1 = new Label("出す手を決めてください"); Label lab2 = new Label("1(グー)、2(チョキ)、3(パー)を入力してください"); TextField tf1 = new TextField(5); TextField tf2 = new TextField(5); Button bt1 = new Button("決定"); Button bt2 = new Button("決定"); Button bt3 = new Button("ジャンケン ポン"); //--------------------------------------------------------------------------- public ap2(APP app){ parent = app; setBackground(Color.pink); setBounds(0, 0, 700, 700); setLayout(null); lab1.setBounds(240, 30, 300, 35); lab1.setFont(new Font("Serif", Font.PLAIN, 20)); add(lab1); lab2.setBounds(170, 60, 360, 40); lab2.setFont(new Font("Serif", Font.PLAIN, 14)); add(lab2); tf1.setBounds(80, 170, 75, 25); tf1.setEchoChar('*'); tf1.setFont(new Font("Serif", Font.PLAIN, 15)); tf2.setBounds(230, 170, 75, 25); tf2.setEchoChar('*'); tf2.setFont(new Font("Serif", Font.PLAIN, 15)); bt1.setBounds(85, 230, 65, 30); bt1.addActionListener(this); bt2.setBounds(235, 230, 65, 30); bt2.addActionListener(this); if(ap1.player_PC == 1){ add(tf1); add(bt1); } else{ add(tf1); add(tf2); add(bt1); add(bt2); } bt3.setBounds(295, 590, 120, 50); bt3.setEnabled(false); add(bt3); bt3.addActionListener(this); parent.add(this); } //--------------------------------------------------------------------------- public void init(){ repaint(); } //--------------------------------------------------------------------------- public void paint(Graphics g){ for(int i = 0; i < ap1.player_PC; i++){ player_main1[i] = new Player("プレイヤー" + (i+1)); g.setFont(new Font(null, Font.PLAIN, 14)); g.drawString(player_main1[i].getName(), 80+150*i, 140); } for(int i = ap1.player_PC; i < ap1.player; i++){ player_main1[i] = new Player("コンピュータ" + (i+1-ap1.player_PC)); g.setFont(new Font(null, Font.PLAIN, 14)); g.drawString(player_main1[i].getName(), 80+150*i, 140); } } //---------------------------------------------------------------------------- public void actionPerformed(ActionEvent e){ if(e.getActionCommand == "ジャンケン ポン"){ } } }
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。