1求一段Java的程序代码,这个代码的功能是要求弹出新窗口的,要求完整的一段代码(包括这段代码的最后文件名)...
(我是用eclipse.exe操作的)
2另有疑问:
import java.awt.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Frame1 extends JFrame
{
private JButton jButton1=new JButton();
public Frame1 ()
{
try {
jbInit();
}
catch(Exception exception) {
exception.printStackTrace();
}
this.setVisible(true);
}
private void jbInit () throws Exception
{
this.setBounds(300,180,400,300);
getContentPane().setLayout(null);
jButton1.setBounds(new Rectangle(127, 120, 139, 36));
jButton1.setMnemonic('C');
jButton1.setText("点我(C)");
jButton1.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().add(jButton1);
}
public static void main (String[] args)
{
Frame1 frame1=new Frame1();
}
public void jButton1_actionPerformed (ActionEvent e)
{
this.setVisible(false);
JFrame jf1=new JFrame("子窗口");
jf1.setBounds(100,50,800,600);
jf1.setDefaultCloseOperation(jf1.EXIT_ON_CLOSE);
jf1.setVisible(true);
}
}
这段代码,是一个简单的JAVA程序,点击按钮弹出一个新窗口并且隐藏按钮所在的窗口!
但是,我不知道它具体的文件名是什么,是*.java,我不清楚,所以我在 eclipse.exe中运行,都是错误的,求高手帮忙啊!
package untitled1
是什么意思啊,我把那三个文件都编好了,用eclipse运行windowscenter.java系统说,那开头的package does not match the expected package...
那个package,要先建一个吗..
还有就是,那三个文件编译,怎么编译啊,我只是用记事本用java为后缀保存了,具体编译,要用dos命令吗?
我java是超级不懂啊