adddictionary.java
来自「用JAVA实现文档检查正误的系统」· Java 代码 · 共 526 行 · 第 1/2 页
JAVA
526 行
jLabel4.setText("\u4ece\u8bcd\u5178\u5220\u9664\u5355\u8bcd:");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(50, 50, 50)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 439, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel1))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel3))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel4)
.add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(19, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(22, 22, 22)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 158, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(25, 25, 25)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(jLabel2)
.add(jLabel3)
.add(jLabel4))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void DelWord1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DelWord1ActionPerformed
String Message="请输入你想要删除的新单词。";
String Title="删除单词输入";
try{
DelWord=JOptionPane.showInputDialog(frame1,Message,Title,MessageType);
}catch(Exception e){
}
}//GEN-LAST:event_DelWord1ActionPerformed
private void sureDelWord1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sureDelWord1ActionPerformed
DictionaryAction dicAction=new DictionaryAction();
dicAction.setDelWordDic(DelWordDic);
dicAction.setDelWord(DelWord);
try{
if(!dicAction.isExistDelWord().equals("")){
JOptionPane.showMessageDialog(frame1,dicAction.isExistDelWord(),"温馨提示",MessageType);
}
else{
if((!DelWordDic.equals(""))&&(!DelWord.equals(""))){
if(dicAction.deleteWord()){
String print;
print="恭喜你,删除单词完成了!"+"\n"+"已经将单词:"+DelWord+"从"+"\n"+DelWordDic+"中删除了!";
JOptionPane.showMessageDialog(frame1,print,"温馨提示",MessageType);
}
else{
JOptionPane.showMessageDialog(frame1,"请你选择要删除单词的词典!","温馨提示",MessageType);
}
}
AddWordDic="";
NewWord="";
}
}catch(Exception e){}
}//GEN-LAST:event_sureDelWord1ActionPerformed
private void SelectDicToDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectDicToDelActionPerformed
openDialog();
DelWordDic=file.toString();
}//GEN-LAST:event_SelectDicToDelActionPerformed
private void WordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WordActionPerformed
String Message="请输入你想要添加的新单词。";
String Title="添加单词输入";
try{
NewWord=JOptionPane.showInputDialog(frame1,Message,Title,MessageType);
}catch(Exception e){
}
}//GEN-LAST:event_WordActionPerformed
private void sureAddWordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sureAddWordActionPerformed
DictionaryAction dicAction=new DictionaryAction();
dicAction.setSource(AddWordDic);
dicAction.setNewWord(NewWord);
try{
if(!dicAction.isExistWord().equals("")){
JOptionPane.showMessageDialog(frame1,dicAction.isExistWord(),"温馨提示",MessageType);
}
else{
if((!AddWordDic.equals(""))&&(!NewWord.equals(""))){
if(dicAction.addWords()){
String print;
print="恭喜你,添加单词完成了!"+"\n"+"已经将单词:"+NewWord+"添加到"+"\n"+AddWordDic;
JOptionPane.showMessageDialog(frame1,print,"温馨提示",MessageType);
}
else{
JOptionPane.showMessageDialog(frame1,"请你选择要添加单词的词典!","温馨提示",MessageType);
}
}
AddWordDic="";
NewWord="";
}
}catch(Exception e){}
}//GEN-LAST:event_sureAddWordActionPerformed
private void SeletDicToAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SeletDicToAddActionPerformed
openDialog();
AddWordDic=file.toString();
}//GEN-LAST:event_SeletDicToAddActionPerformed
private void SelectDicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectDicActionPerformed
openDialog();
Select=file.toString();
DelDic=file.getName();
}//GEN-LAST:event_SelectDicActionPerformed
private void DelDictionaryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DelDictionaryActionPerformed
EditDictionary editDic=new EditDictionary();
editDic.setDelPath(file);
if((!DelDic.equals(""))&&(!Select.equals(""))){
if(editDic.delDictionary()){
String print;
print="恭喜你,删除词典完成了!"+"\n"+"已经将词典:"+DelDic+"从"+"\n"+Select+"\n"+"中删除了!";
JOptionPane.showMessageDialog(frame1,print,"温馨提示",MessageType);
}
else{
JOptionPane.showMessageDialog(frame1,"请你选择要删除的词典!","温馨提示",MessageType);
}
}
DelDic="";
Select="";
}//GEN-LAST:event_DelDictionaryActionPerformed
private void ExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitActionPerformed
// this.dispose();
this.setVisible(false);
}//GEN-LAST:event_ExitActionPerformed
private void CopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CopyActionPerformed
EditDictionary editDic=new EditDictionary();
editDic.setSource(source);
editDic.setObject(object);
if((!DicName.equals(""))&&(!source.equals(""))&&(!object.equals(""))){
if(editDic.addDictioanry()){
String print;
print="恭喜你,添加词典完成了!"+"\n"+"已经将词典:"+DicName+"从"+"\n"+source+"\n"+"复制到"+"\n"+object;
JOptionPane.showMessageDialog(frame1,print,"温馨提示",MessageType);
}
else{
JOptionPane.showMessageDialog(frame1,"请你选择要添加的词典!","温馨提示",MessageType);
}
}
DicName="";
source="";
object="";
}//GEN-LAST:event_CopyActionPerformed
private void ObjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ObjectActionPerformed
openDialog();
object=file.toString();
}//GEN-LAST:event_ObjectActionPerformed
private void SourceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SourceActionPerformed
openDialog();
source=file.toString();
DicName=file.getName();
}//GEN-LAST:event_SourceActionPerformed
/**
*define a method showDialog
*/
public void openDialog(){
fileChooser1.setCurrentDirectory(new File("."));
fileChooser1.setFileFilter(new javax.swing.filechooser.FileFilter() {
public boolean accept(File f) {
String name=f.getName().toLowerCase();
return f.isFile()||f.isDirectory();
}
public String getDescription() {
return "All files";
}
});
int t=fileChooser1.showOpenDialog(this);
if(t==JFileChooser.APPROVE_OPTION){
//get file's suffix name
file=fileChooser1.getSelectedFile();
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new AddDictionary().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton Copy;
private javax.swing.JButton DelDictionary;
private javax.swing.JButton DelWord1;
private javax.swing.JButton Exit;
private javax.swing.JButton Object;
private javax.swing.JButton SelectDic;
private javax.swing.JButton SelectDicToDel;
private javax.swing.JButton SeletDicToAdd;
private javax.swing.JButton Source;
private javax.swing.JButton Word;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JButton sureAddWord;
private javax.swing.JButton sureDelWord1;
// End of variables declaration//GEN-END:variables
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?