/*
* TextEditor1.java
*
* Created on __DATE__, __TIME__
*/
package text;
import java.awt.Color;
import java.awt.Font;
import java.io.*;
import java.sql.Struct;
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.text.AttributeSet.FontAttribute;
import javax.swing.text.StyleConstants.FontConstants;
import org.omg.CORBA.PUBLIC_MEMBER;
import sun.awt.FontConfiguration;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import com.sun.xml.internal.txw2.Document;
import font.JFontChooser;
import font.LHFont;
/**
*
* @author __USER__
*/
public class TextEditor1 extends javax.swing.JFrame {
/** Creates new form TextEditor1 */
public TextEditor1() {
initComponents();
}
/** 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() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jLabel2 = new javax.swing.JLabel();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem8 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
jMenuItem7 = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jMenu1.setText("\u6587\u4ef6");
jMenuItem1.setText("\u65b0\u5efa");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuItem2.setText("\u6253\u5f00");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);
jMenuItem3.setText("\u4fdd\u5b58");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem3);
jMenuItem4.setText("\u53e6\u5b58\u4e3a");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem4);
jMenuItem5.setText("\u9000\u51fa");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem5);
jMenuBar1.add(jMenu1);
jMenu2.setText("\u8bbe\u7f6e");
jMenuItem8.setText("\u8bbe\u7f6e\u524d\u666f\u8272");
jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem8ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem8);
jMenuItem6.setText("\u8bbe\u7f6e\u80cc\u666f\u8272");
jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem6ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem6);
jMenuItem7.setText("\u8bbe\u7f6e\u5b57\u4f53");
jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem7ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem7);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout
.setHorizontalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addContainerGap()
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE,
649,
Short.MAX_VALUE)
.addComponent(
jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE,
270,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap()));
layout
.setVerticalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
layout
.createSequentialGroup()
.addContainerGap(38, Short.MAX_VALUE)
.addComponent(
jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
370,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2).addGap(8, 8, 8)));
pack();
}// </editor-fold>
//GEN-END:initComponents
private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JFontChooser fontChooser = new JFontChooser();
LHFont font = fontChooser.showDialog(this, "aaa");
jTextArea1.setFont(font.getFont());
jTextArea1.setForeground(font.getColor());
}
private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Color color = JColorChooser.showDialog(this, "背景色", jTextArea1
.getBackground());
if (color != null) {
jTextArea1.setBackground(color);
}
}
private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Color color = JColorChooser.showDialog(this, "前景色", jTextArea1
.getBackground());
if (color != null) {
jTextArea1.setBackground(color);
}
}
String filename;
boolean isSaved = false;
Document document;
JFileChooser jFileChooser1 = new JFileChooser();
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (toExit())
System.exit(0);
}
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
saveAs();
}
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
save();
}
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
openfile();
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
newFile();
}
/**
* @param args the command line arguments
*/
void openfile() {
if (!toExit()) {
return;
}
if (JFileChooser.APPROVE_OPTION == jFileChooser1.showOpenDialog(this)) {
try {
String filename1 = jFileChooser1.getSelectedFile().getPath();
File file = new File(filename1);
int size = (int) file.length();
char[] data = new char[size];
FileReader in = new FileReader(file);
int readChar = 0;
while (in.ready()) {
readChar = readChar
+ in.r
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
TextEditor.rar (30个子文件)
TextEditor
.project 386B
bin
text
TextEditor1.form 7KB
TextEditor1$3.class 734B
Application.form 5KB
TextEditor1$8.class 734B
TextEditor1$1.class 734B
TextEditor1.class 10KB
TextEditor1$7.class 734B
TextEditor1$5.class 734B
TextEditor1$2.class 734B
TextEditor1$6.class 734B
TextEditor1$9.class 533B
TextEditor1$4.class 734B
font
JFontChooser$2.class 2KB
JFontChooser$7.class 988B
JFontChooser$5.class 1KB
JFontChooser$4.class 1KB
JFontChooser$3.class 2KB
JFontChooser$1.class 1KB
JFontChooser.class 9KB
JFontChooser$6.class 921B
LHFont.class 741B
src
text
TextEditor1.form 7KB
Application.form 5KB
TextEditor1.java 11KB
font
LHFont.java 450B
JFontChooser.java 10KB
.classpath 358B
lib
AbsoluteLayout.jar 3KB
swing-layout-1.0.3.jar 115KB
共 30 条
- 1
资源评论
- muqiutong2012-09-05不好 。不要下
kaly0204
- 粉丝: 22
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功