日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

记事本写html怎么加a1图片,记事本-功能待添加

發布時間:2023/12/2 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 记事本写html怎么加a1图片,记事本-功能待添加 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

IO流、圖形化用戶界面、事件監聽

import java.awt.event.*;

import javax.swing.*;

import java.io.*;

public class Jsb extends JFrame implements ActionListener

{

JMenuBar cd;

JMenu cd1,cd2;

JMenuItem cdx1,cdx2;

JTextArea wby;

JScrollPane gd;

public static void main(String[] args)

{

Jsb js=new Jsb();

}

Jsb()

{

cd=new JMenuBar();

cd1=new JMenu("文件(F)");

cd1.setMnemonic('F');

cd2=new JMenu("編輯(E)");

cd2.setMnemonic('E');

cdx1=new JMenuItem("打開",new ImageIcon("photo/dk.jpg"));

cdx1.addActionListener(this);

cdx1.setActionCommand("open");

cdx2=new JMenuItem("保存",new ImageIcon("photo/bc.jpg"));

cdx2.addActionListener(this);

cdx2.setActionCommand("save");

wby=new JTextArea();

gd=new JScrollPane(wby);

cd1.add(cdx1); cd1.add(cdx2);

cd.add(cd1); cd.add(cd2);

this.setJMenuBar(cd); this.add(gd);

ImageIcon tp1=new ImageIcon("photo/jsb.jpg");

this.setIconImage(tp1.getImage());

this.setTitle("記事本");

this.setSize(400,300);

this.setLocation(300,280);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

}

public void actionPerformed(ActionEvent e)

{

if(e.getActionCommand().equals("open")) //

{

JFileChooser wjxz=new JFileChooser();//文件選擇框

wjxz.setDialogTitle("文件打開"); //對話框標題

wjxz.showOpenDialog(null);//顯示打開對話框的模式,null默認

wjxz.setVisible(true);

String wjlj=wjxz.getSelectedFile().getAbsolutePath();//選擇文件的全路徑

FileReader wjl=null; BufferedReader hcl=null;

try

{

wjl=new FileReader(wjlj);

hcl=new BufferedReader(wjl);

String s="",zfc="";

while((s=hcl.readLine())!=null)

{

zfc+=(s+"\n");

}

wby.setText(zfc);

}

catch(Exception a){}

finally

{

try

{

wjl.close();

hcl.close();

}

catch(Exception a1){}

}

}

else if(e.getActionCommand().equals("save"))

{

JFileChooser wjxz1=new JFileChooser();

wjxz1.setDialogTitle("另存為");

wjxz1.showSaveDialog(null);

wjxz1.setVisible(true);

String wjlj1=wjxz1.getSelectedFile().getAbsolutePath();

try

{

PrintStream pl=new PrintStream(wjlj1);

System.setOut(pl);

System.out.println(this.wby.getText());

}

catch(Exception a2){}

finally

{

try

{

}

catch(Exception a2){}

}

}

}

}

本人初學者,旨在記錄學習java的過程,歡迎大家指正,如果有針對上述部分代碼更優秀的代碼請寫在評論區,我一定會回復感謝并更正。

總結

以上是生活随笔為你收集整理的记事本写html怎么加a1图片,记事本-功能待添加的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。