B 10 : N ip2003f10.tex B : 9/12/ :02 p.1/71

Similar documents
/ ( ) 8/7/ :21 p.2/64

text_12.dvi

......() JButton

awt の主要なクラスを下記に示す クラス Component Container Button Label Panel Frame 説明画面にユーザインターフェイス要素として表示し, ユーザとのやり取りを行うコンポーネントを表すすべてのコンポーネントのスーパークラスになる ほかのコンポーネントを含

2 static final int DO NOTHING ON CLOSE static final int HIDE ON CLOSE static final int DISPOSE ON CLOSE static final int EXIT ON CLOSE void setvisible

IE6 2 BMI chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chap

public class MyFrame { private JPanel panel1; private JPanel panel2; private JPanel panel3; private JPanel panel4; private JLabel label1; private JTex

1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3

public class Kadai _02 { public static void main(string[] args) { MyFrame frame = new MyFrame("Kadai _02"); (2) フレームのクラス名は MyFrame とし 以下

ガイダンス

text_13.dvi

次の演習課題(1),(2)のプログラムを完成させよ

ガイダンス

Java言語 第1回

ガイダンス

PowerPoint Presentation

r1.dvi

ÿþ˜u#u·0¹0Æ0à0

目 次 Java GUI 3 1 概要 クラス構成 ソースコード例 課題...7 i

Java演習(4) -- 変数と型 --

Microsoft PowerPoint - prog13.ppt

Safari AppletViewer Web HTML Netscape Web Web 15-1 Applet Web Applet init Web paint Web start Web HTML stop destroy update init Web paint start Web up

ソフトウェア基礎演習 課題

Thread

< F2D834F838C A815B A CC>

< F2D B838A835882CC8CF68EAE2E6A7464>

I. (i) Foo public (A). javac Foo.java java Foo.class (C). javac Foo java Foo (ii)? (B). javac Foo.java java Foo (D). javac Foo java Foo.class (A). Jav

2

Microsoft PowerPoint - prog13.ppt

6 p.1 6 Java GUI GUI paintcomponent GUI mouseclicked, keypressed, actionperformed mouseclicked paintcomponent thread, 1 GUI 6.0.2, mutlithread C

2

Microsoft PowerPoint - swing2.ppt

ガイダンス

Microsoft PowerPoint - swing3.ppt

Local variable x y i paint public class Sample extends Applet { public void paint( Graphics gc ) { int x, y;... int i=10 ; while ( i < 100 ) {... i +=

ガイダンス

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>

r4.dvi

:30 12:00 I. I V II. III. IV. ( a d) V. VI : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeyliste

I. java.awt.rectangle java.lang.math random Java TM API java.awt Rectangle Rectangle (x,y)... public int x Rectangle X public int y Rectangle Y public

GUI プログラミング第 4 Graph ~ 手書認識と関数グラフ描画 ~ マウスで数式を書いて認識し 関数グラフを描画する < 手書認識とグラフ描画のステップ> ステップ 1_1 フレームの作成 ステップ 1_2 マウスで自由に線を書く ステップ 2-1 手書認識認識結果を標準出力する ステップ

< F2D F B834E2E6A7464>

< F2D E E6A7464>

< F2D825282CC947B909482CC A815B83682E6A>

< F2D82518CC282CC D2E6A7464>

PowerPoint Presentation

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

I HTML HashMap (i) (ii) :.java import java.net.*; import java.io.*; import java.util.hashmap; public class SimpleStopWatch { public static voi

< F2D82B682E182F182AF82F12E6A7464>

< F2D92DE82E8914B82CC977088D32E6A7464>

< F2D BCA82CC978E89BA82CC8EC08CB12E6A7464>

r8.dvi

Animals サンプル Step3 張り付けた動物の上をクリックすると それぞれの鳴き声で鳴く その鳴く間 一定時間 ( ここでは 1 秒間 ) 画像が別のものに変わる <アニメーションの基礎 : タイマーについて> アニメーションは アプリケーションが指定する間 一定間隔でどんどん画像をおきかえ

自宅でJava言語の開発環境を作る方法

アジェンダ 1 グラフィカルなインタフェース GUI(Graphical User Interface) の基礎 2 Swing を利用する Swing の基礎知識 2

Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem

Prog1_12th

Microsoft PowerPoint - prog12.ppt

try catch Exception Java try catch try { } catch ( Exception e ) { } e 16-1 try catch 0 try { int x = 0; int y = 10 / x; } catch ( Exception e ) { Sys

r2.dvi

< F2D A839382CC906A2E6A7464>

I java A

< F2D8EA CE909482CC92EA82852E6A7464>

I 4 p.2 4 GUI java.awt.event.* import /* 1 */ import mouseclicked MouseListener implement /* 2 */ init addmouselistener(this) this /* 3 */ this mousec

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2;

< F2D82518E9F8AD CC95BD8D7388DA93AE2E6A7464>

Prog2_11th

Java プログラミング講習会 第 2 回 芝浦工業大学工学部情報工学科杉本徹 2017 年 3 月 27 日 public class Person { String familyname; String firstname; int age; } public void print() { Sy

. IDE JIVE[1][] Eclipse Java ( 1) Java Platform Debugger Architecture [5] 3. Eclipse GUI JIVE 3.1 Eclipse ( ) 1 JIVE Java [3] IDE c 016 Information Pr

< F2D A838B838D96402E6A7464>

GUIプログラムⅤ

55 7 Java C Java TCP/IP TCP/IP TCP TCP_RO.java import java.net.*; import java.io.*; public class TCP_RO { public static void main(string[] a

新・明解Java入門

データ構造とアルゴリズム論

2

Web 1 p.2 1 Servlet Servlet Web Web Web Apache Web Servlet JSP Web Apache Tomcat Jetty Apache Tomcat, Jetty Java JDK, Eclipse

< F2D B825082CC96E291E82E6A7464>

Java - Visual Editor

Microsoft Word - Java4.DOC

I. (i) Java? (A). 2Apples (B). Vitamin-C (C). Peach21 (D). Pine_Apple (ii) Java? (A). Java (B). Java (C). Java (D). JavaScript Java JavaScript Java (i

Chapter 20. [ ] ; [ ] = new [ ] ; Color colors [ ] = new Color[ 20 ]; // 20 Button operations [ ] = new Button[ 10 ]; // 10 colors[ 3 ] = new Color( 1

II Java :30 12:00 I. I IV II. III. IV. ( a d) V. : this==null, T == N A ActionListener C class D actionperformed G getsource I implements K

ただし 無作為にスレッドを複数実行すると 結果不正やデッドロックが起きる可能性がある 複数のスレッド ( マルチスレッド ) を安全に実行する ( スレッドセーフにする ) ためには 同期処理を用いるこ とが必要になる 同期処理は 予約語 synchronized で行うことができる ここでは sy

< F2D89BA8EE882C E6A7464>

インターネットマガジン2001年4月号―INTERNET magazine No.75


19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

Applet java.lang.object java.awt.component java.awt.container java.awt.panel java.applet.applet

アトミックコンポーネント ( 部 品 )<ボタン, 文 字 > 中 間 コンテナ ( 部 品 を 置 く 場 所 ) トップレベルコンテナ (GUI を 表 示 するための 場 所.コンテントペイン) Swingコンポーネントを 利 用 する 手 順 サンプル 10.1 (Helo.java)につい

K227 Java 2

Java

Prog1_12th

HTML Java Tips dp8t-asm/java/tips/ Apache Tomcat Java if else f

PowerPoint Presentation

II 1 p.1 1 Servlet 1.1 Web Web WWW HTML CGI Common Gateway Interface Web HTML Web Web CGI CGI CGI Perl, PHP C JavaScript Web CGI HTML 1.2 Servlet Java

10/31 Java AWTの基本構造(Frameクラスの継承) 演習課題資料

問1

HTML Java Tips dp8t-asm/java/tips/ Apache Tomcat Java if else f

Java演習(9) -- クラスとメソッド --


Transcription:

B 10 : ks91@sfc.wide.ad.jp N206 2003 ip2003f10.tex B : 9/12/2003 10:02 p.1/71

: / ip2003f10.tex B : 9/12/2003 10:02 p.2/71

ip2003f10.tex B : 9/12/2003 10:02 p.3/71

1 http://java.sun.com/j2se/1.4.1/docs/api/ http://java.sun.com/j2se/1.4/ja/docs/ja/api/index.html... ip2003f10.tex B : 9/12/2003 10:02 p.4/71

2 jar manifest.txt? jar f m manifest.txt? manifest.txt?? all-in-one jar ip2003f10.tex B : 9/12/2003 10:02 p.5/71

3 GUI GUI GUI GUI GUI (Q & A) ip2003f10.tex B : 9/12/2003 10:02 p.6/71

(event) (reaction) ( ) ( ) 3 ip2003f10.tex B : 9/12/2003 10:02 p.7/71

: / ip2003f10.tex B : 9/12/2003 10:02 p.8/71

ip2003f10.tex B : 9/12/2003 10:02 p.9/71

. 1,000 Java 3 main() ip2003f10.tex B : 9/12/2003 10:02 p.10/71

9. Java OK GUI ip2003f10.tex B : 9/12/2003 10:02 p.11/71

80 6 (12/9 )? (Vending.java) ( ) All-in-one jar (Windows XP Mac OS X ) ip2003f10.tex B : 9/12/2003 10:02 p.12/71

j All-in-one jar o -jar jar manifest.txt Main-Class: (main()) < > z:> jar cvfm manifest.txt *.class *.java <Enter> c: v: f: m: * *.java.java ip2003f10.tex B : 9/12/2003 10:02 p.13/71

j All-in-one jar o ( ) Vending.java manifest.txt Main-Class: Vending < > z:> jar cvfm vending.jar manifest.txt Vending.class Merchandise.class Money.class Vending.java images manifest.txt gpl.txt jar ( ) jar *.class *.java manifest.txt vending.jar gpl.txt Vending.java ip2003f10.tex B : 9/12/2003 10:02 p.14/71

j Java GUI java.awt (AWT: Abstract Window Toolkit) Java : Button javax.swing (Swing) Java : JButton J ip2003f10.tex B : 9/12/2003 10:02 p.15/71

j Swing o Visual Index Applet : JFrame( ), JPanel,... : BorderLayout, GridLayout, BoxLayout,... : JButton, JCheckBox, JLabel,... ip2003f10.tex B : 9/12/2003 10:02 p.16/71

j o ip2003f10.tex B : 9/12/2003 10:02 p.17/71

j Java GUI ( ) 1. (content pane) frame = new JFrame( ); Container pane = frame.getcontentpane(); 2. // frame.setdefaultcloseoperation(jframe.exit ON CLOSE); 3. ( ) 4. frame.pack(); frame.setvisible(true); JFrame _frame private ip2003f10.tex B : 9/12/2003 10:02 p.18/71

j o // JPanel panel = new JPanel(new GridLayout(0, I NUMBER OF GOODS PER ROW)); // (i++ i=i+1 ) for (int i = 0; i < aogoods.length; i++) { : panel.add( aogoods[i]); } // (pane) ( ) pane.add(panel, BorderLayout.NORTH); add() pane panel ip2003f10.tex B : 9/12/2003 10:02 p.19/71

j JDialog JOptionPane (Vending.java ) JFrame (menu bar) (content pane) JPanel JPanel panel = new JPanel( ); :// panel.add( ); // panel.add(, ); ip2003f10.tex B : 9/12/2003 10:02 p.20/71

j BorderLayout ( ) ( ) ( ) ( ) JPanel panel = new JPanel(new BorderLayout()); :// panel.add(, BorderLayout.CENTER); // NORTH/SOUTH/EAST/WEST GridLayout JPanel panel = new JPanel(new GridLayout(, )); :// panel.add( ); ( ) 0 ( ) ip2003f10.tex B : 9/12/2003 10:02 p.21/71

j JButton JButton button = new JButton( ); // JButton button = new JButton(, ); // JButton button = new JButton( ); JLabel JLabel label = new JLabel( ); // JLabel label = new JLabel( ); JLabel Visual Index ip2003f10.tex B : 9/12/2003 10:02 p.22/71

j ImageIcon JButton JLabel ImageIcon icon = new ImageIcon( URL); URL getclass().getresource( ) // : images/10yen.png jar a a URL jar URL ip2003f10.tex B : 9/12/2003 10:02 p.23/71

: / ip2003f10.tex B : 9/12/2003 10:02 p.24/71

ip2003f10.tex B : 9/12/2003 10:02 p.25/71

10. 1. web ( URL) http://www.soi.wide.ad.jp/quiz/ 2. SOI 3. ip2003f10.tex B : 9/12/2003 10:02 p.26/71

SOI 8, 9 2003/12/14 23:59 JST ip2003f10.tex B : 9/12/2003 10:02 p.27/71

: / ip2003f10.tex B : 9/12/2003 10:02 p.28/71

( ) ip2003f10.tex B : 9/12/2003 10:02 p.29/71

j Java Vending buttoncancel = new JButton(S LABEL CANCEL); buttoncancel.setenabled(false); buttoncancel.addactionlistener(this); panel.add( buttoncancel, BorderLayout.CENTER); panel, JButton, setenabled(), addactionlistener()???????? _buttoncancel, this? S_LABEL_CANCEL??? ip2003f10.tex B : 9/12/2003 10:02 p.30/71

: / ip2003f10.tex B : 9/12/2003 10:02 p.32/71

: ip2003f10.tex B : 9/12/2003 10:02 p.33/71

j vending.jar 1: vending.jar 2: z:> java -jar vending.jar <Enter> 1 ip2003f10.tex B : 9/12/2003 10:02 p.34/71

j o all-in-one jar z:> jar xvf vending.jar <Enter> x: v: f: Vending.java images (PNG a ) a PNG: Portable Network Graphics ip2003f10.tex B : 9/12/2003 10:02 p.35/71

j : (Vending.java ) ( ) ip2003f10.tex B : 9/12/2003 10:02 p.36/71

j extends implements : public class A implements B {...} 1 : A B( ) 2 : A B A B, ActionListener void actionperformed(actionevent event) ip2003f10.tex B : 9/12/2003 10:02 p.37/71

j public class Vending implements ActionListener { : public Vending() { : } } // addactionlistener() ActionListener buttoncancel.addactionlistener(this); : public void actionperformed(actionevent event) { Object source = event.getsource(); // :// } : ActionListener actionperformed() ip2003f10.tex B : 9/12/2003 10:02 p.38/71

: / ip2003f10.tex B : 9/12/2003 10:02 p.40/71

ip2003f10.tex B : 9/12/2003 10:02 p.41/71

p o GUI ( ) ActionListener actionperformed() ip2003f10.tex B : 9/12/2003 10:02 p.42/71

p o CLI ( ) ( quit ) CLI: Command Line Interface ip2003f10.tex B : 9/12/2003 10:02 p.43/71

: / ip2003f10.tex B : 9/12/2003 10:02 p.44/71

/ Random Date/SimpleDateFormat Timer JButton/ImageIcon ip2003f10.tex B : 9/12/2003 10:02 p.45/71

j o All-in-one jar ( slot-machine.jar) z:> java -jar slot-machine.jar z:> jar xvf slot-machine.jar SlotMachine.java ip2003f10.tex B : 9/12/2003 10:02 p.46/71

j SlotMachine o ( ) ( ) ( ) ip2003f10.tex B : 9/12/2003 10:02 p.47/71

j SlotMachine o Random ( ) Date/SimpleDateFormat ( ) Timer ( ) JButton/ImageIcon ( ) ip2003f10.tex B : 9/12/2003 10:02 p.48/71

j java.util.random Random(long seed) seed: int nextint() ip2003f10.tex B : 9/12/2003 10:02 p.49/71

j Random random = new Random(System.currentTimeMillis()); ( ) : int irandom = random.nextint(); System.currentTimeMillis() 1970 1 1 00:00:00 GMT nextint() ip2003f10.tex B : 9/12/2003 10:02 p.50/71

j Random o : int irandom = random.nextint(); = [Math.abs(iRandom) %.length]; : (Math.abs() ) ( ) 32... 1 1 32 3 3 32 ip2003f10.tex B : 9/12/2003 10:02 p.51/71

j java.text o.simpledateformat SimpleDateFormat(String pattern) pattern: ( : HH:mm:ss ( : : )) String format(date date) date ip2003f10.tex B : 9/12/2003 10:02 p.52/71

j java.util.date Date(long date) date: 1970 1 1 00:00:00 GMT System.currentTimeMillis() ip2003f10.tex B : 9/12/2003 10:02 p.53/71

j SimpleDateFormat/ o Date : format = new SimpleDateFormat( HH:mm:ss ); : : time = new Date(System.currentTimeMillis()); String s = format.format( time); : : _format GMT SlotMachine.java ip2003f10.tex B : 9/12/2003 10:02 p.54/71

j javax.swing.timer Timer(int delay, ActionListener listener) delay: ( : ) listener: void start() void stop() ip2003f10.tex B : 9/12/2003 10:02 p.55/71

j Timer class implements ActionListener { : : : timer = new Timer(1000, this); 1 timer.start(); 1 public void actionperformed(actionevent event) { Object source = event.getsource(); if (source == timer) { : 1 Timer actionperformed() ip2003f10.tex B : 9/12/2003 10:02 p.56/71

j javax.swing.jbutton Swing JButton(Icon icon) icon: void addactionlistener(actionlistener l) l void seticon(icon icon) ip2003f10.tex B : 9/12/2003 10:02 p.57/71

j javax.swing.imageicon Icon ImageIcon(String filename) filename: ImageIcon(URL location) location: GUI ip2003f10.tex B : 9/12/2003 10:02 p.58/71

j JButton/ImageIcon o class implements ActionListener { : : icon = new ImageIcon( getclass().getresource( )); getclass().getresource() jar button = new JButton( icon); button.addactionlistener(this); public void actionperformed(actionevent event) { Object source = event.getsource(); if (source == button) { button.seticon( ); : ip2003f10.tex B : 9/12/2003 10:02 p.59/71

j MouseListener ( ) java.awt.event.mouselistener SlotMachine.java ip2003f10.tex B : 9/12/2003 10:02 p.60/71

: / ip2003f10.tex B : 9/12/2003 10:02 p.61/71

a a ip2003f10.tex B : 9/12/2003 10:02 p.62/71

j INU o All-in-one jar ( inucalc.jar) z:> java -jar inucalc.jar z:> jar xvf inucalc.jar InuCalc.java ip2003f10.tex B : 9/12/2003 10:02 p.63/71

j INU o CLI z:> java -jar inucalc.jar -cli quit ip2003f10.tex B : 9/12/2003 10:02 p.64/71

j InuCalc o BufferedReader/InputStreamReader ( ) CLI... public, private protected protected ip2003f10.tex B : 9/12/2003 10:02 p.65/71

j java.io.bufferedreader BufferedReader(Reader in) in: String readline() 1 ip2003f10.tex B : 9/12/2003 10:02 p.66/71

j java.io o.inputstreamreader InputStreamReader(InputStream in) in: System.in ip2003f10.tex B : 9/12/2003 10:02 p.67/71

j java.io.fileinputstream System.in InputStreamReader FileInputStream(String name) name: ip2003f10.tex B : 9/12/2003 10:02 p.68/71

j o : BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); System.out.print( ); try { String s = reader.readline(); 1 } catch (IOException unused) { } : ip2003f10.tex B : 9/12/2003 10:02 p.69/71

: / ip2003f10.tex B : 9/12/2003 10:02 p.70/71

8, 9, 10 ip2003f10.tex B : 9/12/2003 10:02 p.71/71