错误?
package com.bruceeckel.swing;
import javax.swing.*;
import java.awt.event.*;
public class Console{
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 width,int height){
setupClosing(frame);
frame.setSize(width,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.*;
import com.bruceeckel.swing.*;
public class Appletlc extends JApplet{
public void init(){
getContentPane().add(new JLabel("Applet!"));
}
public static void main(String[] args){
JApplet applet = new Appletlc();
JFrame frame = new JFrame("Appletlc");
Console.setupClosing(frame);
frame.getContentPane().add(applet);
frame.setSize(100,50);
applet.init();
applet.start();
frame.setVisible(true);
}
}
编译错误为:
G:\My Documents\Appletlc.java:12: cannot resolve symbol
symbol : method setupClosing (javax.swing.JFrame)
location: class Console
Console.setupClosing(frame);
^
1 error
import javax.swing.*;
import java.awt.event.*;
public class Console{
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 width,int height){
setupClosing(frame);
frame.setSize(width,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.*;
import com.bruceeckel.swing.*;
public class Appletlc extends JApplet{
public void init(){
getContentPane().add(new JLabel("Applet!"));
}
public static void main(String[] args){
JApplet applet = new Appletlc();
JFrame frame = new JFrame("Appletlc");
Console.setupClosing(frame);
frame.getContentPane().add(applet);
frame.setSize(100,50);
applet.init();
applet.start();
frame.setVisible(true);
}
}
编译错误为:
G:\My Documents\Appletlc.java:12: cannot resolve symbol
symbol : method setupClosing (javax.swing.JFrame)
location: class Console
Console.setupClosing(frame);
^
1 error
...全文
相关推荐
无法从 int? 转换为 int 运行时出现错误
当我们试图将`int?`转换为`int`时,需要确保`int?`变量不是`null`。这是因为直接转换会尝试将`null`值赋给非可空类型,这会导致编译错误或运行时异常。
HTTP 500错误是什么意思?
服务器配置错误:服务器的配置文件(例如httpd.conf)存在错误,例如虚拟主机配置错误、目录权限不正确等,可能会导致服务器返回500错误。如何解决HTTP 500错误?下面是一些建议:1.
Excel2021中出现常见错误值怎么办?.docx
可能的原因包括缺少数据,查找函数参数错误,未排序的表中使用查找函数,数组公式参数与区域大小不符,缺少必需参数,使用不可用的自定义函数,或宏返回#N/A。5. #NAME?
Dreamweaver无法打开提示javascript错误怎么办?
Dreamweaver无法打开提示javascript错误怎么办?Dreamweaver无法启动,总是提示javascript错误,删除部分软件也不行,该怎么办呢?下面我们就来看看详细的解决办法,需要
在错误的数据上,刷到 SOTA 又有什么意义? .rar
揭示了当前人工智能领域(AI)特别是机器学习(ML)和自然语言处理(NLP)中一个关键问题:如果模型在错误的数据集上实现了最先进的(State-of-the-Art,简称SOTA)性能,那么这种成就的实际价值是多少?


Java SE

