首页 | 注册 | 登陆
首页 >> 技术专栏 >> java文章 >> Applet/Swing 

用Java编写的记事本程序(3)


作者爱心 来源爱心 加入时间:2006年01月26日
摘要:
用Java编写的记事本程序(3)
class Pop_undo_actionAdapter implements java.awt.event.ActionListener{
Jsb adaptee;
Pop_undo_actionAdapter(Jsb adaptee){
this.adaptee=adaptee;
}
public void actionPerformed(Ac…

转载:转载请保留本信息,本文来自
http://www.51dibs.com
/html/2006/article/info/a_05ac37194f506b0c.htm




用Java编写的记事本程序(3)


站点:爱心种子小博士 关键字:用Java编写的记事本程序(3)




用Java编写的记事本程序(3)
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[i]);
}
String fontx[]={"常规","斜体","粗体","粗斜体"};
for(int i=0;i<fontx.length;i++){
list2.add(fontx[i]);
}

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:[email protected]\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);
}
}



发布人:love
→ 推荐给我的好友 → 报告错误链接
上篇文章:用Java编写的记事本程序(2)
下篇文章:这是个用APPLET发送E-MAIL的源代码
〖文章打印〗
〖关闭窗口〗
发表评论
查看评论
中“用Java编写的记事本程序(3)”相关内容 中“用Java编写的记事本程序(3)”相关内容
中“用Java编写的记事本程序(3)”相关内容 中“用Java编写的记事本程序(3)”相关内容
中“用Java编写的记事本程序(3)”相关内容 中“用Java编写的记事本程序(3)”相关内容

关于我们网站留言友情链接与我在线与我聊天领取红包管理TOP