java写字板_java经典写字板程序

这是一个使用Java编写的简单写字板程序,包含文件操作、编辑功能。通过JTextArea、JMenuBar等组件实现文本编辑,支持打开文件,并使用Clipboard进行数据复制粘贴。
摘要由CSDN通过智能技术生成

import java.awt.*;

import java.awt.event.*;

import java.awt.datatransfer.*;

import java.io.*;

import javax.swing.*;

import javax.swing.text.*;

public class 写字板extends JPanel

{

JTextArea jta = new JTextArea("", 24, 40);

JScrollPane jsp = new JScrollPane(jta);

JMenuBar jmb = new JMenuBar();

JMenu file = new JMenu("文件(F)", true);

JMenu edit = new JMenu("编辑(E)", true);

JMenu help = new JMenu("帮助(H)", true);

JToolBar toolBar = new JToolBar();

JMenuItem jmi;

Clipboard clipbd = getToolkit().getSystemClipboard();

String text = "";

public 写字板()

{

class newL implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

jta.setDocument(new PlainDocument());

}

}

class openL implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

JFileChooser fc = new JFileChooser();

int returnVal = fc.showDialog(写字板.this, "打开");

if (returnVal == JFileChooser.APPROVE_OPTION)

{

String file = fc.getSelectedFile().getPath();

if (file == null)

{

return;

}

try

{

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值