📄 spellgui.java
字号:
package 拼写检查器;
import java.awt.*;
import java.awt.event.*;
import java.util.LinkedList;
import java.util.TreeSet;
public class SpellGui extends Frame implements ActionListener{
SpellChecker spell=new SpellChecker();
static SpellGui gui=new SpellGui();
static Panel pan=new Panel();
static TextArea ta1=new TextArea("",10,10,TextArea.SCROLLBARS_NONE);
static TextArea ta2=new TextArea("",10,10,TextArea.SCROLLBARS_VERTICAL_ONLY);
static TextArea ta3=new TextArea("",10,10,TextArea.SCROLLBARS_VERTICAL_ONLY);
static TextField tf=new TextField();
static Button but=new Button("检查");
static Label lab1=new Label("你的字典");
static Label lab2=new Label("请输入一段文字!");
static Label lab3=new Label("错误的单词");
public static void main(String args[]){
gui.setTitle("拼写检查器");
gui.setSize(500,300);
gui.setLocation(300,200);
gui.setResizable(false);
gui.addWindowListener(new WinLis());
gui.setLayout(null);
gui.setBackground(new Color(225,245,252));
gui.setVisible(true);
gui.add(pan);
pan.setLayout(null);
pan.setSize(460,170);
pan.setLocation(20,70);
pan.setBackground(new Color(241,250,255));
pan.setVisible(true);
pan.add(ta1);
pan.add(ta2);
pan.add(ta3);
pan.add(tf);
tf.setBounds(10,10,140,25);
tf.setFont(new Font("楷体gb_2312",Font.PLAIN,16));
ta1.setBounds(10,50,140,110);
ta1.setEditable(false);
ta1.setBackground(new Color(255,255,255));
ta1.setFont(new Font("楷体gb_2312",Font.PLAIN,16));
ta2.setBounds(160,10,140,150);
ta3.setBounds(310,10,140,150);
ta2.setFont(new Font("楷体gb_2312",Font.PLAIN,16));
ta3.setFont(new Font("楷体gb_2312",Font.PLAIN,16));
//lab1.setSize(100,20);
//lab1.setLocation(10,50);
gui.add(lab1);
lab1.setBackground(new Color(199,199,199));
lab1.setBounds(60,45,55,20);
gui.add(lab2);
lab2.setBackground(new Color(199,199,199));
lab2.setBounds(195,45,100,20);
gui.add(lab3);
lab3.setBackground(new Color(199,199,199));
lab3.setBounds(360,45,65,20);
gui.add(but);
but.setBounds(390,250,60,25);
but.addActionListener(gui);
tf.addActionListener(gui);
}
static class WinLis extends WindowAdapter{
public void windowClosing(WindowEvent e){
gui.dispose();
System.exit(0);
}
}
public void actionPerformed(ActionEvent e) {
// TODO 自动生成方法存根
spell.addToDictionary(tf.getText());
tf.setText("");
ta1.setText(spell.outputDictionary());
spell.addToWordSet(ta2.getText());
LinkedList linkedList=spell.compare();
String s="";
for(int i=0;i<linkedList.size();i++){
s+=linkedList.get(i)+"\n";
}
ta3.setText(s);
System.out.println(s);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -