| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 574 人关注过本帖
标题:[讨论]eclipse中鼠标响应问题
只看楼主 加入收藏
jflin
Rank: 1
等 级:新手上路
帖 子:59
专家分:0
注 册:2006-5-17
收藏
 问题点数:0 回复次数:0 
[讨论]eclipse中鼠标响应问题

我在Eclipse中运行这个程序:
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import java.awt.Color;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class A{

/**
* Launch the application
* @param args
*/
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application");
shell.open();

final Button button = new Button(shell, SWT.NONE);
button.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e)
{
button.setForground(Color.blue);
button.setBackgrond(Color.cyan);
}
});
button.setText("button");
button.setBounds(60, 60, 120, 60);
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}

}
提示这两行 button.setForeground(Color.blue);
button.setBackground(Color.cyan);
出错了,类型 Control 中的方法 setForeground(Color)对于参数(Color)不适用,请问应该怎么改才能让按钮能够响应到这个事件?

[此贴子已经被作者于2006-10-17 12:57:05编辑过]

搜索更多相关主题的帖子: eclipse 鼠标 
2006-10-17 12:56
快速回复:[讨论]eclipse中鼠标响应问题
数据加载中...
 
   



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

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