亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

actionPerformed 方法中的錯誤

actionPerformed 方法中的錯誤

幕布斯6054654 2021-07-13 21:09:57
import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Main implements ActionListener {    public static void main(String[] args) {        JFrame f = new JFrame();        JPanel p = new JPanel();        Label l = new Label("Sam");        Button b = new Button("Click me");        Label l2 = new Label();        l.setBounds(3,5,4000,5000);        l.setForeground(Color.BLUE);        b.setLocation(5,5);        b.setSize(1,1);        f.setVisible(true);        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        f.setSize(500,600);        f.setResizable(false);        p.add(l);        p.add(b);        p.setBackground(Color.red);        f.add(p);        b.addActionListener(this);        public void actionPerformed(ActionEvent e){            String str = e.getActionCommand();            if(str.equals("Click me"))                System.out.println("GM");        }    }}這就是為什么 Intellij 在 actionPerformed 方法中顯示錯誤的原因。他們在 ActionEvent e 的聲明中顯示錯誤。錯誤:請幫助我,我是初學者。這也是正確的: b.addActionListener(this); ?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 319 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號