/**
就是这段程序,大家看看什么问题
剪切完成了粘贴的功能,复制和粘贴按钮根本不起作用
我用manubar调用这些功能(wb.cut(),wb.paste())就没问题
大家看看怎么回事
**/
import javax.swing.JFrame;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;public class LileTest extends JFrame
{
    /** ******************************************************************************* */
    /*
     * 初始化组建
     */
       JToolBar fudong = new JToolBar();    JTextArea wb = new JTextArea(8, 25);    JScrollPane scroller = new JScrollPane();    JViewport port = scroller.getViewport();    BorderLayout bord = new BorderLayout();    /*
     * 变量声名
     */
    JPanel contentPane;// 面版容器    fudong fd;// 浮动工具栏    
    /*
     * 浮动工具栏
     */
    class fudong extends JToolBar
    {
        public fudong()
        {
           
            /*
             * 预计 新建的时候 提示保存
             */            JButton button1 = new JButton("新建");
            this.add(button1);
            button1.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    
                    wb.setText("");
                }
            });
            // //////////////////////////////////////////////////////////////////////////////
            JButton button2 = new JButton("打开");
            this.add(button2);
            JButton button3 = new JButton("保存");
            this.addSeparator();
            this.add(button3);
            // ////////////////////////////////////////////////////////////////////////////
            // /
            JButton button4 = new JButton("剪接");
            this.add(button4);
            button4.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    wb.cut();
                    wb.repaint();
                }
            });
            // ////////////////////////////////////////////////////////////////////////////
            // /
            JButton button5 = new JButton("复制");
            this.add(button5);
            button5.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    wb.copy();                  
                }
            });            // ////////////////////////////////////////////////////////////////////////////
            // /
            JButton button6 = new JButton("粘贴");
            this.add(button6);
            button4.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    wb.paste();
                    wb.repaint();
                }
            });            // ////////////////////////////////////////////////////////////////////////////
            // /
            this.addSeparator();
            JButton button7 = new JButton("字体");
            this.add(button7);
            this.addSeparator();
            JButton button8 = new JButton("关于");
            this.add(button8);
            this.addSeparator();
            JButton button9 = new JButton("退出");
            this.add(button9);
            button9.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    dispose();
                    System.exit(0);
                }
            });        }
    }    /** **************************************************************************** */
    /*
     * 布局管理器
     * 
     * 
     */
    public LileTest()
    {
        contentPane = (JPanel) this.getContentPane(); // 建立容器并把JPanel加入容器
        contentPane.setLayout(bord);// 设置布局管理器类型
   
        this.setTitle("记事本");
        // 加入组建
        contentPane.add(wb, BorderLayout.CENTER);
        // 浮动工具栏组建
        fd = new fudong();
        contentPane.add(fd, BorderLayout.NORTH);
        contentPane.add("Center", scroller);
        port.add(wb);        setSize(800, 600);
        show();    }    /** **************************************************************************** */
    /*
     * 主框架属性
     */
    public static void main(String args[])
    {        new LileTest();
    }
}