java小学期代码 java编程代码题库及答案

求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=https://www.04ip.com/post/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=https://www.04ip.com/post/jta.getText();
jta.cut();
}else if("复制".equals(comm)){
jta.copy();
}else if("粘贴".equals(comm)){
value=https://www.04ip.com/post/jta.getText();
jta.paste();
}else if("删除".equals(comm)){
value=https://www.04ip.com/post/jta.getText();
jta.replaceSelection(null);
}else if("全选".equals(comm)){
jta.selectAll();
}else if("查找".equals(comm)){
value=https://www.04ip.com/post/jta.getText();
jf.add(jtf,BorderLayout.CENTER);
jf.add(jb,BorderLayout.SOUTH);
jf.setLocation(300,300);

推荐阅读