⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wengdr.java

📁 简单文本编辑器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        txt6.setText("");
    replace.dispose();
   }
  });  
  button_2.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e){
          txt5.setText("");
          txt6.setText("");
   }
  });
 }
 //查找
 public void search_dialog(){
  search.setSize(300,100);
  search.setResizable(false);
  search.setBackground(Color.orange);
  search.setLayout(new FlowLayout());
  Label label_1=new Label("查找");
  Button button_1=new Button(" 确定 ");
  Button button_3=new Button(" 退出 ");
  Button button_2=new Button("查找下一个");
  search.add(label_1);
  search.add(txt4);
  search.add(button_1);
  search.add(button_2);
  search.add(button_3);
  button_1.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e){
     if(txt4.getText()=="");
    else{
     int locate=textarea.getText().indexOf(txt4.getText(),0);
     textarea.select(locate,locate+txt4.getText().length());
     fromindex=locate+txt4.getText().length();
    }
   }
  });
  button_3.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e){
          search.dispose();
          fromindex=0; 
          txt4.setText("");
   }
  });
  button_2.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e){
    
    int locate=textarea.getText().indexOf(txt4.getText(),fromindex);
    if(locate==-1)txt4.setText("sorry,找不到你要求的字符串!");
    else{
     textarea.select(locate,locate+txt4.getText().length());
     fromindex=locate+txt4.getText().length();
     
   }  
   }
  });
  
 }

 //字体设置
     public void Dialog_Word(){
     
  Button button1=new Button("确定");
  Button button2=new Button("取消");
  
  Word.setSize(400,350);
  Word.setResizable(false);
  Word.setLayout(new FlowLayout());
  Word.add(new Label("字体            "));
  Word.add(new Label("          字形      "));
  Word.add(new Label("                大小"));
  Word.add(txt1);
  Word.add(txt2);
  Word.add(txt3);
 
  list1.add("宋体");
  list1.add("隶书");
  list1.add("幼圆");
  list1.add("Rockwell");
  list1.add("TimesRoman");
  list1.add("Impact");
  list1.add("@Batang");
  list1.add("@Fixedsys");
  list1.add("华文行楷");
  list1.add("华文彩云");
  list1.add("Arial");
  list1.add("Courier");
  list1.addItemListener(new ItemListener(){
   public void itemStateChanged(ItemEvent e){
    int name_choice=list1.getSelectedIndex();
       switch(name_choice){
        case 0:{tempname="宋体";txt1.setText("宋体");break;}
           case 1:{tempname="隶书";txt1.setText("隶书");break;}
        case 2:{tempname="幼圆";txt1.setText("幼圆");break;}
        case 3:{tempname="Rockwell";txt1.setText("Rockwell");break;}
        case 4:{tempname="TimesRoman";txt1.setText("TimesRoman");break;}
        case 5:{tempname="Impact";txt1.setText("Impact");break;}
        case 6:{tempname="@Batang";txt1.setText("@Batang");break;}
        case 7:{tempname="@Fixedsys";txt1.setText("@Fixedsys");break;}
        case 8:{tempname="华文行楷";txt1.setText("华文行楷");break; }
        case 9:{tempname="华文彩云";txt1.setText("华文彩云");break; }
        case 10:{tempname="Arial";txt1.setText("Arial");break; }
        case 11:{tempname="Courier";txt1.setText("Courier");break; }
       }
      }
  });
  Word.add(list1);
  list2.add("常规");
  list2.add("斜体");
  list2.add("粗体");
  list2.add("粗斜体");
  list2.addItemListener(new ItemListener(){
   public void itemStateChanged(ItemEvent e){
    int style_choice=list2.getSelectedIndex();
    switch(style_choice){
     case 0:{tempstyle=Font.PLAIN;txt2.setText("常规");break;}
     case 1:{tempstyle=Font.ITALIC;txt2.setText("斜体");break;}
     case 2:{tempstyle=Font.BOLD;txt2.setText("粗体");break;}
     case 3:{tempstyle=Font.BOLD+Font.ITALIC;txt2.setText("粗斜体");break;} 
    }
   }
  });
  Word.add(list2);
  list3.addItem("16");
  list3.addItem("18");
  list3.addItem("20");
  list3.addItem("22");
  list3.addItem("24");
  list3.addItem("26");
  list3.addItem("28");
  list3.addItem("30");
  list3.addItem("35");
  list3.addItem("40");
  list3.addItem("45");
  list3.addItem("50");
  list3.addItem("55");
  list3.addItem("60");
  list3.addItemListener(new ItemListener(){
   public void itemStateChanged(ItemEvent e){
    int size_choiced=list3.getSelectedIndex();
    switch(size_choiced){
     case 0:{tempsize=16;txt3.setText("16");break;}
     case 1:{tempsize=18;txt3.setText("18");break;}
     case 2:{tempsize=20;txt3.setText("20");break;}
     case 3:{tempsize=22;txt3.setText("22");break;}
     case 4:{tempsize=24;txt3.setText("24");break;}
     case 5:{tempsize=26;txt3.setText("26");break;}
     case 6:{tempsize=28;txt3.setText("28");break;}
     case 8:{tempsize=30;txt3.setText("30");break;}
     case 9:{tempsize=35;txt3.setText("35");break;}
     case 10:{tempsize=40;txt3.setText("40");break;}
     case 11:{tempsize=45;txt3.setText("45");break;}
     case 12:{tempsize=50;txt3.setText("50");break;}
     case 13:{tempsize=55;txt3.setText("55");break;}
     case 14:{tempsize=60;txt3.setText("60");break;} 
    }
   }
  });
  Word.add(list3);
  choice.addItem("red");
  choice.addItem("blue");
  choice.addItem("green");
  choice.addItem("black");
  choice.addItem("yellow");
  choice.addItemListener(new ItemListener(){
   public void itemStateChanged(ItemEvent e){
    int color_choiced=choice.getSelectedIndex();
    switch(color_choiced){
     case 0:{tempcolor=Color.red;break;}
     case 1:{tempcolor=Color.blue;break;}
     case 2:{tempcolor=Color.green;break;}
     case 3:{tempcolor=Color.green;break;}
     case 4:{tempcolor=Color.green;break;}
    }
   }
  });
  Word.add(new Label("颜色"));
     Word.add(choice);
     Word.add(new Label("   示例  "));
     Word.add(label);
     //setColor(tempcolor);
     label.setFont(new Font(tempname,tempstyle,tempsize));
     label.repaint();
     Word.add(label);
     button1.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
       Word.dispose();
       name=tempname;
       style=tempstyle;
       size=tempsize;
       color=tempcolor;
       Font font=new Font(name,style,size);
       textarea.setFont(font);
          //setColor(color); 
      }
     });
     button2.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
       Word.dispose();
       //setColor(color);
       Font font=new Font(name,style,size);
       textarea.setFont(font);
      }
     });
     Word.add(button1);
     Word.add(button2);
 }
 ////关于作者
 public void Dialog_aboutAuthor(){
  Button button=new Button("确定");
  aboutAuthor.setSize(400,300);
  aboutAuthor.setResizable(false);
  aboutAuthor.setBackground(Color.GREEN);
  aboutAuthor.setLayout(new FlowLayout());
  aboutAuthor.add(new Label("学号:5205111241  姓名:朱慧君"));
  aboutAuthor.add(new Label("QQ:564549024 EMail:pigpig.orange@yahoo.com"));
  aboutAuthor.add(new Label("Address:东港学院2#604"));
  aboutAuthor.add(new Label("PostCode:222200"));
  
  aboutAuthor.add(new Label("                                                              "));
  aboutAuthor.add(new Label("*************************************************** "));
     button.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
       aboutAuthor.dispose();
      }
     });
     aboutAuthor.add(button);
 }
 ///关于记事本
 public void Dialog_aboutNotepad(){
  Button button=new Button("确定");
  aboutNotepad.setSize(300,200);
  aboutNotepad.setBackground(Color.BLUE);
  aboutNotepad.setResizable(false);
  aboutNotepad.setLayout(new FlowLayout());
  aboutNotepad.add(new Label("Wengdr_NotePad简易版"));
  aboutNotepad.add(new Label("版本号:1.0.1  版权:朱慧君"));
  aboutNotepad.add(new Label("本产品是共享程序,欢迎大家使用,并提出你的宝贵意见"));
  aboutNotepad.add(new Label("*******************"));
     button.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
       aboutNotepad.dispose();
      }
     });
     aboutNotepad.add(button);
 }
 //设置窗口的大小
 public Dimension getPreferredSize(){
  return new Dimension(800,600);
 }
 //main()函数
 public static void main(String[] arg){
  Wengdr nowframe=new Wengdr("copyright:朱慧君");
  nowframe.addWindowListener(new WindowAdapter(){
   public void windowClosing(WindowEvent e){
    System.exit(0);
   }
  });
  nowframe.pack();
  nowframe.show();
 } 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -