青
青云
Unregistered / Unconfirmed
GUEST, unregistred user!
源文件frame1.java (该文件的路径是 d:/test/frame1.java )如下:
import java.awt.*;
import java.awt.event.*;
public class frame1 extends Frame
{
frame1()
{
super("Frame1");
// self.title:='Frame with Button"';
setSize(300,250);
setLayout(null);
//pack();
addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
//setVisible(false);
System.exit(0);}});
canvas2a x=new canvas2a();
this.add(x);
this.setVisible(true);
// self.visible:=true;
}
class canvas2a extends Canvas
{
canvas2a()
{
setSize(250,100);
this.setBounds(23,23,240,100);
setBackground(Color.yellow);
}
public void paint(Graphics g)
{
g.setColor(Color.red);
g.drawString("this is my gui program",40,50);
}
}
public static void main(String args[])
{
frame1 frm=new frame1();
}
}
jdk的安装位置: D:/Program Files/JBuilder8/jdk1.4
然后,我建立一个 bat文件,内容是:
D:/Program Files/JBuilder8/jdk1.4/bin/javac d:/test/frame1.java
D:/Program Files/JBuilder8/jdk1.4/bin/javaw -classpath "d:/test" frame1
可是运行不成功,我修改如下:
d:
cd D:/Program Files/JBuilder8/jdk1.4/bin
javac d:/test/frame1.java
javaw -classpath "d:/test" frame1
这样就可以了,请问是什么原因?
import java.awt.*;
import java.awt.event.*;
public class frame1 extends Frame
{
frame1()
{
super("Frame1");
// self.title:='Frame with Button"';
setSize(300,250);
setLayout(null);
//pack();
addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
//setVisible(false);
System.exit(0);}});
canvas2a x=new canvas2a();
this.add(x);
this.setVisible(true);
// self.visible:=true;
}
class canvas2a extends Canvas
{
canvas2a()
{
setSize(250,100);
this.setBounds(23,23,240,100);
setBackground(Color.yellow);
}
public void paint(Graphics g)
{
g.setColor(Color.red);
g.drawString("this is my gui program",40,50);
}
}
public static void main(String args[])
{
frame1 frm=new frame1();
}
}
jdk的安装位置: D:/Program Files/JBuilder8/jdk1.4
然后,我建立一个 bat文件,内容是:
D:/Program Files/JBuilder8/jdk1.4/bin/javac d:/test/frame1.java
D:/Program Files/JBuilder8/jdk1.4/bin/javaw -classpath "d:/test" frame1
可是运行不成功,我修改如下:
d:
cd D:/Program Files/JBuilder8/jdk1.4/bin
javac d:/test/frame1.java
javaw -classpath "d:/test" frame1
这样就可以了,请问是什么原因?