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

📄 word2.java

📁 该程序包括排序与向量建立表的基本功能
💻 JAVA
字号:
package yu2;

import java.beans.PropertyVetoException;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class word2 extends JInternalFrame {
	  private JTextArea ta1;
	  private static int i=0;
	  private String path;
	  word2(){
		  super("文档"+(i+1),true,true,true,true);
		  this.setSize(300,400);//文档的大小
		  ta1=new JTextArea();
		  this.getContentPane().add(new JScrollPane(ta1));//添加滚动条
		  this.setLocation(20*i,15*i);//位置的大小
		  i++;
		  this.setVisible(true);
	  }
	  public void open(){
		JFileChooser  jf=new JFileChooser();
		jf.showOpenDialog(null);
		File f=jf.getSelectedFile();
		path=f.getAbsolutePath();
		this.setTitle(path);
		try {
			BufferedReader bf=new BufferedReader(new FileReader(f));
			String aa="";
			while ((aa=bf.readLine())!=null) {
				ta1.append(aa+"\n");
			}
	    } catch (Exception e1) {
			e1.printStackTrace();
		}
		
	}
	  public void copy(){
		  this.ta1.copy();
		
	  }
	  
	  public void cut(){
		  this.ta1.cut();
		
	  }
	  public void paste(){
		  this.ta1.paste();
		
	  }
     public void huanhang(){
    	  this.ta1.setLineWrap(true); 
     }
     public void nothuanhang(){
    	this.ta1.setLineWrap(false); 
     }
     public void close(){
    	try {
			this.setClosed(true);
		} catch (PropertyVetoException e) {
			e.printStackTrace();
		}
     }
     public void baocun(){
		String str=this.ta1.getText();
		JFileChooser fc=new JFileChooser();
		fc.showSaveDialog(null);//打开保存对话框
		File f=fc.getSelectedFile();
		try {
			BufferedWriter bw=new BufferedWriter(new FileWriter(f));
			bw.write(str.replace("\n", "\r\n"));
			bw.close();
		} catch (IOException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
	}
    	 
     }
	

⌨️ 快捷键说明

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