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

Similar documents
4 p.2 4 GUI return; public void mousepressed(mouseevent e) { /* 5 */ public void mousereleased(mouseevent e) { /* 5 */ public void mouseentered(mousee

4 p.2 4 GUI public void mousepressed(mouseevent e) { /* 5 */ public void mousereleased(mouseevent e) { /* 5 */ public void mouseentered(mouseevent e)

I. (i) Java? (A). Foo_Bar (B). G day (C). 999 (D). Golgo13 (ii)? (A). Java public (B). Java (C). Java JavaScript (D). Java C Java C (iii)? (A). Java (

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

KeyListener init addkeylistener addactionlistener addkeylistener addkeylistener( this ); this.addkeylistener( this ); KeyListener public void keytyped

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

Chapter JDK KeyListener keypressed(keyevent e ) keyreleased(keyevent e ) keytyped(keyevent e ) MouseListener mouseclicked(mouseeven

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

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

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

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed

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

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

Microsoft PowerPoint prog1_doc2x.pptx

Java 2 - Lesson01

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

Microsoft PowerPoint prog1_doc2.pptx

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

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

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

text_12.dvi

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;

(Microsoft PowerPoint - \223\306\217KJAVA\221\346\202R\224\ 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

r14.dvi

r14.dvi

r3.dvi

2008 e-learning T050050

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

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 +=

Animals サンプル Step 1 動物の種類を指定しておいて クリックした場所に画像を貼り付ける < レイアウトについて > 前回は ラベルやボタンの位置を座標で設定した Absolute Layout を選んだためである レイアウトは どのようにボタンなどのコンポーネントを配置するかを決定す

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

text_13.dvi

Microsoft PowerPoint - prog11.ppt

r8.dvi

Assignment_.java /////////////////////////////////////////////////////////////////////// // 課題 星の画像がマウスカーソルを追従するコードを作成しなさい 次 ///////////////////

Microsoft PowerPoint - swing2.ppt

Microsoft PowerPoint - prog12.ppt


PowerPoint Presentation

Microsoft PowerPoint - swing3.ppt

アプレットⅣ

Color.cyan, Color.yellow, Color.pink, Color.orange, Color.white, Color.black, Color.gray, Color.darkGray, Color.lightGray ; Button barray [ ] = new Bu

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

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

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

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

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>

以下に java.awt.graphics クラスの主なメソッドを示す (Graphics クラスの ) メソッド drawline(int x1, int y1, int x2, int y2) drawrect(int x, int y, int width, int height) fillr

Microsoft PowerPoint - prog10.ppt

Microsoft PowerPoint - prog10.ppt

Java言語 第1回

Java言語 第1回

Microsoft PowerPoint - prog11.ppt

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

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

Java演習(2) -- 簡単なプログラム --

問1

JAVA入門

< F2D A839382CC906A2E6A7464>

< F2D89BA8EE882C E6A7464>

< F2D82518CC282CC D2E6A7464>

Animals サンプル Step 2 張り付けた動物の上をクリックすると それぞれの鳴き声で鳴く < 例外について > エラーや 通常の処理の中では起こってはいけない事象のことを例外といい 例外が起こる可能性がある場合はその対応処理を記述しなければならない 一般に java.lang パッケージの

< F2D F B834E2E6A7464>

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

Microsoft Word - Java3.DOC

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

ガイダンス

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1) int boolean switch case C Calendar java.util.calendar A

r2.dvi

Microsoft Word - Java4.DOC


r4.dvi

ガイダンス

< F2D82518E9F8AD CC95BD8D7388DA93AE2E6A7464>

Java 2 - Lesson01

Thread

< F2D825282CC947B909482CC A815B83682E6A>

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

< F2D834F838C A815B A CC>

< F2D B838A835882CC8CF68EAE2E6A7464>

Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem

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

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

ガイダンス

ソフトウェア開発方法論2

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

手書認識 グラフ描画 Step2-2 手書認識 : 認識結果を PaintPanel で描画する < 属性付き文字列 AttributedString> 標準出力では分かりにくいうえに認識結果を使えないので 認識するごとに PaintPanel に文字を描画することにする ここで 数式はただの文字列

r3.dvi

アプレットの作成

PowerPoint プレゼンテーション

r2.dvi

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

......() JButton

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

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

< F2D E E6A7464>

2

< F2D92DE82E8914B82CC977088D32E6A7464>

Transcription:

I 4 p.1 4 GUI GUI GUI 4.1 4.1.1 MouseTest.java /* 1 */ public class MouseTest extends JApplet implements MouseListener /* 2 */ { int x=50, y=20; addmouselistener(this); /* 3 */ public void mouseclicked(mouseevent e) { /* 4 */ x = e.getx(); y = e.gety(); return; public void mousepressed(mouseevent e) { /* 5 */ public void mousereleased(mouseevent e) { /* 5 */ public void mouseentered(mouseevent e) { /* 5 */ public void mouseexited(mouseevent e) { /* 5 */ public void paint(graphics g) { super.paint(g); /* 6 */ g.drawstring("hello WORLD!", x, y);

I 4 p.2 4 GUI java.awt.event.* import /* 1 */ import mouseclicked MouseListener implement /* 2 */ init addmouselistener(this) this /* 3 */ this mouseclicked /* 4 */ mouseclicked MouseEvent MouseListener mousepressed, mousereleased, mouseentered, mouseexited /* 5 */ paint super.paint(g) super. /* 6 */ x, y mouseclicked MouseEvent getx, gety repaint repaint JApplet paint 4.2 this this Java self Java object.methed(args1, args2,... ). object this 4.3 interface C++ Java

4.4. I 4 p.3 Java MouseListener public interface MouseListener { public void mouseclicked(mouseevent e); public void mousepressed(mouseevent e); public void mousereleased(mouseevent e); public void mouseentered(mouseevent e); public void mouseexited(mouseevent e); MouseListener MouseClicked addmouselistener MouseListener 4.3.1 repaint() MouseTest.java? 4.3.2 Othello.java 4.3.3 4.3.4 java.util.arraylist (100,100) 4.4 Mouse Key MouseTest.java 4.4.1 U(p), D(own)

I 4 p.4 4 GUI KeyTest.java public class KeyTest extends JApplet implements KeyListener { int x=50, y=20; addkeylistener(this); public void paint(graphics g) { super.paint(g); g.drawstring("hello WORLD!", x, y); public void keytyped(keyevent e) { int k = e.getkeychar(); if (k== u ) { y-=10; else if (k== d ) { y+=10; public void keyreleased(keyevent e) { public void keypressed(keyevent e) { KeyListner keypressed, keyreleased, keytyped 3 keypressed keyreleased KeyEvent getkeycode KeyTyped keypressed, keyreleased KeyEvent getkeychar ( Shift, a A ) 4.4.2 KeyTest.java KeyTest.java : (JDKDIR)/docs/ja/api/java.awt.event.KeyEvent.html 4.5 GUI GUI GUI

4.5. GUI I 4 p.5 ChangeColor.java Factorial.java mouseclicked keypressed GUI ActionEvent 4.5.1 ChangeColor.java public class ChangeColor extends JApplet implements ActionListener { Color[] cs = {Color.RED, Color.BLUE, Color.GREEN, Color.ORANGE; int i=0; JButton b = new JButton("Next"); b.addactionlistener(this); /* 1 */ setlayout(new FlowLayout()); /* 2 */ add(b); /* 3 */ public void paint(graphics g) { super.paint(g); g.setcolor(cs[i]); g.drawstring("hello WORLD!", 20, 50); i=(i+1)%cs.length; JButton /* 3 */

I 4 p.6 4 GUI /* 2 */ add FlowLayout actionperformed b actionperformed b addactionlistener /* 1 */ GUI 1 actionperformed e actionperformed i GUI 2 4.5.2 Factorial.java public class Factorial extends JApplet implements ActionListener { JTextField input; JLabel output; input=new JTextField("0", 8); output=new JLabel(" 1"); input.addactionlistener(this); setlayout(new FlowLayout()); add(input); add(new JLabel(" ")); add(output); add(new JLabel(" ")); static int factorial(int n) { int r = 1; for (; n>0; n--) { r *= n; return r; // factorial int n = Integer.parseInt(input.getText()); output.settext(" "+factorial(n)); JTextField String int 2 JLabel GUI actionperformed actionperformed input JTextField gettext output JLabel settext

4.6. GUI I 4 p.7 4.6 GUI 4.6.1 2 UpDownButton.java public class UpDownButton extends JApplet implements ActionListener { int x=20; JButton left, right; left = new JButton("Left"); right = new JButton("Right"); left.addactionlistener(this); right.addactionlistener(this); setlayout(new FlowLayout()); add(left); add(right); public void paint(graphics g) { super.paint(g); g.drawstring("hello WORLD!", x, 55); if (e.getsource() == left) { // Left x-=10; else if (e.getsource() == right) { // Right x+=10; GUI 2 actionperformed ActionEvent getsource == 4.6.2 Factorial.java 2 = 9 + 32 5 0 32 100 212 String double double String 3

I 4 p.8 4 GUI 4.7 GUI if else getsource innner class 4.7.1 UpDownButton.java UpDownButton2.java public class UpDownButton2 extends JApplet { int x=20; public class LeftListener implements ActionListener { x-=10; public class RightListener implements ActionListener { x+=10; JButton left = new JButton("Left"); JButton right = new JButton("Right"); left.addactionlistener(new LeftListener()); right.addactionlistener(new RightListener()); setlayout(new FlowLayout()); add(left); add(right); public void paint(graphics g) { super.paint(g); g.drawstring("hello WORLD!", x, 55); Java C LeftListener RightListener ActionPerformed x repaint addactionlistner getsource

4.8. I 4 p.9 4.8, new ( ) { ActionListener java.lang.object 4.8.1 UpDownButton.java (anonymous class) UpDownButton3.java public class UpDownButton3 extends JApplet { int x=20; JButton left = new JButton("Left"); JButton right = new JButton("Right"); left.addactionlistener(new ActionListener() { x-=10; ); right.addactionlistener(new ActionListener() { x+=10; ); setlayout(new FlowLayout()); add(left); add(right); public void paint(graphics g) { super.paint(g); g.drawstring("hello WORLD!", x, 55);

I 4 p.10 4 GUI 4.9 JTextArea 4.9.1 JTextArea Divisor.java public class Divisor extends JApplet implements ActionListener { JTextField input; JTextArea output; input = new JTextField("0", 8); output = new JTextArea(10, 20); input.addactionlistener(this); setlayout(new FlowLayout()); add(input); add(output); int i, n = Integer.parseInt(input.getText()); for(i=1; i<=n; i++) { if (n%i==0) { output.append(i+" "+n+" Y=n"); output.append(" Y=nY=n"); JTextArea

4.9. JTextArea I 4 p.11 4.9.2 JPanel, JCheckBox, JComboBox, JList, JTable, JTree GUI 4.9.3 FlowLayout GUI Layout keytyped, mouseclicked, actionperformed, interface, MouseListener, KeyListener, ActionListener, this, MouseEvent, KeyEvent, ActionEvent, add, JButton, JLabel, JTextField, JTextArea

I 4 p.12 4 GUI :