⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 10+

📁 本压缩文档为《Java大学实用教程》(7-121-00959-5 电子工业出版社 2005.3) 的电子教案。
💻
字号:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class EditWindow extends JFrame implements ActionListener  
{  
    JMenuBar menubar;
    JMenu menu;
    JSplitPane splitPane;
    JMenuItem  itemCopy,itemCut,itemPaste; 
    JTextArea text1,text2;
    EditWindow(String s) 
    {  
      super(s);        
      setSize(260,270);
      setLocation(120,120);
      setVisible(true);               
      menubar=new JMenuBar(); 
      menu=new JMenu("编辑");   
      itemCopy=new JMenuItem("拷贝");
      itemCut=new JMenuItem("剪切");
      itemPaste=new JMenuItem("粘贴");
      menu.add(itemCopy);
      menu.add(itemCut);
      menu.add(itemPaste);
      menubar.add(menu);
      setJMenuBar(menubar);
      text1=new JTextArea();
      text2=new JTextArea();
      splitPane=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,text1,text2);
      splitPane.setDividerLocation(120);
      setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      Container con=getContentPane();
      con.add(splitPane,BorderLayout.CENTER);
      con.validate();
      validate();
      itemCopy.addActionListener(this);
      itemCut.addActionListener(this);
      itemPaste.addActionListener(this);
    } 
   public void actionPerformed(ActionEvent e)
    {
       if(e.getSource()==itemCopy)
           text1.copy();
       else if(e.getSource()==itemCut)
           text1.cut();
       else if(e.getSource()==itemPaste)
           text2.paste();
    }
}
public class Example
{  
    public static void main(String args[])
    { 
      EditWindow win=new EditWindow("窗口");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -