[email protected]
也给我发一份吧,谢谢!
也给我发一份吧,谢谢!
解决方案 »
- java 实现发送syslog
- HttpUrlConnection的POST方法如何向一个带有参数的地址上传文件?
- 关于JPDA的问题
- 求助,当jtable选择的行改变时,会触发什么事件???就是本来是第一行,现在跳到第二行,这个动作会触发什么事件?
- 新手问hibernate映射的问题
- 在查阅JDK文档的时候,如何确定一些函数的参数?
- 如何在java应用程序中播放声音文件???
- 用工厂模式写了一个简单的显示新闻功能,可是到最后一步显示到页面上时出错了,有源码?愿望大哥帮忙看下
- 请教关于JSONObject的用法.
- 请教将一个ByteArrayOutputStream的流里的数据,写到d:\test.txt 文件里的方法。谢谢
- 如何象format 硬盘时一样显示当前的进度??
- 具体如何用socket传输服务器的对象,客户端如何接收?如何对ResultSet类进行序列化?
[email protected]
可以去DOWN一个学习
你可以参考一下package myprojects.w10;import java.io.*;
import java.awt.*;
import java.awt.event.*;class W10 extends Frame implements ActionListener
{
TextArea ta=new TextArea();
MenuBar mb=new MenuBar();
Menu m1=new Menu("File");
MenuItem open=new MenuItem("Open");
MenuItem close=new MenuItem("Close");
MenuItem save=new MenuItem("Save");
MenuItem exit=new MenuItem("exit");
FileDialog fileDlg;
String str,fileName;
byte byteBuf[]=new byte[1000000];
public W10()
{
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
add("Center",ta);
m1.add(open);
m1.add(close);
m1.add(save);
m1.addSeparator();
m1.add(exit);
open.addActionListener(this);
close.addActionListener(this);
save.addActionListener(this);
exit.addActionListener(this);
mb.add(m1);
setMenuBar(mb);
show();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==exit)
System.exit(0);
else if(e.getSource()==close)
ta.setText(null);
else if(e.getSource()==open)
{
fileDlg=new FileDialog(this,"Open File");
fileDlg.show();
fileName=fileDlg.getFile();
try
{
FileInputStream in=new FileInputStream(fileName);
in.read(byteBuf);
in.close();
str=new String(byteBuf);
ta.setText(str);
setTitle("Notepad-"+fileName);
}
catch(IOException ioe){}
}
else if(e.getSource()==save)
{
fileDlg=new FileDialog(this,"Save File",FileDialog.SAVE);
fileDlg.show();
fileName=fileDlg.getFile();
str=ta.getText();
byteBuf=str.getBytes();
try
{
FileOutputStream out=new FileOutputStream(fileName);
out.write(byteBuf);
out.close();
}
catch(IOException ioe){}
}
} public static void main(String args[]) {
W10 mainFrame = new W10();
mainFrame.setSize(500, 400);
mainFrame.setTitle("Notepad");
mainFrame.setVisible(true);
}
}
[email protected]
[email protected]
[email protected]我写的记事本:jNotepad 1.4 [支持关键字高亮]...各位看看...给个评价.
[email protected]