replacedlg.java

来自「程序的功能与微软的记事本功能差不多」· Java 代码 · 共 65 行

JAVA
65
字号
package jeason; 

import java.awt.*; 
import java.awt.event.*; 
import javax.swing.*; 

public class ReplaceDlg extends JDialog{ 

private String findStr="",replaceStr=""; 
/////////////////////////////////////// 
JLabel txt1=new JLabel("查找:"); 
JLabel txt2=new JLabel("替换为:"); 
JTextField txtFind=new JTextField(" "); 
JTextField txtReplace=new JTextField(" "); 
JButton btn=new JButton("替换"); 
FlowLayout flowLayout1=new FlowLayout(); 

ReplaceDlg(Frame frame,String title,boolean modal){ 
super(frame,title,modal); 

this.setTitle("替换为"); 
this.setSize(200,90); 
this.setModal(true); 

txt1.setSize(40,60); 
txt2.setSize(40,60); 
txtFind.setSize(50,60); 
txtReplace.setSize(50,60); 

btn.setSize(200,20); 
btn.addActionListener(new btn_actionAdapter(this)); 

this.getContentPane().setLayout(flowLayout1); 
this.getContentPane().add(txt1,flowLayout1); 
this.getContentPane().add(this.txtFind,flowLayout1); 
this.getContentPane().add(this.txt2,flowLayout1); 
this.getContentPane().add(this.txtReplace,flowLayout1); 
this.getContentPane().add(this.btn,flowLayout1); 

} 
ReplaceDlg(){ 
this(null,"",false); 
} 
public void btn_actionPerformed(ActionEvent e){ 
this.findStr=this.txtFind.getText(); 
this.replaceStr=this.txtReplace.getText(); 
this.dispose(); 
} 
public String findStr(){ 
return this.findStr; 
} 
public String replaceStr(){ 
return this.replaceStr; 
} 

} 
class btn_actionAdapter implements java.awt.event.ActionListener{ 
ReplaceDlg adaptee; 
btn_actionAdapter(ReplaceDlg adaptee){ 
this.adaptee=adaptee; 
} 
public void actionPerformed(ActionEvent e){ 
adaptee.btn_actionPerformed(e); 
} 
} 

⌨️ 快捷键说明

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