java一个小错误,帮忙看下啊,超级感谢import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.CaretEvent;import javax.swing.event.CaretListener;public class NumberFrame extends JFrame implements CaretListener
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 09:48:48
java一个小错误,帮忙看下啊,超级感谢import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.CaretEvent;import javax.swing.event.CaretListener;public class NumberFrame extends JFrame implements CaretListener
java一个小错误,帮忙看下啊,超级感谢
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
public class NumberFrame extends JFrame implements CaretListener
{
private JTextField texts[];
private JLabel label[];
public NumberFrame()
{
super("十进制整数转换");
this.setSize(220, 300);
this.setBackground(Color.lightGray);
this.setLayout(new FlowLayout());
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
String M[]={"十进制整数","二进制","八进制","十六进制"};
for (int i=0; i
java一个小错误,帮忙看下啊,超级感谢import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.CaretEvent;import javax.swing.event.CaretListener;public class NumberFrame extends JFrame implements CaretListener
private JTextField texts[]; 创建数组,但是没有开启空间,
在下方代码 label[i]=new JLabel(M[i]); 中,你直接给数组成员i 开始赋值了,所以出现了空指针.
现需要在FOR循环上方对 texts 初始化
texts = new JTextField [ M.length ] //大小应该与内容数量相同,否则后面会出现数组越界.