• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

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

发布: 2007-7-14 21:19 | 作者: 佚名    | 来源: 网络转载     | 查看: 398次 | 进入软件测试论坛讨论

领测软件测试网 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: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);
}
}

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网