| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1369 人关注过本帖
标题:没看出错在哪里,请老司机帮看看,谢谢
取消只看楼主 加入收藏
notbad301
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2018-2-17
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
没看出错在哪里,请老司机帮看看,谢谢
执行不了,但没看出来哪里有错,请老司机帮看看。

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

    public class Gaibianyanse extends JFrame implements ActionListener{
     Button bt1,bt2;
     JPanel jp1,jp2;
   
    public static void main(String[] args) {
        Gaibianyanse keke=new Gaibianyanse();
    }

    public Gaibianyanse() {
        bt1=new Button("红色");
        bt2=new Button("绿色");
        jp1=new JPanel();
        jp2=new JPanel();
        bt1.addActionListener(this);
        bt2.addActionListener(this);
        bt1.setActionCommand("Tutu");
        bt2.setActionCommand("Kaka");
        jp2.add(bt1);
        jp2.add(bt2);
        jp2.setLayout(new FlowLayout(FlowLayout.CENTER));
        
        this.setLayout(new GridLayout(2,1));
        this.add(jp1);
        this.add(jp2);
        
        this.setTitle("改颜色的面板");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
        this.setLocation(300, 300);
        this.setSize(300,300);        
    }
   
    public void ActionPerformed(ActionEvent e) {
        if(e.getActionCommand().equals("Tutu")) {
            jp1.setBackground(Color.BLACK);
        }
        else if(e.getActionCommand().equals("Kaka")) {
            jp1.setBackground(Color.RED);
            }
    }
    }
搜索更多相关主题的帖子: 出错 public new add this 
2018-03-09 18:33
notbad301
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2018-2-17
收藏
得分:0 
谢谢!
2018-03-09 20:05
快速回复:没看出错在哪里,请老司机帮看看,谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015034 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved