关于run函数的问题

iSausage 2011-04-30 12:09:34
本人正在阅读《Java编程思想》一书,至793页时运行程序(代码如下)时遇到如下提示
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method run(RadioButtons, int, int) is undefined for the type RadioButtons


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import static net.mindview.util.SwingConsole.*;

public class RadioButtons extends JFrame{
private JTextField t=new JTextField(15);
private ButtonGroup g=new ButtonGroup();
private JRadioButton
rb1=new JRadioButton("one",false),
rb2=new JRadioButton("two",false),
rb3=new JRadioButton("three",false);
private ActionListener al=new ActionListener(){
public void actionPerformed(ActionEvent e){
t.setText("Radio button"+((JRadioButton)e.getSource()).getText());
}
};
public RadioButtons(){
rb1.addActionListener(al);
rb2.addActionListener(al);
rb3.addActionListener(al);
g.add(rb1);g.add(rb2);g.add(rb3);
t.setEditable(false);
setLayout(new FlowLayout());
add(t);
add(rb1);
add(rb2);
add(rb3);
}

public static void main(String[] args) {
run(new RadioButtons(),200,125);
}
}


请各位指点,是何原因造成,我应该怎么办?非常感谢~
...全文
153 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
panoopan 2011-12-02
  • 打赏
  • 举报
回复
是作者用到了自己的类 库import static net.mindview.util.SwingConsole.*;
,你将这个类库 导入就行了!!
xyls82 2011-04-30
  • 打赏
  • 举报
回复
有点怪
iSausage 2011-04-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 ylz2007 的回复:]

没看明白,可能是代码不全。
[/Quote]
[Quote=引用 2 楼 gentleboy2009 的回复:]

书上的代码可能没有全部印出来~~~去书上的网站去下载代码
[/Quote]
是全部代码,也是我从图书官网上下载的。
gentleboy2009 2011-04-30
  • 打赏
  • 举报
回复
书上的代码可能没有全部印出来~~~去书上的网站去下载代码
  • 打赏
  • 举报
回复
没看明白,可能是代码不全。
Joop_Song 2011-04-30
  • 打赏
  • 举报
回复
The method run(RadioButtons, int, int) is undefined for the type RadioButtons


你RadioButtons中没有定义run(RadioButtons, int, int)这个方法,但是你却在main中调用了它,你在找找这个方法,把它敲上去应该就没问题了。。
iSausage 2011-04-30
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 bao110908 的回复:]

引用 6 楼 windows1989 的回复:

引用 5 楼 bao110908 的回复:

run 方法在哪里?我好像没有看到呢。
最后一行代码



我指的是 run 方法的定义在哪里?
[/Quote]
书上没有run方法的定义。
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 windows1989 的回复:]

引用 5 楼 bao110908 的回复:

run 方法在哪里?我好像没有看到呢。
最后一行代码
[/Quote]


我指的是 run 方法的定义在哪里?
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 bao110908 的回复:]

run 方法在哪里?我好像没有看到呢。
[/Quote]

书上是这样的,肯定是没印全
iSausage 2011-04-30
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 bao110908 的回复:]

run 方法在哪里?我好像没有看到呢。
[/Quote]最后一行代码
  • 打赏
  • 举报
回复
run 方法在哪里?我好像没有看到呢。

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧