当前位置: 技术问答>java相关
请帮看看这段菜代码错在哪里?
来源: 互联网 发布时间:2015-08-31
本文导语: import javax.swing.JOptionPane; import javax.swing.JTextArea; import java.awt.Event; import java.awt.*; public class InitArray { public static void main(String args[]) { JTextArea outText = new JTextArea(20,10); String numberCount = JOptionPa...
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import java.awt.Event;
import java.awt.*;
public class InitArray
{
public static void main(String args[])
{
JTextArea outText = new JTextArea(20,10);
String numberCount = JOptionPane.showInputDialog("请您输入数组的大小:");
int count = Integer.parseInt(numberCount);
outText.addKeyListener(new KeyAdapter()//编译时这里出错
{
public void keyPressed(KeyEvent e)
{
JOptionPane.showMessageDialog(null,e.getKeyCode(),"提示信息",JOptionPane.PLAIN_MESSAGE);
}//方法结束
}//class结束
);
outText.setText("");
outText.append("此数组共有" + count + "个元素:n");
int number[] = new int[count];
appendToTextArea(number,outText);
JOptionPane.showMessageDialog(null,outText,"提示信息",JOptionPane.
INFORMATION_MESSAGE);
System.exit(0);
}
public static void appendToTextArea(int a[],JTextArea source)
{
for(int i = 0;i
import javax.swing.JTextArea;
import java.awt.Event;
import java.awt.*;
public class InitArray
{
public static void main(String args[])
{
JTextArea outText = new JTextArea(20,10);
String numberCount = JOptionPane.showInputDialog("请您输入数组的大小:");
int count = Integer.parseInt(numberCount);
outText.addKeyListener(new KeyAdapter()//编译时这里出错
{
public void keyPressed(KeyEvent e)
{
JOptionPane.showMessageDialog(null,e.getKeyCode(),"提示信息",JOptionPane.PLAIN_MESSAGE);
}//方法结束
}//class结束
);
outText.setText("");
outText.append("此数组共有" + count + "个元素:n");
int number[] = new int[count];
appendToTextArea(number,outText);
JOptionPane.showMessageDialog(null,outText,"提示信息",JOptionPane.
INFORMATION_MESSAGE);
System.exit(0);
}
public static void appendToTextArea(int a[],JTextArea source)
{
for(int i = 0;i