1 Introduction to Java Programming Lecture 4 Using JOptionPane Spring 2010.

Slides:



Advertisements
Similar presentations
Introduction to Java Programming Lecture 10 Method Benefits, Declaring, and Calling Methods.
Advertisements

6-1 指標簡介 6-2 指標與陣列 6-3 動態配置記憶體 6-4 本章綜合練習
Introduction to Java Programming Lecture 13 Classes I OO Programming.
第 10 章 Java 的執行緒 10-1 執行緒的基礎 10-2 Java 執行緒的使用方法 10-3 Java 執行緒的同步 10-4 管道串流的執行緒.
學習C++的基本語法 認識關鍵字與識別字的不同 學習程式碼偵錯的流程 學習如何提高程式的可讀性
: A-Sequence 星級 : ★★☆☆☆ 題組: Online-judge.uva.es PROBLEM SET Volume CIX 題號: Problem D : A-Sequence 解題者:薛祖淵 解題日期: 2006 年 2 月 21 日 題意:一開始先輸入一個.
Chapter 2 - Introduction to Java Applications
Reference, primitive, call by XXX 必也正名乎 誌謝 : 部份文字取於前輩 TAHO 的文章.
What is static?. Static? 靜態 ? class Test { static int staticX; int instanceX; public Test(int var1, int var2) { this.staticX = var1; this.instanceX =
多媒體安全 Macros Examples Gamma.txt 報告學生:碩專 2A 王朝鵬 ( ) 指導教授:黃文楨 博士.
Android Class vs. Jar 建國科技大學 資管系 饒瑞佶 2013/4 V1. 從 MyAndroidProject 專案改起 將 BMI_method.java 改寫成 class 方式 步驟 1 :在原 package 內新增一個 class.
1 Web of Science 利用指引 單元二 瀏覽與處理查詢結果. 2 瀏覽檢索結果 查出的結果,預設以時間排列, 使用者可改變結果的排列方式: 還可以依被引用次數、相關度、 第一作者、刊名、出版年等排序 回到前先查的結果畫面 點選想看資料的完整書目 本館訂購範圍的期刊 全文,便可直接連結.
第一章 變數、常數及資料型態. 變數 C 程式語言的變數名稱 第一個字必須是英文字母或底線 (_) 之後可以是數字, 英文字母或底線 (_) 不可以是保留字 例: Num (Ο) _score (Ο) C&C (X) 8num (X)
: ShellSort ★★☆☆☆ 題組: Problem D 題號: 10152: ShellSort 解題者:林一帆 解題日期: 2006 年 4 月 10 日 題意:烏龜王國的烏龜總是一隻一隻疊在一起。唯一改變烏龜位置 的方法為:一隻烏龜爬出他原來的位置,然後往上爬到最上方。給 你一堆烏龜原來排列的順序,以及我們想要的烏龜的排列順序,你.
: Problem E - Beverages ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11060: Problem E - Beverages 解題者:李重儀 解題日期: 2008 年 3 月 4 日 題意: Dilbert 大學剛畢業,他決定要和朋友出去。他有奇怪的嗜好,
程式註解說明. 2 程式註解格式 塊狀註解 對檔案、 class 、 method 、資料結構、一段程式 …. 等程式區塊 做說明。 第一行的開頭必需為 “/*” 且沒有其他文字,最後一行的開頭 必需以 “*/” 做為結束,在中間每一行的開頭都必需是一個 “*” 。 單行註解 佔據一整行的說明。 以.
1 Introduction to Java Programming Lecture 4 Using JOptionPane Spring 2008.
JAVA 程式設計與資料結構 第十章 GUI Introdution III. File Chooser  File Chooser 是一個選擇檔案的圖形介面, 無論我們是要存檔還是要開啟檔案,使 用這個物件都會讓我們覺得容易且舒適。
Introduction to Java Programming Lecture 5: Using Java Classes : String & Math Spring 2009.
Introduction to Java Programming Lecture 15 Objects and Classes.
軟體保護技術及其弱點 序列號保護與弱點. 組員名單 資訊三乙 D 吳俊緯 資訊三乙 D 吳俊緯 資訊三乙 D 陳品端 資訊三乙 D 陳品端.
Introduction to Java Programming Lecture 17 Abstract Classes & Interfaces.
7 陣列與搜尋 7.1 陣列 一般資料變數 宣告一維陣列 起始一維陣列 7-4
: Tight words ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: : Tight Words 解題者:鐘緯駿、林一帆 解題日期: 2006 年 03 月 14 日 題意: 給定數字 k 與 n (0 ≦ k.
Hung-Hsiang WuWindows Processing Design1 Chapter 3 基本觀念 變數宣告與型態 特殊運算子符號 字串與數值的轉換 類別與物件的觀念 建立新的專案 WinMain 程式進入點 Include Header File.
: Multisets and Sequences ★★★★☆ 題組: Problem Set Archive with Online Judge 題號: 11023: Multisets and Sequences 解題者:葉貫中 解題日期: 2007 年 4 月 24 日 題意:在這個題目中,我們要定義.
第 13 章 檔案與資料夾處理 13-1 檔案與資料夾操作 13-1 檔案與資料夾操作 13-2 循序檔案的文字檔案讀寫 13-2 循序檔案的文字檔案讀寫 13-3 隨機檔案的處理 13-3 隨機檔案的處理 13-4 二進位檔案的讀寫 13-4 二進位檔案的讀寫 13-5 檔案對話方塊 13-5 檔案對話方塊.
資料結構實習-一 參數傳遞.
6-2 認識元件庫與內建元件庫 Flash 的元件庫分兩種, 一種是每個動畫專 屬的元件庫 (Library) ;另一種則是內建元 件庫 (Common Libraries), 兩者皆可透過 『視窗』功能表來開啟, 以下即為您說明。
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2008.
Management Abstracts Retrieval System; MARS 檢索操作.
資料結構實習-二.
845: Gas Station Numbers ★★★ 題組: Problem Set Archive with Online Judge 題號: 845: Gas Station Numbers. 解題者:張維珊 解題日期: 2006 年 2 月 題意: 將輸入的數字,經過重新排列組合或旋轉數字,得到比原先的數字大,
Introduction to Java Programming Lecture 9 Flow Control : while do-while and for loops II.
School of Computing Science CMT1000 Ed Currie © Middlesex University Lecture 4: 1 CMT1000: Introduction to Programming Ed Currie Lecture 5a: Input and.
File I/O 範例講解 授課:林哲嘉 日期: 2009/04/29. 範例:上機考第三題 Add 部分 1. 將檔案的資料顯示在畫面 2. 將要加入檔案加到資料的尾端.
資料結構實習-十 Binary Tree Traversal.
第 17 章 樣板 17-1 樣板的基礎 17-1 樣板的基礎 17-2 樣板函數 17-2 樣板函數 17-3 樣板類別 17-3 樣板類別 17-4 非型態參數的樣板類別 17-4 非型態參數的樣板類別 17-5 樣板類別的繼承 17-5 樣板類別的繼承 17-6 特化樣板與靜態成員 17-6 特化樣板與靜態成員.
: Function Overloading ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11032:Function Overloading 解題者:許智祺 解題日期: 2007 年 5 月 8 日 題意:判對輸入之數字是否為.
Chapter 2 - Introduction to Java Applications
1 Introduction to Java Programming Lecture 6 Program Input : BufferedReader & Scanner.
Extreme Discrete Summation ★★★★☆ 題組: Contest Archive with Online Judge 題號: Extreme Discrete Summation 解題者:蔡宗翰 解題日期: 2008 年 10 月 13 日.
組合語言與系統程式 軟體使用教學. 軟體下載及安裝 下載 到課程網頁下載 tw/~jiun/ 安裝 解壓縮後將 System Software 資料夾放在 D 槽 (C 槽版本放在 C 之下 )
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2009.
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
5 重複迴圈 5.1 增減運算符號 增量運算符號 減量運算符號
Introduction to Java Programming Lecture 12 Method Benefits, Declaring, and Calling Methods.
-Artificial Neural Network- Matlab操作介紹 -以類神經網路BPN Model為例
Visual C++重點複習.
資料結構實習-六.
1 Introduction to Java Programming Lecture 3 Mathematical Operators Spring 2008.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2010.
What is static? CS340100, NTHU Yoshi. Static? 靜態 ? class Test { static int staticX; int instanceX; public Test(int var1, int var2) { this.staticX = var1;
Introduction to Java Programming Lecture 16 Super and Sub Classes.
6 使用者函數 6.1 函數定義 宣告函數 呼叫函數 呼叫多個函數 6-6
1 Introduction to Java Programming Lecture 3 Mathematical Operators Spring 2009.
: How many 0's? ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11038: How many 0’s? 解題者:楊鵬宇 解題日期: 2007 年 5 月 15 日 題意:寫下題目給的 m 與 n(m
1 生物計算期末作業 暨南大學資訊工程系 2003/05/20. 2 如何從 C/C++ 讀入參數 int main(int argc, char* argv[])  argc: 參數的個數, argc>0  argv[0]: 目前被執行的檔案名稱,以字串表示  argv[1]: 第一個參數,以字串表示.
物件導向實習 極高的忘記答題率 … AB 卷都有的題目 : 4(1). Define method overloading 明明寫出了方法, 卻不回答老師的題目 (1)( 只要 寫出定義就好了 ) 另外, 讀題一定要仔細 : Two overloaded methods average.
Java Tutorial /10/21. Java Resource Java SDK –Download from –Install Jdk windows-i586.exe –
9/6: Variable Types, Arithmetic Operators, Comparison Operators Addition.java in depth Variable types & data types Input from user: how to get it Arithmetic.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 2 - Introduction to Java Applications Outline 2.1Introduction 2.2A Simple Program: Printing a.
1 COMP 241: Object-Oriented Programming with Java Fall 2004 Lecture 1 September 27, 2004 Serdar Taşıran.
1/23: Java Modular Components Identifiers: naming requirements for Java variables & objects Stepping out of the MS-DOS window: The Java Modular Component:
1/28: Inputs, Variable Types, etc. Addition.java in depth Variable types & data types Input from user: how to get it Arithmetic operators.
南台科技大學 機械工程系 奈米一乙 學號 :4A 老師 : 謝慶存 計算機程式及實習 期末報告 ppt 製作 泡麵品牌票選 題目 : 泡麵品牌票選.
A Java Program: // Fig. 2.1: Welcome1.java // Text-printing program.
2.5 Another Java Application: Adding Integers
Chapter 2 - Introduction to Java Applications
Presentation transcript:

1 Introduction to Java Programming Lecture 4 Using JOptionPane Spring 2010

2 Displaying Text in a Dialog Box ( 使用 JOptionPane 來顯示 ) Display ( 顯示 ) – 顯示資料的方式有 : Command Windows, Graphic Window, Dialog Box … –Class JOptionPane 提供了 Dialog Box 的顯示方式 Packages – 一組已經寫好了的 classes – 相類似的 classes 組成 packages 所有的 packages 被稱為 Java class library 或 Java applications programming interface (Java API) –JOptionPane 是 javax.swing 這個 package 裡 的一個 class, 同時也包含其他 Graphical User Interfaces (GUIs) 的 classes

3 Displaying Text in a Dialog Box ( 使用 JOptionPane 來顯示 ) // 檔名 : Welcome.java // 利用 java package javax.swing 顯示數行文字 import javax.swing.JOptionPane; // 程式使用了 JOptionPane public class Welcome { public static void main( String args[] ) { JOptionPane.showMessageDialog( null, "Welcome\nto\nJava\nProgramming!" ); System.exit( 0 ); // 可略過這一行 } // end method main } // end class Welcome

4 Inputing using JOptionPane ( 使用 JOptionPane 來輸入資料 ) // 檔名 : Addition.java // 整數相加 Addition program that displays the sum of two numbers. // Java packages import javax.swing.JOptionPane; // program uses JOptionPane public class Addition { // main method begins execution of Java application public static void main( String args[] ) { String firstNumber; // 用來存放使用者輸入的第一個字串 String secondNumber; // 用來存放使用者輸入的第二個字串

5 int number1; // 宣告第一個整數變數來存放輸入的數字 int number2; // 宣告第二個整數變數來存放輸入的數字 int sum; // 數字的和 // 讀進使用者輸入的第一個數字, JOptionPane 的輸入是字串 firstNumber = JOptionPane.showInputDialog( "Enter first integer" ); // 讀進使用者輸入的第二個數字 secondNumber= JOptionPane.showInputDialog("Enter second integer" ); number1 = Integer.parseInt( firstNumber ); // 把 數字從字串 String number2 = Integer.parseInt( secondNumber ); // 轉換為 int sum = number1 + number2; // 相加 JOptionPane.showMessageDialog( null, "The sum is " + sum, "Results", JOptionPane.PLAIN_MESSAGE ); System.exit( 0 ); // 這行可省略 } // end method main } // end class Addition

6 Output

7 Message Icons