游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1431|回复: 0

用Java编写的记事本程序2 wxh zt

[复制链接]

1367

主题

1993

帖子

2118

积分

金牌会员

Rank: 6Rank: 6

积分
2118
发表于 2004-12-27 22:36:00 | 显示全部楼层 |阅读模式
/*------------------------------------------------
*
* main
*
*-----------------------------------------------
*/

public static void main(String[] args){
Jsb jsb1=new Jsb();
}
}

/************************************************************
///////////////////////// Event class ///////////////////////
**************************************************************/
class Jsb_frame_closingAdapter extends java.awt.event.WindowAdapter{
Jsb adaptee;
Jsb_frame_closingAdapter(Jsb adaptee){
this.adaptee=adaptee;
}

public void windowClosing(WindowListener e){
adaptee.frame_windowclose_windowClosing(e);
}
}
///////////////////////////////////////////////////////////
class Jsb_text_mouseAdapter extends java.awt.event.MouseAdapter{
Jsb adaptee;
Jsb_text_mouseAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void mouseClicked(MouseEvent e){
adaptee.text_mouseClicked(e);
}
}
class Jsb_text_ancestorAdapter implements javax.swing.event.AncestorListener{
Jsb adaptee;
Jsb_text_ancestorAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void ancestorAdded(AncestorEvent e){
adaptee.text_ancestorAdded(e);
}
public void ancestorRemoved(AncestorEvent e){
}
public void ancestorMoved(AncestorEvent e){
}
}
class Jsb_text_caretAdapter implements javax.swing.event.CaretListener{
Jsb adaptee;
Jsb_text_caretAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void caretUpdate(CaretEvent e){
adaptee.text_caretUpdate(e);
}
}

///////////////////////////////////////////////////////////
class File_open_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
File_open_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.File_open_actionPerformed(e);
}
}

class File_new_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
File_new_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.File_new_actionPerformed(e);
}
}

class File_save_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
File_save_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.File_save_actionPerformed(e);
}
}

class File_saveas_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
File_saveas_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.File_saveas_actionPerformed(e);
}
}
class File_quite_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
File_quite_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.File_quite_actionPerformed(e);

}
}
//////////////////////////////////////////////////////////////
class Edit_undo_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Edit_undo_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Edit_undo_actionPerformed(e);
}
}

class Edit_cut_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Edit_cut_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Edit_cut_actionPerformed(e);
}
}

class Edit_copy_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Edit_copy_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Edit_copy_actionPerformed(e);
}
}

class Edit_paste_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Edit_paste_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Edit_paste_actionPerformed(e);
}
}

class Edit_delete_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Edit_delete_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Edit_delete_actionPerformed(e);
}
}

class Edit_find_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Edit_find_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Edit_find_actionPerformed(e);
}
}

class Edit_replace_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Edit_replace_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Edit_replace_actionPerformed(e);
}
}

class Edit_selectall_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Edit_selectall_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Edit_selectall_actionPerformed(e);
}
}

class Edit_timedate_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Edit_timedate_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Edit_timedate_actionPerformed(e);
}
}
/////////////////////////////////////////////////////////////
class Format_word_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Format_word_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Format_word_actionPerformed(e);
}
}

class Format_font_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Format_font_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Format_font_actionPerformed(e);
}
}

class Format_color_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Format_color_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Format_color_actionPerformed(e);
}
}
///////////////////////////////////////////////////////////////

class Help_about_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Help_about_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.Help_about_actionPerformed(e);
}
}

///////////////////////////////////////////////////////////
class Pop_undo_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Pop_undo_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.pop_undo_actionPerformed(e);
}
}

class Pop_cut_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Pop_cut_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.pop_cut_actionPerformed(e);
}
}

class Pop_copy_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Pop_copy_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.pop_copy_acionPerformed(e);
}
}

class Pop_paste_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Pop_paste_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.pop_paste_actionPerformed(e);
}
}

class Pop_delete_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Pop_delete_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.pop_delete_actionPerformed(e);
}
}

/******************* Event class end **********************************/
/*************************************************************
* title: DlgText.java
* author: jeason
* date: 2004-12-21
**************************************************************/
package jeason;

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

public class Dlgtext extends JDialog{
private boolean check=false;

JLabel text=new JLabel( );
JButton btnOk=new JButton( );
JButton btnNo=new JButton( );

FlowLayout flowLayout1=new FlowLayout();

Dlgtext(){
this(null,"",false);
}

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

text.setText(" 你要保存吗? ");
text.setSize(200,60);

this.setSize(200,80);
this.setModal(true);

btnOk.setText("确定(Y)");
btnOk.setMnemonic(´Y´);
btnOk.setSize(100,20);
btnOk.addActionListener(new btnOk_actionAdapter(this));


btnNo.setText("取消(N)");
btnNo.setMnemonic(´N´);
btnNo.setSize(100,20);
btnNo.addActionListener(new btnNo_actionAdapter(this));


this.getContentPane().setLayout(flowLayout1);
this.getContentPane().add(text,flowLayout1);
this.getContentPane().add(btnOk,flowLayout1);
this.getContentPane().add(btnNo,flowLayout1);


}
void btnOk_actionPerformed(ActionEvent e){
this.check=true;
this.dispose();
this.hide();
}
void btnNo_actionPerformed(ActionEvent e){
this.check=false;
this.dispose();
this.hide();
}
public boolean getCheck(){
return this.check;
}

}

class btnOk_actionAdapter implements java.awt.event.ActionListener{
Dlgtext adaptee;
btnOk_actionAdapter(Dlgtext adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.btnOk_actionPerformed(e);
}
}

class btnNo_actionAdapter implements java.awt.event.ActionListener{
Dlgtext adaptee;
btnNo_actionAdapter(Dlgtext adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.btnNo_actionPerformed(e);
}
}
/******************************************************
*-----------------------------------------------------
* FindDlg.java
* jeason
* 04-12-23 2:19
*-----------------------------------------------------
*****************************************************/

package jeason;

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

public class FindDlg extends JDialog{

private String findstr;
private boolean flag=true;

JLabel findText=new JLabel("查找内容");
JTextField strText=new JTextField(" ");
JButton btnNext=new JButton( );
JButton btnUp=new JButton( );

FlowLayout flowLayout1=new FlowLayout();

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

this.setTitle("查找");
this.setSize(200,90);
this.setModal(true);

findText.setText(" 查找内容 ");
findText.setSize(70,60);

strText.setText(" ");
strText.setSize(130,60);

btnNext.setText("向下查找");
btnNext.setSize(100,40);
btnNext.addActionListener(new btnNext_actionAdapter(this));

btnUp.setText("向上查找");
btnUp.setSize(100,40);
btnUp.addActionListener(new btnUp_actionAdapter(this));

this.getContentPane().setLayout(flowLayout1);
this.getContentPane().add(this.findText,flowLayout1);
this.getContentPane().add(this.strText,flowLayout1);
this.getContentPane().add(this.btnNext,flowLayout1);
this.getContentPane().add(this.btnUp,flowLayout1);
}
FindDlg(){
this(null,"",false);
}

public void btnNext_actionPerformed(ActionEvent e){
this.findstr=this.strText.getText();
this.flag=true;
this.dispose();
}
public void btnUp_actionPerformed(ActionEvent e){
this.findstr=this.strText.getText();
this.flag=false;
this.dispose();
}
public String getFindStr(){
return this.findstr;
}
public boolean getFlag(){
return this.flag;
}
}
class btnNext_actionAdapter implements java.awt.event.ActionListener{
FindDlg adaptee;
btnNext_actionAdapter(FindDlg adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.btnNext_actionPerformed(e);
}
}

class btnUp_actionAdapter implements java.awt.event.ActionListener{
FindDlg adaptee;
btnUp_actionAdapter(FindDlg adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.btnUp_actionPerformed(e);
}
}


/******************************************************
*-----------------------------------------------------
* FontSet.java
* jeason
* 04-12-23 2:19
*-----------------------------------------------------
*****************************************************/

package jeason;

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

public class FontSet extends JDialog{

//JPanel panel1 = new JPanel();
private String font1="";
JLabel txtStr=new JLabel("请选择字体");
JLabel txt2=new JLabel("请选择字型");
List list1 = new List(3,false);
List list2 = new List(3,false);

JButton btnOk=new JButton("确定");
JButton btnNo=new JButton("撤销");
FlowLayout flowLayout1=new FlowLayout();

boolean flag=true;
int type;

FontSet(Frame frame,String title,boolean modal){
this.setTitle("字体设置");
this.setSize(200,230);
this.setModal(true);

txtStr.setSize(100,60);


list1.setSize(100,60);
list1.setMultipleMode(false);

this.txt2.setSize(100,60);

list2.setSize(100,60);

btnOk.setMnemonic(´Y´);
btnOk.setSize(100,20);
btnOk.addActionListener(new btnOk_actionAdapter(this));


//btnNo.setText("取消(N)");
btnNo.setMnemonic(´N´);
btnNo.setSize(100,20);
btnNo.addActionListener(new btnNo_actionAdapter(this));


///////////// Font //////////////////////////////////

GraphicsEnvironment gl=GraphicsEnvironment.getLocalGraphicsEnvironment();
String fontName[]=gl.getAvailableFontFamilyNames();
// int fontX[]={Font.BOLD,Font.ITALIC,Font.PLAIN};


for(int i=0;i<fontName.length;i++){
list1.add(fontName);
}
String fontx[]={"常规","斜体","粗体","粗斜体"};
for(int i=0;i<fontx.length;i++){
list2.add(fontx);
}

list1.select(0);
list2.select(0);
///////////////////////////////////////////////

this.getContentPane().setLayout(flowLayout1);

this.getContentPane().add(txtStr,flowLayout1);
this.getContentPane().add(list1,flowLayout1);
this.getContentPane().add(this.txt2,flowLayout1);
this.getContentPane().add(this.list2,flowLayout1);
this.getContentPane().add(btnOk,flowLayout1);
this.getContentPane().add(btnNo,flowLayout1);
}
FontSet(){
this(null,"",false);
}
void btnOk_actionPerformed(ActionEvent e){
this.flag=true;
this.font1=this.list1.getSelectedItem();
this.type=this.list2.getSelectedIndex();
this.dispose();
}
void btnNo_actionPerformed(ActionEvent e){
this.flag=false;
this.dispose();
}

public String font1(){
return this.font1;
}
public int font2(){

return this.type;
}
}

class btnOk_actionAdapter implements java.awt.event.ActionListener{
FontSet adaptee;
btnOk_actionAdapter(FontSet adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.btnOk_actionPerformed(e);
}
}

class btnNo_actionAdapter implements java.awt.event.ActionListener{
FontSet adaptee;
btnNo_actionAdapter(FontSet adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(ActionEvent e){
adaptee.btnNo_actionPerformed(e);
}
}

/**************************************************************
*-------------------------------------------------------------
* ReplaceDlg.java
* jeason
* 04-12-23
*-------------------------------------------------------------
**************************************************************/

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);
}
}

/*********************************************
*------------------------------------------
* AboutDlg.java
* jeason
*----------------------------------------------
*********************************************/

package jeason;

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

public class AboutDlg extends JFrame{

JLabel text=new JLabel("");
JLabel bar=new JLabel("");

final BorderLayout borderLayout1=new BorderLayout();

AboutDlg(){
super();
this.setSize(300,150);
this.setTitle("~关于作者~");
text.setText("本记事本作者:杨勇\r\n\r\n"+"E-mail:yangyong@ccsu.cn\r\n");
bar.setText("本软件由JCreator 2.5开发");
JPanel jPanel=new JPanel();
jPanel.setLayout(borderLayout1);
jPanel.add(text,borderLayout1.CENTER);
jPanel.add(bar,borderLayout1.SOUTH);

this.getContentPane().add(jPanel);

this.setVisible(true);
}

}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-23 20:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表