请看我的代码如下:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class MyCompare extends JFrame
{
static String a,b;
static JLabel l1 = new JLabel("请输入您的密码");
static JLabel l2 = new JLabel("请确认您的密码");
static JLabel l3 = new JLabel();
//static JLabel l4 = new JLabel();
static JPasswordField j1 = new JPasswordField();
static JPasswordField j2 = new JPasswordField();
static JButton b1 = new JButton("确认");
static JButton b2 = new JButton("清除");
public MyCompare()
{
super("登陆框");
setBounds(20,20,200,150);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
MyCompare m = new MyCompare();

m.getContentPane().add(l1);
m.getContentPane().add(j1);
m.getContentPane().add(l2);
m.getContentPane().add(j2);
m.getContentPane().add(l3);
//m.getContentPane().add(l4);
m.getContentPane().setLayout(new GridLayout(4,2));
m.show();
a = j1.getPassword().toString();
b = j2.getPassword().toString();
b1.addActionListener(new ButtonListener1());
b2.addActionListener(new ButtonListener2());
//frm.getContentPane().setLayout(new GridLayout(4,2));
}
static class ButtonListener1 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
if(a.equals(b))
{
l3.setText("OK!!");
}
else
{
l3.setText("error!!");
}
}
}

static class ButtonListener2 implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
j1.setText(null);
j2.setText(null);
}
}

}我用我的14.1宽屏笔记本运行,每次都是黑屏,在学校的台式机却不是这样,不知道是怎么回事,难道宽屏幕显示器有关系???

解决方案 »

  1.   

    sony的吧,让你别买,小心炸死 啊
      

  2.   

    你直接到dos环境下运行一下,可能jre问题,我运行你的程序没有问题
      

  3.   

    我用的版本jdk比较低 是1.4.2.09版本 是版本低的缘故吗怎么样才能解决问题啊????
      

  4.   

    刚才我用DOS中运行了一下,可以运行!那为什么在jcreator中就会出现黑屏现象呢?