189 8069 5689

安卓日记本java源代码 android我的日记代码

如何把记事本文件变成JAVA源文件

1、打开电脑,首先点击开始按钮选择打开记事本选项按钮。

创新互联-专业网站定制、快速模板网站建设、高性价比浚县网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式浚县网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖浚县地区。费用合理售后完善,十年实体公司更值得信赖。

2、记事本页面后写好代码之后,点击左上角的文件选项按钮。

3、写好之后点击文件下的保存选项按钮

4、这时候就要文件名的后缀改成java

5、改好之后点击保存,之后就可以变成JAVA源文件了。

用Java编写简易记事本源代码

importjava.awt.BorderLayout;importjava.awt.Container;importjava.awt.Font;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.InputEvent;importjava.awt.event.KeyAdapter;importjava.awt.event.KeyEvent;importjava.awt.event.MouseAdapter;importjava.awt.event.MouseEvent;importjava.awt.event.WindowAdapter;importjava.awt.event.WindowEvent;importjava.io.BufferedReader;importjava.io.BufferedWriter;importjava.io.File;importjava.io.FileReader;importjava.io.FileWriter;importjava.io.IOException;importjavax.swing.BorderFactory;importjavax.swing.JFileChooser;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JMenu;importjavax.swing.JMenuBar;importjavax.swing.JMenuItem;importjavax.swing.JOptionPane;importjavax.swing.JPopupMenu;importjavax.swing.JScrollPane;importjavax.swing.JTextArea;importjavax.swing.KeyStroke;importjavax.swing.ScrollPaneConstants;importjavax.swing.SwingConstants;publicclassJNotePadUIextendsJFrame{privateJMenuItemmenuOpen;privateJMenuItemmenuSave;privateJMenuItemmenuSaveAs;privateJMenuItemmenuClose;privateJMenueditMenu;privateJMenuItemmenuCut;privateJMenuItemmenuCopy;privateJMenuItemmenuPaste;privateJMenuItemmenuAbout;privateJTextAreatextArea;privateJLabelstateBar;privateJFileChooserfileChooser;privateJPopupMenupopUpMenu;publicJNotePadUI(){super("新建文本文件");setUpUIComponent();setUpEventListener();setVisible(true);}privatevoidsetUpUIComponent(){setSize(640,480);//菜单栏JMenuBarmenuBar=newJMenuBar();//设置「文件」菜单JMenufileMenu=newJMenu("文件");menuOpen=newJMenuItem("打开");//快捷键设置menuOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,InputEvent.CTRL_MASK));menuSave=newJMenuItem("保存");menuSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK));menuSaveAs=newJMenuItem("另存为");menuClose=newJMenuItem("关闭");menuClose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,InputEvent.CTRL_MASK));fileMenu.add(menuOpen);fileMenu.addSeparator();//分隔线fileMenu.add(menuSave);fileMenu.add(menuSaveAs);fileMenu.addSeparator();//分隔线fileMenu.add(menuClose);//设置「编辑」菜单JMenueditMenu=newJMenu("编辑");menuCut=newJMenuItem("剪切");menuCut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_MASK));menuCopy=newJMenuItem("复制");menuCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_MASK));menuPaste=newJMenuItem("粘贴");menuPaste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,InputEvent.CTRL_MASK));editMenu.add(menuCut);editMenu.add(menuCopy);editMenu.add(menuPaste);//设置「关于」菜单JMenuaboutMenu=newJMenu("关于");menuAbout=newJMenuItem("关于JNotePad");aboutMenu.add(menuAbout);menuBar.add(fileMenu);menuBar.add(editMenu);menuBar.add(aboutMenu);setJMenuBar(menuBar);//文字编辑区域textArea=newJTextArea();textArea.setFont(newFont("宋体",Font.PLAIN,16));textArea.setLineWrap(true);JScrollPanepanel=newJScrollPane(textArea,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);ContainercontentPane=getContentPane();contentPane.add(panel,BorderLayout.CENTER);//状态栏stateBar=newJLabel("未修改");stateBar.setHorizontalAlignment(SwingConstants.LEFT);stateBar.setBorder(BorderFactory.createEtchedBorder());contentPane.add(stateBar,BorderLayout.SOUTH);popUpMenu=editMenu.getPopupMenu();fileChooser=newJFileChooser();}privatevoidsetUpEventListener(){//按下窗口关闭钮事件处理addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){closeFile();}});//菜单-打开menuOpen.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){openFile();}});//菜单-保存menuSave.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){saveFile();}});//菜单-另存为menuSaveAs.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){saveFileAs();}});//菜单-关闭文件menuClose.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){closeFile();}});//菜单-剪切menuCut.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){cut();}});//菜单-复制menuCopy.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){copy();}});//菜单-粘贴menuPaste.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){paste();}});//菜单-关于menuAbout.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){//显示对话框JOptionPane.showOptionDialog(null,"程序名称:\nJNotePad\n"+"程序设计:\n\n"+"简介:\n一个简单的文字编辑器\n"+"可作为验收Java的实现对象\n"+"欢迎网友下载研究交流\n\n"+"/","关于JNotePad",JOptionPane.DEFAULT_OPTION,JOptionPane.INFORMATION_MESSAGE,null,null,null);}});//编辑区键盘事件textArea.addKeyListener(newKeyAdapter(){publicvoidkeyTyped(KeyEvente){processTextArea();}});//编辑区鼠标事件textArea.addMouseListener(newMouseAdapter(){publicvoidmouseReleased(MouseEvente){if(e.getButton()==MouseEvent.BUTTON3)popUpMenu.show(editMenu,e.getX(),e.getY());}publicvoidmouseClicked(MouseEvente){if(e.getButton()==MouseEvent.BUTTON1)popUpMenu.setVisible(false);}});}privatevoidopenFile(){if(isCurrentFileSaved()){//文件是否为保存状态open();//打开}else{//显示对话框intoption=JOptionPane.showConfirmDialog(null,"文件已修改,是否保存?","保存文件?",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE,null);switch(option){//确认文件保存caseJOptionPane.YES_OPTION:saveFile();//保存文件break;//放弃文件保存caseJOptionPane.NO_OPTION:open();break;}}}privatebooleanisCurrentFileSaved(){if(stateBar.getText().equals("未修改")){returnfalse;}else{returntrue;}}privatevoidopen(){//fileChooser是JFileChooser的实例//显示文件选取的对话框intoption=fileChooser.showDialog(null,null);//使用者按下确认键if(option==JFileChooser.APPROVE_OPTION){try{//开启选取的文件BufferedReaderbuf=newBufferedReader(newFileReader(fileChooser.getSelectedFile()));//设定文件标题setTitle(fileChooser.getSelectedFile().toString());//清除前一次文件textArea.setText("");//设定状态栏stateBar.setText("未修改");//取得系统相依的换行字符StringlineSeparator=System.getProperty("line.separator");//读取文件并附加至文字编辑区Stringtext;while((text=buf.readLine())!=null){textArea.append(text);textArea.append(lineSeparator);}buf.close();}catch(IOExceptione){JOptionPane.showMessageDialog(null,e.toString(),"开启文件失败",JOptionPane.ERROR_MESSAGE);}}}privatevoidsaveFile(){//从标题栏取得文件名称Filefile=newFile(getTitle());//若指定的文件不存在if(!file.exists()){//执行另存为saveFileAs();}else{try{//开启指定的文件BufferedWriterbuf=newBufferedWriter(newFileWriter(file));//将文字编辑区的文字写入文件buf.write(textArea.getText());buf.close();//设定状态栏为未修改stateBar.setText("未修改");}catch(IOExceptione){JOptionPane.showMessageDialog(null,e.toString(),"写入文件失败",JOptionPane.ERROR_MESSAGE);}}}privatevoidsaveFileAs(){//显示文件对话框intoption=fileChooser.showSaveDialog(null);//如果确认选取文件if(option==JFileChooser.APPROVE_OPTION){//取得选择的文件Filefile=fileChooser.getSelectedFile();//在标题栏上设定文件名称setTitle(file.toString());try{//建立文件file.createNewFile();//进行文件保存saveFile();}catch(IOExceptione){JOptionPane.showMessageDialog(null,e.toString(),"无法建立新文件",JOptionPane.ERROR_MESSAGE);}}}privatevoidcloseFile(){//是否已保存文件if(isCurrentFileSaved()){//释放窗口资源,而后关闭程序dispose();}else{intoption=JOptionPane.showConfirmDialog(null,"文件已修改,是否保存?","保存文件?",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE,null);switch(option){caseJOptionPane.YES_OPTION:saveFile();break;caseJOptionPane.NO_OPTION:dispose();}}}privatevoidcut(){textArea.cut();stateBar.setText("已修改");popUpMenu.setVisible(false);}privatevoidcopy(){textArea.copy();popUpMenu.setVisible(false);}privatevoidpaste(){textArea.paste();stateBar.setText("已修改");popUpMenu.setVisible(false);}privatevoidprocessTextArea(){stateBar.setText("已修改");}publicstaticvoidmain(String[]args){newJNotePadUI();}}

java记事本源代码

给你个做好了的Java的源程序的记事本,自己看看就行了的,不怎么难的···

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import javax.swing.*;

public class MyNotepad implements ActionListener{

private JFrame frame=new JFrame("新记事本");

private JTextArea jta=new JTextArea();

private String result="";

private boolean flag=true;

private File f;

private JButton jb=new JButton("开始");

private JTextField jtf=new JTextField(15);

private JTextField jt=new JTextField(15);

private JButton jbt=new JButton("替换为");

private JButton jba=new JButton("全部替换");

private Icon ic=new ImageIcon("D:\\java课堂笔记\\GUI\\11.gif");

private String value;

private int start=0;

private JFrame jf=new JFrame("查找");

private JFrame jfc=new JFrame("替换");

@Override

public void actionPerformed(ActionEvent e) {

String comm=e.getActionCommand();

if("新建".equals(comm)){

if(!(frame.getTitle().equals("新记事本"))){

if(!flag){

write();

newNew();

}else{

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

}

}

}else if(!(jta.getText().isEmpty())){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

newNew();

}

}else{

newNew();

}

}else if("打开".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

jfc.setDialogType(JFileChooser.OPEN_DIALOG);

int returnVal = jfc.showOpenDialog(null);

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

frame.setTitle(f.getName());

result=read();

flag=false;

value=result;

jta.setText(result);

}

}else if("保存".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

if(flag){

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

}

}else{

write();

}

}else if("另存".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"另存");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

write();

}

}else if("退出".equals(comm)){

System.exit(0);

}else if("撤销".equals(comm)){

jta.setText(value);

}else if("剪切".equals(comm)){

value=jta.getText();

jta.cut();

}else if("复制".equals(comm)){

jta.copy();

}else if("粘贴".equals(comm)){

value=jta.getText();

jta.paste();

}else if("删除".equals(comm)){

value=jta.getText();

jta.replaceSelection(null);

}else if("全选".equals(comm)){

jta.selectAll();

}else if("查找".equals(comm)){

value=jta.getText();

jf.add(jtf,BorderLayout.CENTER);

jf.add(jb,BorderLayout.SOUTH);

jf.setLocation(300,300);

jf.pack();

jf.setVisible(true);

jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}else if("替换".equals(comm)){

value=jta.getText();

GridLayout gl=new GridLayout(3,3);

JLabel jl1=new JLabel("查找内容:");

JLabel jl2=new JLabel("替换为:");

jfc.setLayout(gl);

jfc.add(jl1);

jfc.add(jtf);

jfc.add(jb);

jfc.add(jl2);

jfc.add(jt);

jfc.add(jbt);

JLabel jl3=new JLabel();

JLabel jl4=new JLabel();

jfc.add(jl3);

jfc.add(jl4);

jfc.add(jba);

jfc.setLocation(300,300);

jfc.pack();

jfc.setVisible(true);

jfc.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}else if("版本".equals(comm)){

JDialog jd=new JDialog(frame,"关于对话框");

jd.setSize(200,200);

JLabel l=new JLabel("哈哈哈哈哈哈哈哈哈哈呵呵呵呵呵呵呵呵呵呵呵呵呵");

jd.add(l,BorderLayout.CENTER);

jd.setLocation(100,200);

jd.setSize(300,300);

jd.setVisible(true);

// jd.pack();

jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

}else if("开始".equals(comm)||"下一个".equals(comm)){

String temp=jtf.getText();

int s=value.indexOf(temp,start);

if(value.indexOf(temp,start)!=-1){

jta.setSelectionStart(s);

jta.setSelectionEnd(s+temp.length());

jta.setSelectedTextColor(Color.GREEN);

start=s+1;

jb.setText("下一个");

// value=value.substring(s+temp.length());//不能截取字串

}else {

JOptionPane.showMessageDialog(jf, "查找完毕!", "提示", 0, ic);

jf.dispose();

}

}else if("替换为".equals(comm)){

String temp=jtf.getText();

int s=value.indexOf(temp,start);

if(value.indexOf(temp,start)!=-1){

jta.setSelectionStart(s);

jta.setSelectionEnd(s+temp.length());

jta.setSelectedTextColor(Color.GREEN);

start=s+1;

jta.replaceSelection(jt.getText());

}else {

JOptionPane.showMessageDialog(jf, "查找完毕!", "提示", 0, ic);

jf.dispose();

}

}else if("全部替换".equals(comm)){

String temp=jta.getText();

temp=temp.replaceAll(jtf.getText(), jt.getText());

jta.setText(temp);

}

}

public String read(){

String temp="";

try {

FileInputStream fis = new FileInputStream(f.getAbsolutePath());

byte[] b=new byte[1024];

while(true){

int num=fis.read(b);

if(num==-1)break;

temp=temp+new String(b,0,num);

}

fis.close();

} catch (Exception e1) {

e1.printStackTrace();

}

return temp;

}

public void write(){

try {

FileOutputStream fos=new FileOutputStream(f);

fos.write(jta.getText().getBytes());

fos.close();

} catch (Exception e) {

e.printStackTrace();

}

}

public void newNew(){

frame.dispose();

new MyNotepad();

flag=true;

}

public MyNotepad(){

JMenuBar jmb=new JMenuBar();

String[] menuLab={"文件","编辑","帮助"};

String[][] menuItemLab={{"新建","打开","保存","另存","退出"},

{"撤销","剪切","复制","粘贴","删除","全选","查找","替换"},

{"版本"}};

for(int i=0;imenuLab.length;i++){

JMenu menu=new JMenu(menuLab[i]);

jmb.add(menu);

for(int j=0;jmenuItemLab[i].length;j++){

JMenuItem jmi=new JMenuItem(menuItemLab[i][j]);

menu.add(jmi);

jmi.addActionListener(this);

}

}

frame.setJMenuBar(jmb);

jta.setLineWrap(true);//自动换行

JScrollPane jsp=new JScrollPane(jta);//滚动窗口面板

frame.add(jsp);

jb.addActionListener(this);

jbt.addActionListener(this);

jba.addActionListener(this);

frame.setLocation(200,50);

frame.setSize(620,660);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String[] args) {

new MyNotepad();

}

}

求一个用JAVA写的简单的记事本源代码程序

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.awt.datatransfer.*;

class MyMenuBar extends MenuBar{

public MyMenuBar(Frame parent){

parent.setMenuBar(this);

}

public void addMenus(String [] menus){

for(int i=0;imenus.length;i++)

add(new Menu(menus[i]));

}

public void addMenuItems(int menuNumber,String[] items){

for(int i=0;iitems.length;i++){

if(items[i]!=null)

getMenu(menuNumber).add(new MenuItem(items[i]));

else getMenu(menuNumber).addSeparator();

}

}

public void addActionListener(ActionListener al){

for(int i=0;igetMenuCount();i++)

for(int j=0;jgetMenu(i).getItemCount();j++)

getMenu(i).getItem(j).addActionListener(al);

}

}

class MyFile{

private FileDialog fDlg;

public MyFile(Frame parent){

fDlg=new FileDialog(parent,"",FileDialog.LOAD);

}

private String getPath(){

return fDlg.getDirectory()+"\\"+fDlg.getFile();

}

public String getData() throws IOException{

fDlg.setTitle("打开");

fDlg.setMode(FileDialog.LOAD);

fDlg.setVisible(true);

BufferedReader br=new BufferedReader(new FileReader(getPath()));

StringBuffer sb=new StringBuffer();

String aline;

while((aline=br.readLine())!=null)

sb.append(aline+'\n');

br.close();

return sb.toString();

}

public void setData(String data) throws IOException{

fDlg.setTitle("保存");

fDlg.setMode(FileDialog.SAVE);

fDlg.setVisible(true);

BufferedWriter bw=new BufferedWriter(new FileWriter(getPath()));

bw.write(data);

bw.close();

}

}

class MyClipboard{

private Clipboard cb;

public MyClipboard(){

cb=Toolkit.getDefaultToolkit().getSystemClipboard();

}

public void setData(String data){

cb.setContents(new StringSelection(data),null);

}

public String getData(){

Transferable content=cb.getContents(null);

try{

return (String) content.getTransferData(DataFlavor.stringFlavor);

//DataFlavor.stringFlavor会将剪贴板中的字符串转换成Unicode码形式的String对象。

//DataFlavor类是与存储在剪贴板上的数据的形式有关的类。

}catch(Exception ue){}

return null;

}

}

class MyFindDialog extends Dialog implements ActionListener{

private Label lFind=new Label("查找字符串");

private Label lReplace=new Label("替换字符串");

private TextField tFind=new TextField(10);

private TextField tReplace=new TextField(10);

private Button bFind=new Button("查找");

private Button bReplace=new Button("替换");

private TextArea ta;

public MyFindDialog(Frame owner,TextArea ta){

super(owner,"查找",false);

this.ta=ta;

setLayout(null);

lFind.setBounds(10,30,80,20);

lReplace.setBounds(10,70,80,20);

tFind.setBounds(90,30,90,20);

tReplace.setBounds(90,70,90,20);

bFind.setBounds(190,30,80,20);

bReplace.setBounds(190,70,80,20);

add(lFind);

add(tFind);

add(bFind);

add(lReplace);

add(tReplace);

add(bReplace);

setResizable(false);

bFind.addActionListener(this);

bReplace.addActionListener(this);

addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

MyFindDialog.this.dispose();

}

});

}//构造函数结束

public void showFind(){

setTitle("查找");

setSize(280,60);

setVisible(true);

}

public void showReplace(){

setTitle("查找替换");

setSize(280,110);

setVisible(true);

}

private void find(){

String text=ta.getText();

String str=tFind.getText();

int end=text.length();

int len=str.length();

int start=ta.getSelectionEnd();

if(start==end) start=0;

for(;start=end-len;start++){

if(text.substring(start,start+len).equals(str)){

ta.setSelectionStart(start);

ta.setSelectionEnd(start+len);

return;

}

}

//若找不到待查字符串,则将光标置于末尾

ta.setSelectionStart(end);

ta.setSelectionEnd(end);

}

public Button getBFind() {

return bFind;

}

private void replace(){

String str=tReplace.getText();

if(ta.getSelectedText().equals(tFind.getText()))

ta.replaceRange(str,ta.getSelectionStart(),ta.getSelectionEnd());

else find();

}

public void actionPerformed(ActionEvent e) {

if(e.getSource()==bFind)

find();

else if(e.getSource()==bReplace)

replace();

}

}

public class MyMemo extends Frame implements ActionListener{

private TextArea editor=new TextArea(); //可编辑的TextArea

private MyFile mf=new MyFile(this);//MyFile对象

private MyClipboard cb=new MyClipboard();

private MyFindDialog findDlg=new MyFindDialog(this,editor);

public MyMemo(String title){ //构造函数

super(title);

MyMenuBar mb=new MyMenuBar(this);

//添加需要的菜单及菜单项

mb.addMenus(new String[]{"文件","编辑","查找","帮助"});

mb.addMenuItems(0,new String[]{"新建","打开","保存",null,"全选"});

mb.addMenuItems(1,new String[]{"剪贴","复制","粘贴","清除",null,"全选"});

mb.addMenuItems(2,new String[]{"查找",null,"查找替换"});

mb.addMenuItems(3,new String[]{"我的记事本信息"});

add(editor); //为菜单项注册动作时间监听器

mb.addActionListener(this);

addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e){

MyMemo.this.dispose();

}

}); //分号不能忘了

} //构造函数完

public void actionPerformed(ActionEvent e){

String selected=e.getActionCommand(); //获取菜单项标题

if(selected.equals("新建"))

editor.setText("");

else if(selected.equals("打开")){

try{

editor.setText(mf.getData());

}catch(IOException ie){}

}

else if(selected.equals("保存")){

try{

mf.setData(editor.getText());

}catch(IOException ie){}

}

else if(selected.equals("退出")){

dispose();

}

else if(selected.equals("剪贴")){

//将选中的字符串复制到剪贴板中并清除字符串

cb.setData(editor.getSelectedText());

editor.replaceRange("",editor.getSelectionStart(),editor.getSelectionEnd());

}

else if(selected.equals("复制")){

cb.setData(editor.getSelectedText());

}

else if(selected.equals("粘贴")){

String str=cb.getData();

editor.replaceRange(str,editor.getSelectionStart(),editor.getSelectionEnd());

//粘贴在光标位置

}

else if(selected.equals("清除")){

editor.replaceRange("",editor.getSelectionStart(),editor.getSelectionEnd());

}

else if(selected.equals("全选")){

editor.setSelectionStart(0);

editor.setSelectionEnd(editor.getText().length());

}

else if(selected.equals("查找")){

findDlg.showFind();

}

else if(selected.equals("查找替换")){

findDlg.showReplace();

}

}

public static void main(String[] args){

MyMemo memo=new MyMemo("记事本");

memo.setSize(650,450);

memo.setVisible(true);

}

}


本文标题:安卓日记本java源代码 android我的日记代码
分享网址:http://cdxtjz.com/article/dojgihi.html

其他资讯