package mypackage;  //当注释掉该行时,没有错误,不注释的时候,总是出错
import javax.swing.*;
import java.awt.event.*;public class Console
{
//Creat a title string from the class name
public static String title(Object o)
{
String t = o.getClass().toString();
//Remove the word "class"
if(t.indexOf("class") != -1)
t = t.substring(6);
return t;
}
public static void run(JFrame frame,int width,int height)
{
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(width,height);
frame.setVisible(true);
}
public static void run(JApplet applet,int width,int height)
{
JFrame frame = new JFrame(title(applet));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
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));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(panel);
frame.setSize(width,height);
frame.setVisible(true);
}
public static void main(String [] args)
{
Console.run(new JPanel(),1000,500);
}
}上面注释的那一行总是出错误,当package以后应该怎么应用该类呢?
还有是不是package以后会自动生成一个文件夹呢???还是必须自己建立呀?