- //search.java
- package abc.jdm;
- import java.awt.*;
- import abc.jdm.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.border.Border;
- public class search{
- JLabel searchlabel=new JLabel("查找(S)"),replace=new JLabel("替换(R)");
- JButton okbutton=new JButton("确定"),cancelbutton=new JButton("取消");
- JTextField oldstring=new JTextField(10),newstring=new JTextField(10);
- public search(){
- JFrame f=new JFrame("查找与替换");
- searchlabel.setSize(20,20);
- f.setLayout(new GridLayout(3,2));
- f.add(searchlabel);
- okbutton.setSize(10, 10);
- //okbutton.setLocation(60, 10);
- f.add(oldstring);
- f.add(replace);
- f.add(newstring);
- f.add(okbutton);
- okbutton.addActionListener(new replace());
- f.add(cancelbutton);
- f.setSize(250, 100);
- f.setLocation(10, 10);
- f.setVisible(true);
- f.setResizable(false);
- //JFramesetResizable(false)方法可以禁用缩放,
- f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- cancelbutton.addActionListener(new cancelbutton());
- }
- }
- class cancelbutton implements ActionListener{
- public void actionPerformed(ActionEvent e){
- System.exit(0);
- }
- }
- class replace implements ActionListener{
- public void actionPerformed(ActionEvent e){
- /*String oldstr=oldstring.getText();
- String newstr=newstring.getText();
- int result=(mytext.getText().indexOf(oldstr));
- if(result!=0){
- }*/
- }
- }
java 记事本本源代码.
最新推荐文章于 2024-08-23 15:54:50 发布