JAVA寫的NotePad
來源:互聯網
上載者:User
學了JAVA一個月.就寫了個NotePad.由於時間關係.要實訓了,很多功能沒加上去,只實現了簡單的介面和最基本上的功能.
以後有時間再完善吧..
=================================================================================
/*貓貓..第一個Java程式
*
*
*copyright 貓貓
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
public class Notepad extends JFrame
{
String openFilePath;
String openFileName;
String title="ERROR MESSAGE";
int type=JOptionPane.ERROR_MESSAGE;
public Notepad()
{
super("記事本");
final JTextArea text = new JTextArea();
text.setToolTipText("請鍵入內容");
//介面
//退出事件
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
//簡單的布局
final JPanel panel=new JPanel();
panel.setLayout(new GridLayout(1,1));
panel.add(new JScrollPane(text));
this.getContentPane().add(panel);
//功能表項目
JMenuBar Mbar = new JMenuBar();
this.setJMenuBar(Mbar);
JMenu file = new JMenu("檔案");
JMenu edit = new JMenu("編輯");
JMenu help = new JMenu("協助");
Mbar.add(file);
Mbar.add(edit);