我有一个用 Swing 编码的带有 JButton 的表单,我单击它来完成操作。但是当我单击它时,我的框架会挂起。在使用任务栏结束它之前,我无法退出它。问题是什么?这是我的代码:
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String[] stopwords = {"a", "sometime", "sometimes", "somewhere", "still",
"such", "system", "take", "ten", "than", "that", "the", "their",
"them", "themselves", "then", "thence", "there", "thereafter",
"thereby", "therefore", "therein", "thereupon", "these", "they",
"thickv", "thin", "third", "this", "those", "though", "three",
"through", "throughout", "thru", "thus", "to", "together", "too",
"top", "toward", "towards", "twelve", "twenty", "two", "un",
"under", "until", "up", "upon", "us", "very", "via", "was", "we",
"well", "were", "what", "whatever", "when", "whence", "whenever",
"where", "whereafter", "whereas","whereby", "wherein", "whereupon",
"wherever", "whether", "which", "while","whither", "who", "whoever",
"whole", "whom", "whose", "why", "will", "with", "within", "without",
"would", "yet", "you", "your", "yours", "yourself", "yourselves",
"contact", "grounds", "buyers", "tried", "said,", "plan", "value",
"principle.", "forces", "sent:", "is,", "was", "like", "discussion",
"tmus", "diffrent.", "layout", "area.", "thanks", "thankyou",
"hello", "bye", "rise","fell","fall","psqft.","http://","km","miles"};
try {
Scanner fip1 = new Scanner(new File(selectedFile));
FileOutputStream out=new FileOutputStream("d:/StopWords.txt");
while(fip1.hasNext()) {
int flag=1;
String s1=fip1.next();
s1=s1.toLowerCase();
for(int i=0;i<stopwords.length;i++){
if(s1.equals(stopwords[i])) {
flag=0;
}
}
if(flag!=1) {
// System.out.println(s1);
// jTextArea1.append("\n"+s1);
PrintStream p=new PrintStream(out);
p.println(s1);
p.close();
}
}
JOptionPane.showMessageDialog(null,"STOP WORD REMOVAL IS DONE");
} catch(Exception e){
System.err.println("cannot read file");
}
}