有点问题的代码
2008-03-27 22:28
288 查看
一个有问题的程序。。
import javax.swing.*; import java.awt.event.*; import java.awt.*; class EditBook { public static void main(String[] args) { Edit e=new Edit(); e.run(); } } class Edit extends JFrame { JMenuBar jmb; JMenu file; JMenu compile; JMenu tool; JMenu help; JMenuItem newF; JMenuItem open; JMenuItem save; JMenuItem exit; JMenuItem copy; JMenuItem cut; JMenuItem paste; JMenuItem s_all; JMenuItem color; JMenuItem toolb; JMenuItem toolc; JMenuItem h; JTextArea jta; JDialog jd; JPanel jp; JToolBar jtb; String message; public void run(){ jmb=new JMenuBar(); jp=new JPanel(); file=new JMenu("文件"); compile=new JMenu("编辑"); tool=new JMenu("工具"); help=new JMenu("帮助"); newF=new JMenuItem("新建"); open=new JMenuItem("打开"); save=new JMenuItem("保存"); exit=new JMenuItem("退出"); copy=new JMenuItem("Copy"); cut=new JMenuItem("Cut"); paste=new JMenuItem("Paste"); s_all=new JMenuItem("保存全部"); color=new JMenuItem("Color"); toolb=new JMenuItem("MS记事本"); toolc=new JMenuItem("MS计算器"); h=new JMenuItem("关于"); jtb=new JToolBar("MyJToolBar"); jta=new JTextArea(20,30); /* ef.addWindowListener(new WindowAdapter(WindowEvent e){ System.exit(0); }); */ //文件 file.add(newF); file.add(open); //////////如何显示文件内容 open.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ jd=new JDialog(new JFrame(),"Color"); JFileChooser jfc=new JFileChooser(); String f=jfc.getName(); System.out.println(f); jd.add(jfc); jd.pack(); jd.setVisible(true); } }); file.add(save); file.add(exit); exit.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ System.exit(0); } }); //编辑 compile.add(copy); copy.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ jta.copy(); } }); compile.add(cut); cut.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ jta.cut(); } }); compile.add(paste); paste.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ jta.paste(); } }); compile.add(s_all); compile.add(color); color.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ jd=new JDialog(new JFrame(),"Color"); jd.add(new JColorChooser()); jd.pack(); jd.setVisible(true); } }); //工具 tool.add(toolb); tool.add(toolc); toolc.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ Calculate cc=new Calculate(); cc.display(); } }); //帮助 help.add(h); jmb.add(file); jmb.add(compile); jmb.add(tool); jmb.add(help); jtb.add(new JButton(new ImageIcon("copy.jpg"))); jtb.add(new JButton(new ImageIcon("copy.jpg"))); jtb.add(new JButton(new ImageIcon("copy.jpg"))); jp.setLayout(new BorderLayout()); jp.add("North",jtb); jp.add("Center",jta); this.setJMenuBar(jmb); this.add(jp); this.pack(); this.setTitle("简单文本编辑器"); this.setLocation(100,150); this.setVisible(true); } }
相关文章推荐
- 如下这段代码怎么传递动态参数比较合适?(问题有点长~谢谢)
- IOS 自动适配的代码 有点问题
- 今天碰到个怪异的问题..js代码和c#得出的结果大多一样,个别有点区别
- HandlerMapping实现代码感觉有点问题
- 一段蓝牙通讯代码(似乎有点问题)
- 书上的代码总觉得有点问题
- 从懒人图库下载下来的一个图片播放效果有点问题,修改了一处代码之后ok了
- 学习Opencv中文版--例2--10,书上的代码有点问题,现在把遇到的问题及解决方案作总结
- HTML5+学习笔记2-------边看代码边研究貌似还是有点问题...还在研究中api中
- 有点问题的代码
- c#.NET 连接 SQLServer 的代码和遇到的问题
- js更改TextBox只读后,后台代码取TextBox值的问题
- Keil uVision4 代码编辑器中文字符乱码问题
- 使用axis编写客户端代码调用webservice的一些问题
- 解决`向github提交代码是老要输入用户名密码`的问题
- 代码数值DataReader没有Close之前与Output参数的问题
- 前端小总结第一幕:关于多人一起开发的前端样式代码管理问题
- 关于点击事件提交代码到后台发现控件被重置的问题
- 记住一句话,阅读优秀的代码可以知道怎么写,做项目,可以解决问题!
- 分枝界限法-N皇后问题代码