初学者请教一程序 你应该自己查资料作,遇到不明白的具体问题可以上来问问 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 好的,我可以提供参考程序,明天给 import java.awt.*;import java.io.*;import java.awt.event.*;public class freeask { public static void main(String []S) { new myframe(); }}class myframe extends Frame implements ActionListener{ TextArea t; Button bt; FileDialog f; myframe() { super("文本保存"); this.setLayout(new FlowLayout()); this.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ dispose(); System.exit(0); } }); t=new TextArea(20,20); this.add(t); bt=new Button("保存文本"); bt.addActionListener(this); this.add(bt); this.setSize(300,300); this.show(); } public void actionPerformed(ActionEvent e) { if(e.getSource()==bt) { f=new FileDialog(this,"选择保存的文件",FileDialog.SAVE); f.show(); try { File myfile=new File(f.getDirectory(),f.getFile()); RandomAccessFile r=new RandomAccessFile(myfile,"rw"); String s=t.getText(); r.writeChars(s); }catch(IOException ie){} } }} java awt 问题 求!javax.swing类中的JTable做个简单的表格怎么做?求代码! 面试编程求解 基础知识很重要!! 这样一个时间字符串:2008-08-08 20:08:08 , 请编写能够匹配它的正则表达式 为学JAVA散分~ JFileChooser的打开对话框,如何能选择一个文件夹,点击确定,就关闭对话框? 关于socket,请大牛们帮忙看一下。。。。 这些都是什么错误呀 较简单,但搞不定的一个问题:关于滚动条。几行代码,烦请相助! static一点小问题 自从创建的文件放在什么地方了?
import java.io.*;
import java.awt.event.*;
public class freeask
{
public static void main(String []S)
{
new myframe();
}
}
class myframe extends Frame implements ActionListener
{
TextArea t;
Button bt;
FileDialog f;
myframe()
{
super("文本保存");
this.setLayout(new FlowLayout());
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
t=new TextArea(20,20);
this.add(t);
bt=new Button("保存文本");
bt.addActionListener(this);
this.add(bt);
this.setSize(300,300);
this.show();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==bt)
{
f=new FileDialog(this,"选择保存的文件",FileDialog.SAVE);
f.show();
try
{
File myfile=new File(f.getDirectory(),f.getFile());
RandomAccessFile r=new RandomAccessFile(myfile,"rw");
String s=t.getText();
r.writeChars(s);
}catch(IOException ie){}
}
}
}