| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1048 人关注过本帖
标题:[求助]这个程序错在那?我是新手
取消只看楼主 加入收藏
zhangjp
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-4-7
收藏
 问题点数:0 回复次数:5 
[求助]这个程序错在那?我是新手
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class text extends JFrame implements ActionListener
{
int red,green,blue;
JPanel p =new JPanel();
JButton b = new JButton("按键");
public text()
{
this.add(p);
p.add(b);
b.addActionListener(this);
this.setVisible(true);
this.setSize(300,200);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
}
public void actionperformed(ActionEvent e)
{
red = (int)(Math.random()*256);
green = (int)(Math.random()*256);
blue = (int)(Math.random()*256);
p.setBackground(new Color(red,green,blue));
this.setTitle("红:"+ red+" 绿:"+green +" 蓝:"+blue);
}
public static void main(String[] args)
{
new text();
}
}
搜索更多相关主题的帖子: 按键 public import 
2006-04-07 13:37
zhangjp
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-4-7
收藏
得分:0 

刚忘了,告诉public class text extends JFrame implements ActionListener不是抽象类,而且未覆盖
我不知道要怎么改,谢谢大家了

2006-04-07 13:50
zhangjp
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-4-7
收藏
得分:0 
我都实现了啊
还有就是抽象类,我定义了
2006-04-07 13:54
zhangjp
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-4-7
收藏
得分:0 
哈哈
谢谢了
是大写的事情
我真该打我自己了,那么简单的问题
谢谢了
2006-04-07 14:01
zhangjp
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-4-7
收藏
得分:0 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class aa extends JFrame implements KeyListener
{
JPanel p = new JPanel();
JTextField tf = new JTextField(20);
aa()
{
this.add(p);
tf.addKeyListener(this);
p.add(tf);
this.setVisible(true);
this.setSize(300,200);
this.setLocation(200,200);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
}
public void KeyTyped(KeyEvent e)
{
if(e.getKeyChar()=='a')
tf.setBackground(Color.yellow);
}
public void KeyPressed(KeyEvent e)
{
tf.setBackground(Color.red);
}
public void KeyReleased(KeyEvent e)
{
tf.setBackground(Color.black);
}
public static void main(String[] args)
{
new aa();
}
}
这个是那错了那?
我真的找不到了
2006-04-07 14:02
zhangjp
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-4-7
收藏
得分:0 
晕了,这个也是大小写的问题
2006-04-07 14:06
快速回复:[求助]这个程序错在那?我是新手
数据加载中...
 
   



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

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