ackage taoshi.a6;
import javax.swing.*;
import java.awt.event.*;
public class Adisplay {
public static String title(Object o) {
String t=o.getClass().toString();
if(t.indexOf("class"!=-1)) {
t=t.substring(6);
return t;
}
public static void setupClosing (JFrame frame) {
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
public static void
run (JFrame frame,int widthint ,height) {
setupClosing(frame);
frame.setSize(wideth,height);
frame.setVisible(true);
}
public static void
run (JApplet applet,int width,int height) {
JFrame frame=new JFrame(title(applet));
setupClosing(frame);
frame.getContentPane().add(applet);
frame.setSize(width,height);
applet.init();
applet.start();
frame.setVisible(true);
}
public static void
run (JPanel panel,int width,int height) {
JFrame frame=new JFrame(title(panel));
setupClosing(frame);
frame.getContentPane().add(panel);
frame.setSize(width,height);
frame.setVisible(true);
}
}
}}
怎么搞的有四处错误,这是书上的原程序啊。怎么把错误消除啊
import javax.swing.*;
import java.awt.event.*;
public class Adisplay {
public static String title(Object o) {
String t=o.getClass().toString();
if(t.indexOf("class"!=-1)) {
t=t.substring(6);
return t;
}
public static void setupClosing (JFrame frame) {
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
public static void
run (JFrame frame,int widthint ,height) {
setupClosing(frame);
frame.setSize(wideth,height);
frame.setVisible(true);
}
public static void
run (JApplet applet,int width,int height) {
JFrame frame=new JFrame(title(applet));
setupClosing(frame);
frame.getContentPane().add(applet);
frame.setSize(width,height);
applet.init();
applet.start();
frame.setVisible(true);
}
public static void
run (JPanel panel,int width,int height) {
JFrame frame=new JFrame(title(panel));
setupClosing(frame);
frame.getContentPane().add(panel);
frame.setSize(width,height);
frame.setVisible(true);
}
}
}}
怎么搞的有四处错误,这是书上的原程序啊。怎么把错误消除啊
解决方案 »
- 学习java
- 两颗星以下的菜鸟们不要瞎起哄,一定要三星以上的老鸟,最好是四星级的古灰级鸟回答。JAVA中的引用和C++中的引用一样吗?
- 有谁有关于Java的面试试题呢?
- 如何输入字符串,并输出
- struts-bean.tld,struts-html.tld,struts-logic.tld 请教
- JFrame 修改标题栏颜色??
- 伟大的中华人民共和国万岁!国庆假期万岁!
- 关于java Map put方法的一点疑问?请高手解答
- 数组 查找相邻的最大值
- 下面的代码用命令行运行成功了,但用eclipse编译失败
- =====请问如何做远程控制?======
- sb.append('*');和sb=sb.append('*');有什么区别?
建议你用一个IDE工具,例如Eclipse,它会提示你有哪些错误,以及建议的改正方法。
if(t.indexOf("class")!=-1)
package taoshi.a6;import javax.swing.*;
import java.awt.event.*;public class Adisplay {
public static String title(Object o) {
String t=o.getClass().toString();
if(t.indexOf("class")!=-1) {
t=t.substring(6);
}
return t;}
public static void setupClosing(JFrame frame){
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});}
public static void
run (JFrame frame,int widthint ,int height) {
setupClosing(frame);
frame.setSize(widthint,height);
frame.setVisible(true);
}
public static void run (JApplet applet,int width,int height) {
JFrame frame=new JFrame(title(applet));
setupClosing(frame);
frame.getContentPane().add(applet);
frame.setSize(width,height);
applet.init();
applet.start();
frame.setVisible(true);}
public static void
run (JPanel panel,int width,int height) {
JFrame frame=new JFrame(title(panel));
setupClosing(frame);
frame.getContentPane().add(panel);
frame.setSize(width,height);
frame.setVisible(true);
}}