資源簡(jiǎn)介
純手寫,能完成字體顏色大小設(shè)置,打開和保存txt文件。最最重要的是內(nèi)附實(shí)驗(yàn)報(bào)告啊...

代碼片段和文件信息
import?javax.swing.*;
import?java.awt.*;
import?java.awt.event.*;
import?javax.swing.event.*;
import?java.io.*;
public?class?editor
{
public?static?void?main?(String[]?args)
{
textframe?frame=new?textframe();
frame.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
frame.show();
}
}
class?textframe?extends?Jframe?implements?ActionListener
{
public?textframe()
{
settitle(“記事本“);
setSize(600540);
JMenuBar?menubar?=new?JMenuBar();
setJMenuBar(menubar);
fileMenu?=new?JMenu(“文件(F)“);
fileMenu.setForeground(Color.?BLUE);
fileMenu.setMnemonic(‘F‘);
openitem=new?JMenuItem(“打開“);
openitem.addActionListener(this);
saveitem=new?JMenuItem(“保存“);
saveitem.addActionListener(this);
fileMenu.add(openitem);
fileMenu.add(saveitem);
JMenu?styleMenu?=new?JMenu(“格式(S)“);
styleMenu.setForeground(Color.?BLUE);
styleMenu.setMnemonic(‘S‘);
JMenu?colorMenu=new?JMenu(“顏色“);
JMenu?fontMenu=new?JMenu(“字體“);
styleMenu.add(colorMenu);
????bitem=new?JMenuItem(“BLUE“);
????bitem.addActionListener(this);
????bitem.setForeground(Color.?BLUE);
????blitem=new?JMenuItem(“BLACK“);
????blitem.addActionListener(this);
????blitem.setForeground(Color.?BLACK);
????ritem=new?JMenuItem(“RED“);
????ritem.addActionListener(this);
????ritem.setForeground(Color.?RED);
????gitem=new?JMenuItem(“GREEN“);
????gitem.addActionListener(this);
????gitem.setForeground(Color.?GREEN);
????colorMenu.add(bitem);
????colorMenu.add(blitem);
????colorMenu.add(ritem);
????colorMenu.add(gitem);
????styleMenu.add(new?JMenuItem(“_____“));
styleMenu.add(fontMenu);
songitem=new?JMenuItem(“宋體“);
songitem.addActionListener(this);
huaitem=new?JMenuItem(“華文行楷“);
huaitem.addActionListener(this);
liitem=new?JMenuItem(“隸書“);
liitem.addActionListener(this);
fontMenu.add(songitem);
fontMenu.add(huaitem);
fontMenu.add(liitem);
fontMenu.add(new?JMenuItem(“_____“));
bolditem=new?JCheckBoxMenuItem(“加粗“);
bolditem.addActionListener(this);
italicitem=new?JCheckBoxMenuItem(“傾斜“);
italicitem.addActionListener(this);
fontMenu.add(bolditem);
fontMenu.add(italicitem);
JMenu?helpMenu=new?JMenu(“幫助(H)“);
helpMenu.setForeground(Color.?BLUE);
????helpMenu.setMnemonic(‘H‘);
????copyrightitem?=?new?JMenuItem(“版權(quán)“?‘b‘);
????copyrightitem.addActionListener(this);
????explainitem=new?JMenuItem(“說明“‘a(chǎn)‘);
????explainitem.addActionListener(this);
????helpMenu.add(copyrightitem);
????helpMenu.add(explainitem);
menubar.add(fileMenu);
menubar.add(styleMenu);
menubar.add(helpMenu);
Container?contentPane=getContentPane();
JPanel?TextPanel=new?JPanel();
text=new?JTextArea(2780);
text.setFont(new?Font(“宋體“Font.PLAIN13));
JScrollPane?scrollpane=new?JScrollPane?(text);
TextPanel.add(scrollpane);
contentPane.add(TextPanelBorderLayout.SOUTH);
JPanel?toolPanel=new?JPanel();
????JLabel?l=new?JLabel(“字體大小“);
????sizeBox=?new?JComboBox();
????a=new?int?[16];
????for(int?i=0;i<=15;i++)
????{???a[i]=(i+5)*2;
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2011-12-21?21:37??文本編輯器\
?????文件????????7257??2011-12-21?21:36??文本編輯器\editor.java
?????文件????????7304??2010-12-08?22:11??文本編輯器\editor.java.bak
?????文件??????207360??2010-12-19?12:44??文本編輯器\用Java設(shè)計(jì)文本編輯器.doc
評(píng)論
共有 條評(píng)論