Java写一个图形界面应用程序,界面中有一个标签、一个文本框、一个文本区。

来源:百度知道 编辑:UC知道 时间:2024/07/04 15:10:54
标签提示用户在文本框输入一个正整数,然后在文本区显示小于或等于该正整数的所有质数,同时显示质数的个数。当用户输入小于2的整数时,在文本区显示“请输入一个大于等于2的正整数”
高手帮忙,谢谢!~暂时没分数,等我有了马上加分!~!~

就这么着吧,有点长。

/*
* 输入一个数,输出所有素数。
* 2008-10-16
*/

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class OutputPrime {

private JTextArea textArea;
private JTextField textField;
private JFrame frame;
private List<Integer> list = new ArrayList<Integer>();

public static void main(String args[]) {
OutputPrime window = new OutputPrime();
window.frame.setVisible(true);
}

public OutputPrime() {
createContents();
}

private void createContents() {
frame = new JFrame();
frame.setResizable(false);
frame.getContentPan