最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

java编程记事本代码

IT圈 admin 30浏览 0评论

2024年6月15日发(作者:柴初珍)

import .*; import .*; import .*; import .*;

public class Notepad extends JFrame {係统组件声明 private JMenuBar menuBar = new

JMe nuBar(; private JEditorPa ne content = new JEditorPa ne(; private JScrollPa ne scroll

= new JScrollPa ne(c ontent; private JFileChooser filechooser = new JFileChooser(;

private BorderLayout bord = new BorderLayout(; private JLabel statusBar = new JLabel(;

private JPanel pane = new JPanel(; private File file = null; /定义文件菜单 private JMenu

fileMenu = new JMenu(; private JMenultem newMenultem = new JMenultem(; private JMe

nultem ope nMen ultem = new JMe nultem(; private JMe nultem saveMe nultem = new JMe

nultem(; private JMe nultem saveAsMe nultem = new JMe nultem(; private JMe nultem

pageSetupMe nultem = new JMe nultem(; private JMe nultem prin tMe nultem = new JMe

nultem(; private JMe nultem exitMe nultem = new JMenultem(; // 定义风格菜单 private

JMenu styleMenu = new JMenu(; private Butt on Group styleMe nu Group = new Butt on

Group(; private JRadioButt onMen ultem javaStyleMe nultem = new JRadioButt onMen

ultem(; private JRadioButt onMen ultem metalStyleMe nultem = new JRadioButt onMen

ultem(; private JRadioButt onMen ultem windowsStyleMenultem = new

JRadioButtonMenultem(; // 定义帮助菜单 private JMe nultem aboutMe nultem = new JMe

nultem(; private JMe nultem helpTopicMe nultem =new JMenultem(; private JMenu

helpMenu = new JMenu(; 〃构造函数 public Notepad({ initComponents(; } private void

initComponents({ // 添加子菜单项到文件菜 单 fileMe t("u6587u4ef6 (F"; n

ewMe t(” 新建(N

Ctrl+N"; ope nMen t(” 打开

(

O…

保存(S

Ctrl+O"; saveMe t(”

Ctrl+S"; t(” 另存为(A...";

t(” 页面设置(U..."; t(” 打印

(

P... Ctrl+P";

exitMe t(” 退出";fileMe ( newMe nultem;

fileMe nu .add(ope nMen ultem; fileMe nu .add(saveMe nultem; fileMe nu .add(saveAsMe

nultem; fileMe arator(; (pageSetupMenultem;

(printMenultem; fileMe arator(; fileMe (exitMe nultem; // 添

加子菜单项到风格菜单 styleMe t(‘ 风格(S"; javaStyleMe t("Java 默

认";

metalStyleMe t("Metal 风格";wi ndowsStyleMe t("Wi ndows 风

格";styleMe (javaStyleMe nultem;

styleMe (metalStyleMe nuItem;

styleMe nu (wi ndowsStyleMe nultem; styleMe nu .add(javaStyleMe nultem;

styleMe (metalStyleMe nultem; styleMe (wi ndowsStyleMe nultem; // 添加子

菜单项到帮助菜单 t(‘帮助(H"; t(” 帮助

主题(H"; t(” 关于记事本(A";

helpMe nu .add(helpTopicMe nultem; helpMe nu .addSeparator(;

helpMe nu .add(aboutMe nultem; //定义文件菜单下的事件监听

n ewMe io nListe ner(new n ewMe nultem_actio nAdapter(this; ope nMen

io nListe ner(new ope nMen ultem_actio nAdapter(this; saveMe

io nListe ner(new saveMe nultem_actio nAdapter(this; saveAsMe

io nListe ner(new saveAsMe nultem_actio nAdapter(this; pageSetupMe

io nListe ner(new pageSetupMe nultem_actio nAdapter(this; prin tMe

i on Liste ner(n ew prin tMe nultem_actio nAdapter(this;

ionListener(new exitMenultem_actionAdapter(this; // 定义风格菜 单

下的事件监听 ionListener(new

javaStyleMenultem_actionAdapter(this; ionListener(new

metalStyleMe nultem_actio nAdapter(this;

wi ndowsStyleMe io nListe ner(new

wi ndowsStyleMe nultem_actio nAdapter(this; // 定义帮助菜单下的事件监听 helpTopicMe

io nListe ner(new helpTopicMe nultem_actio nAdapter(this; aboutMe

io nListe ner(new aboutMe nultem_actio nAdapter(this; 〃填加菜单 至U菜

单栏 (fileMenu; (styleMenu; (helpMenu; // 对主窗

2024年6月15日发(作者:柴初珍)

import .*; import .*; import .*; import .*;

public class Notepad extends JFrame {係统组件声明 private JMenuBar menuBar = new

JMe nuBar(; private JEditorPa ne content = new JEditorPa ne(; private JScrollPa ne scroll

= new JScrollPa ne(c ontent; private JFileChooser filechooser = new JFileChooser(;

private BorderLayout bord = new BorderLayout(; private JLabel statusBar = new JLabel(;

private JPanel pane = new JPanel(; private File file = null; /定义文件菜单 private JMenu

fileMenu = new JMenu(; private JMenultem newMenultem = new JMenultem(; private JMe

nultem ope nMen ultem = new JMe nultem(; private JMe nultem saveMe nultem = new JMe

nultem(; private JMe nultem saveAsMe nultem = new JMe nultem(; private JMe nultem

pageSetupMe nultem = new JMe nultem(; private JMe nultem prin tMe nultem = new JMe

nultem(; private JMe nultem exitMe nultem = new JMenultem(; // 定义风格菜单 private

JMenu styleMenu = new JMenu(; private Butt on Group styleMe nu Group = new Butt on

Group(; private JRadioButt onMen ultem javaStyleMe nultem = new JRadioButt onMen

ultem(; private JRadioButt onMen ultem metalStyleMe nultem = new JRadioButt onMen

ultem(; private JRadioButt onMen ultem windowsStyleMenultem = new

JRadioButtonMenultem(; // 定义帮助菜单 private JMe nultem aboutMe nultem = new JMe

nultem(; private JMe nultem helpTopicMe nultem =new JMenultem(; private JMenu

helpMenu = new JMenu(; 〃构造函数 public Notepad({ initComponents(; } private void

initComponents({ // 添加子菜单项到文件菜 单 fileMe t("u6587u4ef6 (F"; n

ewMe t(” 新建(N

Ctrl+N"; ope nMen t(” 打开

(

O…

保存(S

Ctrl+O"; saveMe t(”

Ctrl+S"; t(” 另存为(A...";

t(” 页面设置(U..."; t(” 打印

(

P... Ctrl+P";

exitMe t(” 退出";fileMe ( newMe nultem;

fileMe nu .add(ope nMen ultem; fileMe nu .add(saveMe nultem; fileMe nu .add(saveAsMe

nultem; fileMe arator(; (pageSetupMenultem;

(printMenultem; fileMe arator(; fileMe (exitMe nultem; // 添

加子菜单项到风格菜单 styleMe t(‘ 风格(S"; javaStyleMe t("Java 默

认";

metalStyleMe t("Metal 风格";wi ndowsStyleMe t("Wi ndows 风

格";styleMe (javaStyleMe nultem;

styleMe (metalStyleMe nuItem;

styleMe nu (wi ndowsStyleMe nultem; styleMe nu .add(javaStyleMe nultem;

styleMe (metalStyleMe nultem; styleMe (wi ndowsStyleMe nultem; // 添加子

菜单项到帮助菜单 t(‘帮助(H"; t(” 帮助

主题(H"; t(” 关于记事本(A";

helpMe nu .add(helpTopicMe nultem; helpMe nu .addSeparator(;

helpMe nu .add(aboutMe nultem; //定义文件菜单下的事件监听

n ewMe io nListe ner(new n ewMe nultem_actio nAdapter(this; ope nMen

io nListe ner(new ope nMen ultem_actio nAdapter(this; saveMe

io nListe ner(new saveMe nultem_actio nAdapter(this; saveAsMe

io nListe ner(new saveAsMe nultem_actio nAdapter(this; pageSetupMe

io nListe ner(new pageSetupMe nultem_actio nAdapter(this; prin tMe

i on Liste ner(n ew prin tMe nultem_actio nAdapter(this;

ionListener(new exitMenultem_actionAdapter(this; // 定义风格菜 单

下的事件监听 ionListener(new

javaStyleMenultem_actionAdapter(this; ionListener(new

metalStyleMe nultem_actio nAdapter(this;

wi ndowsStyleMe io nListe ner(new

wi ndowsStyleMe nultem_actio nAdapter(this; // 定义帮助菜单下的事件监听 helpTopicMe

io nListe ner(new helpTopicMe nultem_actio nAdapter(this; aboutMe

io nListe ner(new aboutMe nultem_actio nAdapter(this; 〃填加菜单 至U菜

单栏 (fileMenu; (styleMenu; (helpMenu; // 对主窗

发布评论

评论列表 (0)

  1. 暂无评论