Swing中的標準對話框

          /**
          ?* @(#)TestJOptionPane.java
          ?*
          ?* TestJOptionPane application
          ?*
          ?* @author
          ?* @version 1.00 2007/1/22
          ?*/
          ?import javax.swing.*;
          ?import javax.swing.event.*;
          ?import java.awt.event.*;
          public class TestJOptionPane extends JFrame
          {
          ?String strValue=null;
          ??? public TestJOptionPane()
          ??? {
          ??? ?JOptionPane.showMessageDialog(/*this*/null,"程序已開始運行...","運行",JOptionPane.DEFAULT_OPTION);
          ??? ?JTextArea jta=new JTextArea();
          ??? ?JScrollPane jsp=new JScrollPane();
          ??? ?jsp.getViewport().add(jta);
          ??? ?this.getContentPane().add(jsp);
          ??? ?this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
          ??? ?strValue=JOptionPane.showInputDialog(null,"請輸入姓名:");
          ??? ?//jta.setText(strValue);
          ??? ?jta.append(strValue);
          ??? ?addWindowListener(new WindowAdapter()
          ??? ?{
          ??? ??public void windowClosing(WindowEvent e)
          ??? ??{
          ??? ???if(JOptionPane.OK_OPTION==JOptionPane.showConfirmDialog(TestJOptionPane.this,"確認要退出程序嗎?","Exit",JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE))
          ??? ???{
          ??? ????e.getWindow().dispose();
          ??? ???}
          ??? ???
          ??? ??}
          ??? ?});
          ??? ?
          ??? }
          ??? public static void main(String[] args)
          ??? {
          ??? ?
          ??? ?// TODO, add your application code
          ??? ?System.out.println("Hello World!");
          ??? ?TestJOptionPane mainFrame=new TestJOptionPane();
          ??? ?mainFrame.setTitle("TestJOptionPane");
          ??? ?mainFrame.setBounds(300,200,400,400);
          ??? ?mainFrame.setVisible(true);
          ??? }
          }

          posted on 2007-01-22 01:32 大頭劍客 閱讀(169) 評論(0)  編輯  收藏 所屬分類: 學習筆記

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導航

          統計

          公告

          寫字樓里寫字間,寫字間里程序員;
          程序人員寫程序,又拿程序換酒錢;
          酒醒只在網上坐,酒醉還來網下眠;
          酒醉酒醒日復日,網上網下年復年;
          但愿老死電腦間,不愿鞠躬老板前;
          奔馳寶馬貴者趣,公交自行程序員;
          別人笑我忒瘋癲,我笑自己命太賤;
          不見滿街漂亮妹,哪個歸得程序員.
          不管前面是地雷陣還是萬丈深淵,
          我都將勇往直前,義無反顧,
          鞠躬盡瘁,死而后已。
          —— 朱镕基總理

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章分類

          文章檔案

          學習園地

          最新隨筆

          搜索

          積分與排名

          最新評論

          主站蜘蛛池模板: 蛟河市| 囊谦县| 咸阳市| 若尔盖县| 鹤峰县| 英吉沙县| 蓬莱市| 汝南县| 杂多县| 青海省| 北辰区| 九龙城区| 大港区| 石柱| 江川县| 长汀县| 论坛| 墨竹工卡县| 金昌市| 汝阳县| 揭东县| 阿拉善盟| 五家渠市| 华坪县| 霍州市| 米脂县| 辽源市| 小金县| 浮山县| 天全县| 印江| 扬州市| 团风县| 洛浦县| 宿松县| 瑞金市| 龙山县| 芦山县| 大悟县| 蒙阴县| 浦江县|