⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 book.java

📁 这是一个用Java编写的类似Windows的记事本
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        bDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/delete.gif"))); // NOI18N        bDelete.setToolTipText("删除");        bDelete.setFocusable(false);        bDelete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);        bDelete.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);        bDelete.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                bDeleteActionPerformed(evt);            }        });        jToolBar2.add(bDelete);        bUndo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/undo.gif"))); // NOI18N        bUndo.setToolTipText("撤消");        bUndo.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                bUndoActionPerformed(evt);            }        });        jToolBar2.add(bUndo);        bRedo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/redo.gif"))); // NOI18N        bRedo.setToolTipText("恢复");        bRedo.setFocusable(false);        bRedo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);        bRedo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);        bRedo.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                bRedoActionPerformed(evt);            }        });        jToolBar2.add(bRedo);        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);        jPanel1.setLayout(jPanel1Layout);        jPanel1Layout.setHorizontalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addContainerGap()                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE))        );        jPanel1Layout.setVerticalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                    .addComponent(jToolBar2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                    .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))                .addContainerGap())        );        File.setBackground(new java.awt.Color(236, 233, 216));        File.setText("文件");        New.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));        New.setIcon(new javax.swing.ImageIcon(getClass().getResource("/new.gif"))); // NOI18N        New.setText("新建 ");        New.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                NewActionPerformed(evt);            }        });        File.add(New);        File.add(jSeparator1);        Open.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));        Open.setIcon(new javax.swing.ImageIcon(getClass().getResource("/open.gif"))); // NOI18N        Open.setText("打开");        Open.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                OpenActionPerformed(evt);            }        });        File.add(Open);        File.add(jSeparator2);        Save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));        Save.setIcon(new javax.swing.ImageIcon(getClass().getResource("/save.gif"))); // NOI18N        Save.setText("保存");        Save.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                SaveActionPerformed(evt);            }        });        File.add(Save);        SaveAs.setText("另存为");        SaveAs.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                SaveAsActionPerformed(evt);            }        });        File.add(SaveAs);        Print.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));        Print.setText("打印");        Print.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                PrintActionPerformed(evt);            }        });        File.add(Print);        File.add(jSeparator3);        Quit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));        Quit.setText("退出");        Quit.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                QuitActionPerformed(evt);            }        });        File.add(Quit);        jMenuBar1.add(File);        Edit.setBackground(new java.awt.Color(236, 233, 216));        Edit.setText("编辑");        Edit.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                EditActionPerformed(evt);            }        });        Undo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_MASK));        Undo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/undo.gif"))); // NOI18N        Undo.setText("撤消");        Undo.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                UndoActionPerformed(evt);            }        });        Edit.add(Undo);        Redo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/redo.gif"))); // NOI18N        Redo.setText("恢复   ");        Redo.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                RedoActionPerformed(evt);            }        });        Edit.add(Redo);        Edit.add(jSeparator4);        Copy.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));        Copy.setIcon(new javax.swing.ImageIcon(getClass().getResource("/copy.gif"))); // NOI18N        Copy.setText("复制");        Copy.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                CopyActionPerformed(evt);            }        });        Edit.add(Copy);        Cut.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));        Cut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cut.gif"))); // NOI18N        Cut.setText("剪切");        Cut.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                CutActionPerformed(evt);            }        });        Edit.add(Cut);        Paste.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK));        Paste.setIcon(new javax.swing.ImageIcon(getClass().getResource("/paste.gif"))); // NOI18N        Paste.setText("粘贴");        Paste.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                PasteActionPerformed(evt);            }        });        Edit.add(Paste);        Delete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/delete.gif"))); // NOI18N        Delete.setText("删除");        Delete.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                DeleteActionPerformed(evt);            }        });        Edit.add(Delete);        Edit.add(jSeparator5);        Search.setText("查找/替换");        Search.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                SearchActionPerformed(evt);            }        });        Edit.add(Search);        Insert.setText("插入");        Insert.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                InsertActionPerformed(evt);            }        });        Edit.add(Insert);        Time.setText("显示时间");        Time.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                TimeActionPerformed(evt);            }        });        Edit.add(Time);        SelectAll.setText("全选");        SelectAll.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                SelectAllActionPerformed(evt);            }        });        Edit.add(SelectAll);        jMenuBar1.add(Edit);        Form.setBackground(new java.awt.Color(236, 233, 216));        Form.setText("格式");        Font.setText("字体");        Font.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                FontActionPerformed(evt);            }        });        Form.add(Font);        SetColor.setText("字体颜色");        SetColor.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                SetColorActionPerformed(evt);            }        });        Form.add(SetColor);        BackColor.setText("背景颜色");        BackColor.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                BackColorActionPerformed(evt);            }        });        Form.add(BackColor);        jMenuBar1.add(Form);        Help.setBackground(new java.awt.Color(236, 233, 216));        Help.setText("帮助");        About.setText("关于记事本");        About.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                AboutActionPerformed(evt);            }        });        Help.add(About);        jMenuBar1.add(Help);        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(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 443, Short.MAX_VALUE)                    .addGroup(layout.createSequentialGroup()                        .addComponent(Label, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addGap(18, 18, 18)                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE)))                .addContainerGap())        );        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addContainerGap()                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)                    .addComponent(Label, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE))                .addContainerGap())        );        pack();    }// </editor-fold>//GEN-END:initComponents    private void EditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditActionPerformed                   }//GEN-LAST:event_EditActionPerformed

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -