记事本

  • 自学
  • 记事本
  • 1.界面设计:
  • (1)菜单区:
  • (2)文本区:
  • 2.事件设计:(这里给出对每个功能不完整的操作代码)
  • (1)新建:
  • (2)打开:
  • (3)保存:
  • (4)另存为:
  • (5)退出:
  • (6)全选:
  • (7)剪切:
  • (8)复制:
  • (9)粘贴:
  • (10)撤销:
  • (11)恢复:
  • (12)查找:
  • (13)替换:
  • (14)时间日期:
  • (15)自动换行:
  • (16)字体:
  • (17)主题:
  • (18)状态栏:
  • (19)查看帮助:
  • (20)关于:
  • 待添加功能:发送反馈,背景颜色,字体颜色......


自学

Java Swing教程Java:使用bat运行java文件

记事本

1.界面设计:

(1)菜单区:
①顶部菜单栏

Java语言设计记事本 java程序设计记事本程序_ide

  • 文件<[新建]、[打开]、[保存]、[另存为]、[退出]>
  • 编辑<[全选]、[剪切]、[复制]、[粘贴]、[撤销]、[恢复]、[查找]、[替换]、[时间日期]>
  • 格式<[自动换行]、[字体]、[主题]>
  • 查看<[状态栏]>
  • 帮助<[查看帮助]、[关于]>
②弹出菜单:

Java语言设计记事本 java程序设计记事本程序_Java语言设计记事本_02

(2)文本区:

2.事件设计:(这里给出对每个功能不完整的操作代码)

(1)新建:
JMenuItem create;
create = new JMenuItem("新建(N)", KeyEvent.VK_N);
file.add(create);
create.addActionListener(this);
create.setActionCommand("新建");
create.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
@Override
public void actionPerformed(ActionEvent e)
{
    if(e.getActionCommand().equals("新建"))
    {
        jTextArea.setText(null);
    }
}
(2)打开:
JMenuItem open;
open = new JMenuItem("打开(O)", KeyEvent.VK_O);
file.add(open);
open.addActionListener(this);
open.setActionCommand("打开");
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
@Override
public void actionPerformed(ActionEvent e)
{
	if (e.getActionCommand().equals("打开"))
    {
        JFileChooser jFileChooser = new JFileChooser();
        jFileChooser.setDialogTitle("打开文件");
        jFileChooser.showOpenDialog(null);
        jFileChooser.setVisible(true);
        String address = jFileChooser.getSelectedFile().getAbsolutePath();
        try
        {
            fileReader = new FileReader(address);
            bufferedReader = new BufferedReader(fileReader);
            String str = "";
            String strAll = "";
            while((str = bufferedReader.readLine()) != null)
            {
                strAll += str + "\r\n";
            }
            jTextArea.setText(strAll);
        }
        catch(IOException e1)
        {
            e1.printStackTrace();
        }
        finally
        {
            try
            {
                bufferedReader.close();
                fileReader.close();
            }
            catch(IOException e1)
            {
                e1.printStackTrace();
            }
        }
    }
}
(3)保存:
JMenuItem save;
save = new JMenuItem("保存(S)", KeyEvent.VK_S);
file.add(save);
save.addActionListener(this);
save.setActionCommand("保存");
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
@Override
public void actionPerformed(ActionEvent e)
{
	if (e.getActionCommand().equals("保存"))
    {
    	 String path;
         String content = jTextArea.getText();
         JFileChooser jFileChooser = new JFileChooser();
         jFileChooser.setFileFilter(new FileNameExtensionFilter("文本文件(*.txt)", "txt"));
         int returnValue = jFileChooser.showSaveDialog(null);
         if (returnValue == JFileChooser.APPROVE_OPTION)
         {
        	 path = jFileChooser.getSelectedFile().getAbsolutePath() + ".txt";
             File file = new File(path);
             try
             {
                 BufferedWriter writer = new BufferedWriter(new FileWriter(file));
                 writer.write(content);
                 writer.close();
                 jTextArea.setText("");
             }
             catch (IOException e1)
             {
                 e1.printStackTrace();
             }
         }
     }
}
(4)另存为:
JMenuItem saveAs;
saveAs = new JMenuItem("另存为(B)", KeyEvent.VK_B);
file.add(saveAs);
saveAs.addActionListener(this);
saveAs.setActionCommand("另存为");
saveAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK));
@Override
public void actionPerformed(ActionEvent e)
{
	if (e.getActionCommand().equals("另存为"))
    {
        JFileChooser jFileChooser = new JFileChooser();
        int returnValue = jFileChooser.showSaveDialog(null);
        if (returnValue == JFileChooser.APPROVE_OPTION)
        {
            try
            {
                FileWriter fileWriter = new FileWriter(jFileChooser.getSelectedFile(), true);
                String content = jTextArea.getText();
                fileWriter.write(content + "\r\n");
                fileWriter.close();
            }
            catch (IOException e1)
            {
                e1.printStackTrace();
            }
        }
    }
}
(5)退出:
JMenuItem exit;
exit = new JMenuItem("退出(E)", KeyEvent.VK_E);
file.add(exit);
exit.addActionListener(this);
exit.setActionCommand("退出");
exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK));
@Override
public void actionPerformed(ActionEvent e)
{
	if (e.getActionCommand().equals("退出"))
    {
        Object[] options = { "保存", "不保存" };
        int m = JOptionPane.showOptionDialog(new JFrame(), "你想将更改保存到 记事本 吗?", "记事本",
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
        if (change)
        {
            if (m == JOptionPane.YES_OPTION)
            {
                jFrame.dispose();
            }
            else if (m == JOptionPane.NO_OPTION)
            {
                jFrame.dispose();
            }
        }
    }
}
(6)全选:
JMenuItem selectAll;
selectAll = new JMenuItem("全选(A)",KeyEvent.VK_A);
selectAll.addActionListener(this);
selectAll.setActionCommand("全选");
selectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
@Override
public void actionPerformed(ActionEvent e)
{
	if (e.getActionCommand().equals("全选"))
    {
        jTextArea.selectAll(); 
    }
}
(7)剪切:
JMenuItem cut;
cut = new JMenuItem("剪切(X)", KeyEvent.VK_X);
edit.add(cut);
cut.addActionListener(this);
cut.setActionCommand("剪切");
cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
@Override
public void actionPerformed(ActionEvent e)
{
	if (e.getActionCommand().equals("剪切"))
    {
        jTextArea.cut();
    }
}
(8)复制:
if (e.getActionCommand().equals("复制"))
        {
            jTextArea.copy();
        }
(9)粘贴:
if (e.getActionCommand().equals("粘贴"))
        {
            jTextArea.paste();
        }
(10)撤销:
if (e.getActionCommand().equals("撤销"))
        {
            if(undoManager.canUndo())
            {
                undoManager.undo();
            }
            else
            {
                JOptionPane.showMessageDialog(null,"无法撤销","警告",JOptionPane.WARNING_MESSAGE);
            }
        }
(11)恢复:
if (e.getActionCommand().equals("恢复"))
        {
            if(undoManager.canRedo())
            {
                undoManager.redo();
            }
            else
            {
                JOptionPane.showMessageDialog(null, "无法恢复", "警告", JOptionPane.WARNING_MESSAGE);
            }
        }
(12)查找:
if (e.getActionCommand().equals("查找"))
        {
            JButton jButton1 = new JButton("查找下一个");
            JButton jButton2 = new JButton("取消");
            ButtonGroup buttonGroup = new ButtonGroup(); 
            JCheckBox jCheckBox1 = new JCheckBox("区分大小写");
            JCheckBox jCheckBox2 = new JCheckBox("循环");
            JDialog jDialog = new JDialog(new JFrame(), "查找", false);
            JLabel jLabel = new JLabel("查找内容:");
            JPanel jPanel1 = new JPanel();
            JPanel jPanel2 = new JPanel();
            JRadioButton up = new JRadioButton("向上");
            JRadioButton down = new JRadioButton("向下");
            JTextField jTextField = new JTextField(18);
            jButton1.setBounds(330,10,115,25);
            jButton1.setContentAreaFilled(false);
            jButton2.setBounds(330, 40, 115, 25);
            jButton2.setContentAreaFilled(false);
            buttonGroup.add(up);
            buttonGroup.add(down);
            down.setSelected(true);
            jCheckBox1.setBounds(0,100,140,30);
            jCheckBox2.setBounds(0, 130, 140, 30);
            jPanel1.add(jLabel);
            jPanel1.add(jTextField);
            jPanel1.setLayout(new FlowLayout(FlowLayout.LEFT));
            jPanel1.setBounds(0,10,330,60);
            jPanel2.add(up);
            jPanel2.add(down);
            jPanel2.setBorder(BorderFactory.createTitledBorder("方向"));
            jPanel2.setBounds(150,80,180,70);
            jDialog.add(jButton1);
            jDialog.add(jButton2);
            jDialog.add(jCheckBox1);
            jDialog.add(jCheckBox2);
            jDialog.add(jPanel1);
            jDialog.add(jPanel2);
            jDialog.setBounds(700, 400, 460, 220);
            jDialog.setLayout(null);
            jDialog.setResizable(false);
            jDialog.setVisible(true);
            
            jButton1.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    String areaString = jTextArea.getText();
                    String fieldString = jTextField.getText();
                    String touppArea = areaString.toUpperCase();
                    String touppField = fieldString.toUpperCase();
                    String area,field;
                    int n = jTextArea.getCaretPosition();
                    int m = 0;
                    if (jCheckBox1.isSelected())
                    {
                        area = areaString;
                        field = fieldString;
                    }
                    else
                    {
                        area = touppArea;
                        field = touppField;
                    }
                    if (up.isSelected())
                    {
                        if (jTextArea.getSelectedText() == null)
                        {
                            m = area.lastIndexOf(field,n-1);
                        }
                        else
                        {
                            m = area.lastIndexOf(field,n - jTextField.getText().length() - 1);
                        }
                        if (m != 1)
                        {
                            jTextArea.setCaretPosition(m);
                            jTextArea.select(m,m + jTextField.getText().length()); 
                        }
                        else
                        {
                            if (jCheckBox1.isSelected())
                            {
                                m = area.lastIndexOf(field);
                                if (m != -1)
                                {
                                    jTextArea.setCaretPosition(m);
                                    jTextArea.select(m,m + jTextField.getText().length());
                                }
                                else
                                {
                                    JOptionPane.showMessageDialog(null,"找不到“" + jTextField.getText() + "”","查找",JOptionPane.INFORMATION_MESSAGE);
                                }
                            }
                            else
                            {
                                JOptionPane.showMessageDialog(null, "找不到“" + jTextField.getText() + "”", "查找",JOptionPane.INFORMATION_MESSAGE);
                            }
                        }
                    }
                    else
                    {
                        m = area.indexOf(field,n);
                        if (m != -1)
                        {
                            jTextArea.setCaretPosition(m + jTextField.getText().length());
                            jTextArea.select(m,m + jTextField.getText().length());
                        }
                        else
                        {
                            if(jCheckBox2.isSelected())
                            {
                                m = area.indexOf(field);
                                if (m != -1)
                                {
                                    jTextArea.setCaretPosition(m + jTextField.getText().length());
                                    jTextArea.select(m,m + jTextField.getText().length());
                                }
                                else
                                {
                                    JOptionPane.showMessageDialog(null, "找不到 “" + jTextField.getText() + "”", "查找",JOptionPane.INFORMATION_MESSAGE);
                                }
                            }
                            else
                            {
                                JOptionPane.showMessageDialog(null, "找不到 “" + jTextField.getText() + "”", "查找",JOptionPane.INFORMATION_MESSAGE);
                            }
                        }
                    }
                }
            });
            jButton2.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    jDialog.dispose();
                }
            });
        }
(13)替换:
if (e.getActionCommand().equals("替换"))
        {
            JButton jButton1 = new JButton("查找下一个");
            JButton jButton2 = new JButton("替     换");
            JButton jButton3 = new JButton("取消");
            JCheckBox jCheckBox = new JCheckBox("区分大小写");
            JDialog jDialog = new JDialog(new JFrame(),"替换",false);
            JLabel jLabel1 = new JLabel("查找内容");
            JLabel jLabel2 = new JLabel("替 换 为");
            JPanel jPanel1= new JPanel();
            JPanel jPanel2 = new JPanel();
            JPanel jPanel3 = new JPanel();
            JTextField jTextField1 = new JTextField(15);
            JTextField jTextField2 = new JTextField(15);
            jCheckBox.setBounds(150,70,60,25);
            jPanel1.add(jLabel1);
            jPanel1.add(jTextField1);
            jPanel1.add(jButton1);
            jPanel2.add(jLabel2);
            jPanel2.add(jTextField2);
            jPanel2.add(jButton2);
            jPanel3.add(jCheckBox);
            jPanel3.add(jButton3);
            jDialog.add(jPanel1, BorderLayout.NORTH);
            jDialog.add(jPanel2);
            jDialog.add(jPanel3, BorderLayout.SOUTH);
            jDialog.setBounds(700,500,350, 160);
            jDialog.setResizable(false);
            jDialog.setVisible(true);
            
            jButton1.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    String str1 = jTextArea.getText();
                    String str2 = jTextField1.getText();
                    String str3 = str1.toUpperCase();
                    String str4 = str2.toUpperCase();
                    String area,field;
                    int n =jTextArea.getCaretPosition();
                    if (jCheckBox.isSelected())
                    {
                        area = str1;
                        field = str2;
                    }
                    else
                    {
                        area = str3;
                        field = str4;
                    }
                    int m = area.indexOf(field, n);
                    if (m != -1)
                    {
                        jTextArea.setCaretPosition(m + str2.length());
                        jTextArea.select(m,m + str2.length());
                    }
                    else
                    {
                        m = area.indexOf(field);
                        if (m != -1)
                        {
                            jTextArea.setCaretPosition(m + str2.length());
                            jTextArea.select(m,m + str2.length());
                        }
                        else
                        {
                            JOptionPane.showMessageDialog(null,"找不到“" + str2 +"”");
                        }
                    }
                }
            });
            jButton2.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    String str2 = jTextField2.getText();
                    if (jTextArea.getSelectedText() != null)
                    {
                        jTextArea.replaceRange(str2,jTextArea.getSelectionStart(), jTextArea.getSelectionEnd());
                    }
                    else
                    {
                        JOptionPane.showMessageDialog(null,"选择内容不能为空!");
                    }
                }
            });
            jButton3.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    jDialog.dispose();
                }
            });
        }
(14)时间日期:
if (e.getActionCommand().equals("时间/日期"))
        {
            Date date = new Date();//获得当前日期
            SimpleDateFormat sdf = new SimpleDateFormat("hh:mm yyyy-MM-dd");//日期格式化 h小时,m分钟,y年份,M月份,d天数
            jTextArea.append(sdf.format(date));//追加到文本,System.out.println(sdf.format(date));
        }
class Clock extends Thread
    {
        public void run()
        {
            while (true)
            {
                GregorianCalendar time = new GregorianCalendar();
                int hour = time.get(Calendar.HOUR_OF_DAY);
                int min = time.get(Calendar.MINUTE);
                int second = time.get(Calendar.SECOND);
                statusLabel1.setText("     当前时间是:" + hour + ":" + min + ":" + second + "     ");
                try
                {
                    Thread.sleep(950);
                } 
                catch (InterruptedException exception)
                {

                }
            }
        }
    }
(15)自动换行:
if (e.getActionCommand().equals("自动换行"))
        {
            if (lineWrap.isSelected())
            {
                jTextArea.setLineWrap(true);
            }
            else
            {
                jTextArea.setLineWrap(false);
            }
        }
(16)字体:
if (e.getActionCommand().equals("字体"))
        {
            JDialog jDialog = new JDialog(new JFrame(),"字体");
            jDialog.setLayout(null);
            jDialog.setBounds(300,100,460,470);
            jDialog.setResizable(false);
            JLabel jLabel1 = new JLabel("字体:");
            jLabel1.setBounds(10,10,100,20);
            jLabel1.setFont(new Font("宋体",Font.ITALIC,14));
            JTextField jTextField1 = new JTextField(10);
            jTextField1.setBounds(10,30,180,25);
            DefaultListModel model1 = new DefaultListModel();//<>
            JList list1 = new JList(model1);//<>
            String[] fontName = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
            for (String x : fontName)
            {
                model1.addElement(x);
            }
            jTextField1.setText(fontForm);
            list1.getSelectedIndex();//101
            JScrollPane jScrollPane1 = new JScrollPane();
            jScrollPane1.setViewportView(list1);
            jScrollPane1.setBounds(10,54,180,180);
            JLabel jLabel2 = new JLabel("字形:");
            jLabel2.setBounds(205,10,100,20);
            jLabel2.setFont(new Font("宋体",Font.ITALIC,14));
            JTextField jTextField2 = new JTextField(10);
            jTextField2.setBounds(205,30,150,25);
            DefaultListModel model2 = new DefaultListModel();//<>
            model2.addElement("常规");
            model2.addElement("倾斜");
            model2.addElement("粗体");
            model2.addElement("粗偏斜体");
            JList list2 = new JList(model2);//<>
            JScrollPane jScrollPane2 = new JScrollPane();
            jScrollPane2.setViewportView(list2);
            jScrollPane2.setBounds(205,54,150,180);
            jTextField2.setText("常规");
            list2.setSelectedIndex(0);
            JLabel jLabel3 = new JLabel("大小:");
		    jLabel3.setBounds(367, 10, 100, 20);
		    jLabel3.setFont(new Font("宋体", Font.ITALIC, 14));
		    JTextField jTextField3 = new JTextField(10);
		    jTextField3.setBounds(367, 30, 70, 25);
		    DefaultListModel model3 = new DefaultListModel();
            JList list3 = new JList(model3);
            JScrollPane jScrollPane3 = new JScrollPane();
            jScrollPane3.setViewportView(list3);
            jScrollPane3.setBounds(367,54,70,180);
            for (int i = 8; i <= 12; i++)
            {
                model3.addElement(String.valueOf(i));
            }
            for (int i = 14; i <= 28; i += 2)
            {
                model3.addElement(String.valueOf(i));
            }
            model3.addElement("36");
            model3.addElement("48");
            model3.addElement("72");
            String fontSize[] = {"初号","小初","一号","小一","二号","小二","三号","小三", "四号", "小四", "五号", "小五", "六号", "小六", "七号","小七"};
            int n[] = { 42, 36, 26, 24, 22, 18, 16, 15, 14, 12, 11, 9, 8, 7, 6, 5 };
            for (String x : fontSize)
            {
                model3.addElement(x);
            }
            jTextField3.setText("14");
            list3.setSelectedIndex(5);
            JLabel example = new JLabel("AaBbYyZy");
		    example.setFont(new Font(fontForm,font1,size));
		    JPanel jPanel = new JPanel();
		    jPanel.setBounds(200, 250, 200, 80);
		    jPanel.setBorder(BorderFactory.createTitledBorder("示例"));
		    jPanel.add(example, BorderLayout.CENTER);

            JButton jButton1 = new JButton("确定");
            jButton1.setContentAreaFilled(false);
            jButton1.setBounds(270,400,80,30);
            jButton1.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    fontForm = jTextField1.getText().trim();
                    String str = jTextField2.getText().trim();
                    switch (str)//获得字形
                    {
                        case "常规":
                            font1 = Font.PLAIN;
                            break;
                        case "倾斜":
                            font1 = Font.ITALIC;
                            break;
                        case "粗体":
                            font1 = Font.BOLD;
                            break;
                        case "粗偏斜体":
                            font1 = Font.BOLD + Font.ITALIC;
                            break;
                    }
                    int fontSize = list3.getLeadSelectionIndex();//获得字体大小
                    String select3 = (String) list3.getModel().getElementAt(fontSize);
                    if (0 <= fontSize && fontSize <=15)
                    {
                        size = Integer.parseInt(select3);
                    }
                    else
                    {
                        size = n[fontSize - 16];
                    }
                    example.setFont(new Font(fontForm,font1,size));//更新示例标签
                    jTextArea.setFont(new Font(fontForm,font1,size));
                    jDialog.dispose();
                }
            });
            JButton jButton2 = new JButton("取消");
            jButton2.setContentAreaFilled(false);
            jButton2.setBounds(360,400,80,30);
            jButton2.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent e)
                {
                    jDialog.dispose();
                }
            });
            list1.addListSelectionListener(new ListSelectionListener()
            {
                public void valueChanged(ListSelectionEvent e)
                {
                    int select = list1.getLeadSelectionIndex();//获得选中的下标
                    String selectName = (String) model1.getElementAt(select);
                    jTextField1.setText(selectName);
                    String str = jTextField2.getText().trim();
                    int fontStyle = 0;
                    switch (str)
                    {
                        case "常规":
                            fontStyle = Font.PLAIN;
                            break;
                        case "倾斜":
                            fontStyle = Font.ITALIC;
                            break;
                        case "粗体":
                            fontStyle = Font.BOLD;
                            break;
                        case "粗偏斜体":
                            fontStyle = Font.BOLD + Font.ITALIC;
                            break;
                    }
                    int fontSize = list3.getLeadSelectionIndex();
                    String select3 = (String) list3.getModel().getElementAt(fontSize);
                    int fontSize0 = 0;
                    if (0 <= fontSize && fontSize <= 15)
                    {
                        fontSize0 = Integer.parseInt(select3);
                    }
                    else
                    {
                        fontSize0 = n[fontSize - 16];
                    }
                    example.setFont(new Font(jTextField1.getText(),fontStyle,fontSize0));
                }
            });
            list2.addListSelectionListener(new ListSelectionListener()
            {
                public void valueChanged(ListSelectionEvent e)
                {
                    int select = list2.getLeadSelectionIndex();//获得选中的下标
                    String selectName = (String) model2.getElementAt(select);
                    jTextField2.setText(selectName);
                    String str = jTextField2.getText().trim();
                    int fontStyle = 0;
                    switch (str)
                    {
                        case "常规":
                            fontStyle = Font.PLAIN;
                            break;
                        case "倾斜":
                            fontStyle = Font.ITALIC;
                            break;
                        case "粗体":
                            fontStyle = Font.BOLD;
                            break;
                        case "粗偏斜体":
                            fontStyle = Font.BOLD + Font.ITALIC;
                            break;
                    }
                    int fontSize = list3.getLeadSelectionIndex();
                    String select3 = (String) list3.getModel().getElementAt(fontSize);
                    int fontSize0 = 0;
                    if (0 <= fontSize && fontSize <= 15)
                    {
                        fontSize0 = Integer.parseInt(select3);
                    }
                    else
                    {
                        fontSize0 = n[fontSize - 16];
                    }
                    example.setFont(new Font(jTextField1.getText(),fontStyle,fontSize0));
                }
            });
            list3.addListSelectionListener(new ListSelectionListener()
            {
                public void valueChanged(ListSelectionEvent e)
                {
                    int select = list3.getLeadSelectionIndex();//获得选中的下标
                    String selectName = (String) model3.getElementAt(select);
                    jTextField3.setText(selectName);
                    String str = jTextField2.getText().trim();
                    int fontStyle = 0;
                    switch (str)
                    {
                        case "常规":
                            fontStyle = Font.PLAIN;
                            break;
                        case "倾斜":
                            fontStyle = Font.ITALIC;
                            break;
                        case "粗体":
                            fontStyle = Font.BOLD;
                            break;
                        case "粗偏斜体":
                            fontStyle = Font.BOLD + Font.ITALIC;
                            break;
                    }
                    int fontSize = list3.getLeadSelectionIndex();
                    String select3 = (String) list3.getModel().getElementAt(fontSize);
                    int fontSize0 = 0;
                    if (0 <= fontSize && fontSize <= 15)
                    {
                        fontSize0 = Integer.parseInt(select3);
                    }
                    else
                    {
                        fontSize0 = n[fontSize - 16];
                    }
                    example.setFont(new Font(jTextField1.getText(),fontStyle,fontSize0));
                }
            });

            jDialog.add(jLabel1);
            jDialog.add(jTextField1);
            jDialog.add(jScrollPane1);
            jDialog.add(jLabel2);
            jDialog.add(jTextField2);
            jDialog.add(jScrollPane2);
            jDialog.add(jLabel3);
            jDialog.add(jTextField3);
            jDialog.add(jScrollPane3);
            jDialog.add(jPanel);
            jDialog.add(jButton1);
            jDialog.add(jButton2);
            jDialog.setVisible(true);
        }
(17)主题:
(18)状态栏:
if (e.getActionCommand().equals("状态栏"))
        {
            if (statusBar.isSelected())
            {
                jToolBar2.setVisible(true);
            }
            else
            {
                jToolBar2.setVisible(false);
            }
        }
(19)查看帮助:
if (e.getActionCommand().equals("查看帮助"))
        {
            Desktop desk = Desktop.getDesktop();
				try
                {
					URI uri = new URI(
							"https://cn.bing.com/search?q=%E8%8E" + "%B7%E5%8F%96%E6%9C%89%E5%85%B3+windows+10+%E"
									+ "4%B8%AD%E7%9A%84%E8%AE%B0%E4%BA%8B%E6%9C%AC%E7%"
									+ "9A%84%E5%B8%AE%E5%8A%A9&filters=guid:%224466414-zh-h"
									+ "ans-dia%22%20lang:%22zh-hans%22&form=T00032&ocid=HelpPane-BingIA");
					desk.browse(uri);
				}
                catch (MalformedURLException e1)
                {
					e1.printStackTrace();
				}
                catch (IOException e1)
                {
					e1.printStackTrace();
				}
                catch (URISyntaxException e1)
                {
					e1.printStackTrace();
				}
        }
(20)关于:
if (e.getActionCommand().equals("关于"))
        {
            JOptionPane.showMessageDialog(new JFrame(),"***********************************\n" + "不足之处望提出意见,谢谢!\n" + "***********************************","记事本",JOptionPane.INFORMATION_MESSAGE);
        }
        if (e.getActionCommand().equals("发送反馈"))
        {

        }
    }
待添加功能:发送反馈,背景颜色,字体颜色…