資源簡介
一個簡單的迷你記事本,基本可以實現Windows自帶的所有功能,可以用作java的學習,可以直接運行,打包了所有的項目文件,在Eclipse中開項目即可。

代碼片段和文件信息
import?java.awt.Font;
import?java.awt.GraphicsEnvironment;
import?java.awt.event.ActionEvent;
import?java.awt.event.ActionListener;
import?java.awt.event.ItemEvent;
import?java.awt.event.ItemListener;
import?java.awt.*;
import?javax.swing.*;
import?java.awt.event.*;
import?javax.swing.border.*;
import?java.util.*;
public?class?FontDialog?{?????????????????????
???????private?Dialog?fontdialog;
???????private?JButton?okButton?cancelButton;
???????private?int?width?=?480;
???????private?int?height?=?250;
???????private?String?name?=?“Serif“;
???????private?int?type?=?0;
???????private?int?size?=?12;
???????private?Font?customFont?=?new?Font(“宋體“?Font.ITALIC?12);
???????private?boolean?okpressed?=?false;
???????private?boolean?cancelpressed?=?false;?
???????private?JLabel?lbl1?=?new?JLabel(“字體:“);
???????private?JLabel?lbl2?=?new?JLabel(“字形:“);
???????private?JLabel?lbl3?=?new?JLabel(“大小:“);
???????private?JTextArea?area;
???????String[]?zx?=?{?“常規“?“加粗“?“斜體“?“基線“?};
???????String[]?dx?=?{“8“??“9“??“10“?“12“?“14“?“15“?“16“?“18“
???? ??????????“20“?“21“?“22“?“24“?“26“?“28“?“30“?“36“?
???? ??????????“48“?“54““72“??“89“};
???????JLabel?lbl?=?new?JLabel(“字體樣式style“);
???????private?JComboBox?cb1?cb3?=?new?JComboBox(dx)?cb2?=?new?JComboBox(zx);??
???????private?String[]?zt;
public?FontDialog(frame?owner?String?title?boolean?modal)?{
??????
??init();
??????fontdialog?=?new?Dialog(owner?title?modal);
??????fontdialog.setLocation(owner.getLocation());
??????fontdialog.setLayout(new?FlowLayout());
??????fontdialog.setSize(getWidth()?getHeight());
??????fontdialog.add(lbl1);
??????fontdialog.add(cb1);
??????fontdialog.add(lbl2);
??????fontdialog.add(cb2);
??????fontdialog.add(lbl3);
??????fontdialog.add(cb3);
??????fontdialog.add(okButton);
??????fontdialog.add(cancelButton);
??????fontdialog.add(area);
??????fontdialog.setResizable(false);
??????fontdialog.setAlwaysOnTop(true);
??????cancelButton.addActionListener(new?fontListener());
??????okButton.addActionListener(new?fontListener());
??????fontdialog.addWindowListener(new?fontListener());
??????
??????cb1.addItemListener(new?ItemListener()?{???????????????????????//字體動作
????????????public?void?itemStateChanged(ItemEvent?event)?{?????????//添加監聽器獲取選擇用戶的字體類型
???????????????????name?=?(String)?event.getItem();
???????????????????setCustomFont(new?Font(name?type?size));
???????????}
??????});
??????
??????cb2.addItemListener(new?ItemListener()?{???????????????????????//字形動作
????????????public?void?itemStateChanged(ItemEvent?event)?{?????????//添加監聽器獲取選擇用戶的字形
??????????????????String?s?=?(String)?event.getItem();
?????????????????if?(s.equals(“常規“))?
?????????????????{
?????????????????????type?=?Font.PLAIN;
?????????????????????setCustomFont(new?Font(name?type?size));
?????????????????}
?????????????????else?if?(s.equals(“加粗“))
?????????????????{
?????????????????????type?=?Font.BOLD;
??????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????232??2012-12-27?09:12??MiniNote\.classpath
?????文件????????378??2012-12-27?09:12??MiniNote\.project
?????文件???????1073??2012-12-27?09:16??MiniNote\bin\FontDialog$1.class
?????文件???????1378??2012-12-27?09:16??MiniNote\bin\FontDialog$2.class
?????文件???????1151??2012-12-27?09:16??MiniNote\bin\FontDialog$3.class
?????文件???????1547??2012-12-27?09:16??MiniNote\bin\FontDialog$fontListener.class
?????文件???????5906??2012-12-27?09:16??MiniNote\bin\FontDialog.class
?????文件????????737??2012-12-27?09:18??MiniNote\bin\MiniNote$1.class
?????文件???????1080??2012-12-27?09:18??MiniNote\bin\MiniNote$2.class
?????文件???????3001??2012-12-27?09:18??MiniNote\bin\MiniNote$3.class
?????文件???????2249??2012-12-27?09:18??MiniNote\bin\MiniNote$4.class
?????文件????????741??2012-12-27?09:18??MiniNote\bin\MiniNote$5.class
?????文件???????2245??2012-12-27?09:18??MiniNote\bin\MiniNote$6.class
?????文件????????737??2012-12-27?09:18??MiniNote\bin\MiniNote$7.class
?????文件??????12224??2012-12-27?09:18??MiniNote\bin\MiniNote.class
?????文件?????????11??2012-12-27?09:19??MiniNote\nullnull
?????文件???????5880??2012-12-27?09:16??MiniNote\src\FontDialog.java
?????文件??????20574??2012-12-27?09:18??MiniNote\src\MiniNote.java
?????目錄??????????0??2017-11-27?22:54??MiniNote\bin
?????目錄??????????0??2017-11-27?22:54??MiniNote\src
?????目錄??????????0??2017-11-27?22:54??MiniNote
-----------?---------??----------?-----??----
????????????????61144????????????????????21
評論
共有 條評論