java记事本中的格式设置

本文档展示了如何使用Java创建一个简单的记事本程序,包括文件打开、保存、编辑功能。程序集成了常见的文本编辑操作,如复制、粘贴、剪切、删除,以及字体设置等。
摘要由CSDN通过智能技术生成
/*
 * NotePad.java
 *
 * Created on __DATE__, __TIME__
 */

package gui.com;

import java.awt.event.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.JFileChooser;

/**
 *
 * @author  __USER__
 */
public class NotePad extends javax.swing.JFrame implements ActionListener {

	/** Creates new form NotePad */
	public NotePad() {
		initComponents();                         //注册监听
		this.itemCopy.addActionListener(this);
		this.itemZhuangTai.addActionListener(this);
		this.itemSave.addActionListener(this);
		this.itemPaste.addActionListener(this);
		this.itemOpen.addActionListener(this);
		this.itemNew.addActionListener(this);
		this.itemCut.addActionListener(this);
		this.itemDelete.addActionListener(this);
		this.itemExit.addActionListener(this);
		this.itemFont.addActionListener(this);
		this.mPaste.addActionListener(this);
		this.mCut.addActionListener(this);
		this.mCopy.addActionListener(this);
		this.mDelete.addActionListener(this);
		this.setLocationRelativeTo(null);               //窗体显示位置
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		popMenu = new javax.swing.JPopupMenu();
		mCut = new javax.swing.JMenuItem();
		mCopy = new javax.swing.JMenuItem();
		mPaste = new javax.swing.JMenuItem();
		mDelete = new javax.swing.JMenuItem();
		jScrollPane1 = new javax.swing.JScrollPane();
		ta = new javax.swing.JTextArea();
		jMenuBar1 = new javax.swing.JMenuBar();
		mFile = new javax.swing.JMenu();
		itemNew = new javax.swing.JMenuItem();
		itemOpen = new javax.swing.JMenuItem();
		itemSave = new javax.swing.JMenuItem();
		jSeparator1 = new javax.swing.JSeparator();
		itemExit = new javax.swing.JMenuItem();
		mEdit = new javax.swing.JMenu();
		itemCut = new javax.swing.JMenuItem();
		itemCopy &
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值