|
[code:1]
console.java
//Import this into an applet so that the applet can run as an application.
package tfw;
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.setDefaultCloseOperation(EXIT_ON_CLOSE);//???
frame.addWindowListener(
new WindowAdapter()//Event listening
{
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);
}
}
[/code:1]
我照着书打了这个文件,并且编译通过.
我想把这个文件打进一个名为"tfw"的包里,以便今后些程序可以随时调用.
比如下面这个文件,将引用上述文件的内容:
[code:1]
import java.lang.System;
import javax.swing.*;
import java.awt.*;
import tfw.*;
import java.awt.event.*;
public class button
{
......
......
......
public static void main(String args[])
{
new button();
}
}
[/code:1]
我的操作步骤以及提示如下:
[code:1]
[root@TFW-RHL73 newtest]# javac -d /usr/jclass/ ./console-java/console.java
[root@TFW-RHL73 newtest]# CLASSPATH=/usr/jclass/
[root@TFW-RHL73 newtest]# javac button.java
button.java:4: package tfw does not exist
import tfw.*;
^
1 error
[root@TFW-RHL73 newtest]# _
[/code:1]
为什么?我应该怎么做? |
|