text_12.dvi

Similar documents
text_13.dvi

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

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

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

Java言語 第1回

ガイダンス

text_10.dvi

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

ガイダンス

ガイダンス

Java 2 - Lesson01

Microsoft PowerPoint - swing2.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

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>

< F2D E E6A7464>

Prog1_12th

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

< F2D834F838C A815B A CC>

< F2D B838A835882CC8CF68EAE2E6A7464>

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

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

Prog1_12th

< F2D A839382CC906A2E6A7464>

< F2D B825082CC96E291E82E6A7464>

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

< F2D F B834E2E6A7464>

アプレットⅣ

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

< F2D82518CC282CC D2E6A7464>

< F2D A838B838D96402E6A7464>

< F2D82518E9F8AD CC95BD8D7388DA93AE2E6A7464>

< F2D825282CC947B909482CC A815B83682E6A>

Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem

< F2D89BA8EE882C E6A7464>

......() JButton

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

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

< F2D92DE82E8914B82CC977088D32E6A7464>

< F2D82B682E182F182AF82F12E6A7464>

Java言語 第1回

<4D F736F F F696E74202D AC C8899E D834F E >

< F2D8EA CE909482CC92EA82852E6A7464>

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

アプレットⅢ

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

2

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

Java言語 第1回

Microsoft Word - Java4.DOC

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

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

< F2D BCA82CC978E89BA82CC8EC08CB12E6A7464>

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 - swing3.ppt

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

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

text_08.dvi

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

Prog2_11th

PowerPoint Presentation

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

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

Microsoft PowerPoint - prog12.ppt

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

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;

Java 2 - Lesson01

Microsoft PowerPoint - prog13.ppt

Microsoft PowerPoint - prog13.ppt


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

Thread

問1

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

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

r14.dvi

LMNtal LMNtal LMNtal JAVA JAVA JAVA LMNtal LMNtal LMNtal

PowerPoint Presentation

Microsoft Word - Java3.DOC

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


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

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 (

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

(Microsoft PowerPoint - \223\306\217KJAVA\221\346\202R\224\ ppt)

ガイダンス

ガイダンス

r14.dvi

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

r8.dvi

Microsoft PowerPoint - OOP.pptx

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

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

. 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

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

K227 Java 2

Microsoft PowerPoint - prog11.ppt

2008 e-learning T050050

ブロック崩し Step1 矢印キーで左右に動かせるパドルを描画する < パドルの表現方法 > パドルは java.awt パッケージの Rectangle という Java が用意しているクラスを使う これは四角形を表すクラスで 左上の点の座標と幅 高さをもっている (x, y) Rectangle

Transcription:

C 12 2000 7 2

12 Java(7) { Swing(, ), 1 12.1 12 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 12.2 Swing : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 12.2.1 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 2 12.2.2 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 4 12.2.3 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8 12.3 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 10 12.4 : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 14 {i{

12 Java(7) { Swing(, ), 12.1 12 C 12 13 Java 1 GUI GUI 12 Swing 12.2 Swing Java 1 (GUI) Java GUI AWT(Abstract Window Toolkit) AWT GUI Java Swing AWT GUI AWT Swing Java1.1 Java1.2 1 GUI (frame) (parts) GUI ( ) GUI GUI 12.1 Java GUI 1 Swing Java1.1 Java1.2 /usr/local2/java1.2/bin /bin 1

12.1: GUI 12.2.1 GUI GUI Swing JFrame JFrame setsize setvisible C 6 Hello1.java // Hello1.java import java.awt.* import java.awt.event.* import javax.swing.* // // Swing public class Hello1 { public static void main( String [] args ) { JFrame myframe = new JFrame( "SoftC" ) JLabel mylabel = new JLabel( "Hello java world." ) Container mycontainer = myframe.getcontentpane() mycontainer.add( mylabel ) myframe.setsize( 150, 100 ) myframe.setvisible( true ) // Hello1 // main // myframe // mylabel // mycontainer // mycontainer mylabel // myframe // myframe myframe.addwindowlistener( new WindowAdapter() { public void windowclosing( WindowEvent we ) { System.exit(0) ) // 1 \Hello java world." 1 JFrame myframe JLabel \Hello java world." (content pane) AWT 2

Swing Container JFrame getcontentpane Container add setsize setvisible addwindowlistener 2 WindowAdapter windowclosing Hello1.java JFrame JFrame MyFrame.java // MyFrame.java import javax.swing.* import java.awt.* import java.awt.event.* // Swing // ContentPane // public class MyFrame extends JFrame { MyFrame() { super( "SoftC" ) Container mycontainer = getcontentpane() JLabel mylabel = new JLabel( "Hello java world." ) mycontainer.add( mylabel ) setsize( 150, 100 ) setvisible( true ) // // // ContentPane // // // // addwindowlistener( new WindowAdapter() { public void windowclosing( WindowEvent we ) { System.exit( 0 ) ) // // main public static void main( String [] args ) { MyFrame myframe = new MyFrame() 12-1 250 70 JFrame 2 3

12.2.2 Swing (layout manager) 12.1 12.1: (FlowLayout) (GridLayout) (BorderLayout) (CardLayout) (GridBagLayout) (BoxLayout) (OverlayLayout) (ScrollPaneLayout) (ViewportLayout) (JScrollPane) (JViewport) 3 3 public FlowLayout() public FlowLayout( int alignment ) public FlowLayout( int alignment, int horizgap, int vertgap ) alignment FlowLayout.LEFT FlowLayout.CENTER FlowLayout.RIGHT // // // horizgap vertgap 4

// MyFlow.java import javax.swing.* import java.awt.* import java.awt.event.* public class MyFlow extends JFrame { MyFlow() { super( "FlowLayout" ) Container mycontainer = getcontentpane() FlowLayout flowlayout = new FlowLayout( FlowLayout.LEFT, 5, 10 ) // FlowLayout mycontainer.setlayout( flowlayout ) // JLabel mylabel1 = new JLabel( "This is 1." ) JLabel mylabel2 = new JLabel( "This is 2." ) JLabel mylabel3 = new JLabel( "This is 3." ) JLabel mylabel4 = new JLabel( "This is 4." ) JLabel mylabel5 = new JLabel( "This is 5." ) mycontainer.add( mylabel1 ) mycontainer.add( mylabel2 ) mycontainer.add( mylabel3 ) mycontainer.add( mylabel4 ) mycontainer.add( mylabel5 ) setsize( 220, 90 ) setvisible( true ) // // // // addwindowlistener( new WindowAdapter() { // public void windowclosing( WindowEvent we ) { System.exit( 0 ) ) // main public static void main( String [] args ) { MyFlow myflow = new MyFlow() 5 12.2: 5

2 3 6 public GridLayout( int row, int column ) public GridLayout( int row, int column, int horizgap, int vertgap ) row column horizgap vertgap MyFlow.java FlowLayout flowlayout = new FlowLayout( FlowLayout.LEFT, 5, 10 ) // FlowLayout mycontainer.setlayout( flowlayout ) // GridLayout gridlayout = new GridLayout( 3, 2, 5, 10 ) // GridLayout mycontainer.setlayout( gridlayout ) // NORTH SOUTH WEST EAST CENTER public BorderLayout() public BorderLayout( int horizgap, int vertgap ) // MyBorder.java import javax.swing.* import java.awt.* import java.awt.event.* public class MyBorder extends JFrame { MyBorder() { super( "BorderLayout" ) Container mycontainer = getcontentpane() BorderLayout borderlayout = new BorderLayout() mycontainer.setlayout( borderlayout ) ( ) // BorderLayout // 6

// JLabel mylabel1 = new JLabel( "This is North.", JLabel.CENTER ) JLabel mylabel2 = new JLabel( "This is South.", JLabel.CENTER ) JLabel mylabel3 = new JLabel( "This is West.", JLabel.CENTER ) JLabel mylabel4 = new JLabel( "This is East.", JLabel.CENTER ) JLabel mylabel5 = new JLabel( "This is Center.", JLabel.CENTER ) // mycontainer.add( mylabel1, BorderLayout.NORTH ) mycontainer.add( mylabel2, BorderLayout.SOUTH ) mycontainer.add( mylabel3, BorderLayout.WEST ) mycontainer.add( mylabel4, BorderLayout.EAST ) mycontainer.add( mylabel5, BorderLayout.CENTER ) setsize( 300, 200 ) setvisible( true ) // // addwindowlistener( new WindowAdapter() { // public void windowclosing( WindowEvent we ) { System.exit( 0 ) ) // main public static void main( String [] args ) { MyBorder myborder = new MyBorder() 12.3: 12-2 7

12.2.3 1 1 Swing (panel) JPanel JPanel 3 MyChoice MyChoice 3 p1 p2 p3 JTextField JCheckBox JButton 12.4 MyChoice p1 JPanel JLabel (l1) JTextField (t) MyChoice p1 p2 p3 l1 t l2 c1 c2 l3 b1 b2 // MyChoice.java import javax.swing.* import java.awt.* import java.awt.event.* 12.4: MyChoice public class MyChoice extends JFrame { public MyChoice() { // super( "My Choice" ) Container mycontainer = getcontentpane() // BorderLayout mycontainer.setlayout( new BorderLayout() ) // p1 JPanel p1 = new JPanel( new FlowLayout() ) JLabel l1 = new JLabel( "Your name please." ) JTextField t = new JTextField( 20 ) p1.add( l1 ) p1.add( t ) ( ) 3 8

// p2 JPanel p2 = new JPanel( new BorderLayout() ) JLabel l2 = new JLabel( "Make sure your choice." ) JCheckBox c1 = new JCheckBox( "OxfordAdvanced Learner's Dictionary" ) JCheckBox c2 = new JCheckBox( "Longman Language Activator" ) p2.add( l2, BorderLayout.NORTH ) p2.add( c1, BorderLayout.CENTER ) p2.add( c2, BorderLayout.SOUTH ) // p3 JPanel p3 = new JPanel( new FlowLayout() ) JLabel l3 = new JLabel( "Are you sure?" ) JButton b1 = new JButton( "Yes, I am." ) JButton b2 = new JButton( "No, I'm not." ) p3.add( l3 ) p3.add( b1 ) p3.add( b2 ) // mycontainer.add( p1, BorderLayout.NORTH ) mycontainer.add( p2, BorderLayout.CENTER ) mycontainer.add( p3, BorderLayout.SOUTH ) pack() setvisible( true ) // // addwindowlistener( new WindowAdapter() { // public void windowclosing( WindowEvent we ) { System.exit( 0 ) ) // main public static void main( String [] args ) { MyChoice p0 = new MyChoice() pack MyChoice 12.5 12.5: MyChoice 9

12-3 3 1 12.3 (event) (event processing) Java 4 java.awt.event MouseEvent WindowEvent (event listener) JButton 5 1 MouseEvent MouseListener mousepressed() MouseListener MouseListener mousepressed ( 12.6 ) 12.2 Button Press! Event MouseEvent MouseListener public void mousepressed() {... 12.6: 4 Java 1.0 Java 1.1 Java 1.1 5 10

12.2: Java 1.1 ActionEvent ActionListener actionperformed() mouseclicked() mouseentered() MouseEvent MouseListener mouseexited() mousepressed() mousereleased() TextEvent TextListener textvaluechanged() windowactivated() windowclosed() windowclosing() WindowEvent WindowListener windowdeactivated() windowiconified() windowdeiconified() windowopened() // MyActionEvent.java import javax.swing.* import java.awt.* public class MyActionEvent extends JFrame { MyActionEvent() { super( "My Action Event" ) Container mycontainer = getcontentpane() JButton mybutton = new JButton( "Button" ) mycontainer.add( mybutton ) setsize( 150, 100 ) setvisible( true ) mybutton.addactionlistener( new ActListener() ) addwindowlistener( new WinListener() ) // // // // // // // // main public static void main( String [] args ) { MyActionEvent myactionevent = new MyActionEvent() 11

// ActListener.java // import java.awt.event.* public class ActListener implements ActionListener { public void actionperformed( ActionEvent ae ) { System.out.println( "Button Pressed!!" ) // WinListener.java // import java.awt.event.* public class WinListener implements WindowListener { public void windowclosing( WindowEvent we ) { System.exit( 0 ) // public void windowopened( WindowEvent we ) { // public void windowclosed( WindowEvent we ) { // public void windowiconified( WindowEvent we ) { // public void windowdeiconified( WindowEvent we ) { // public void windowactivated( WindowEvent we ) { // public void windowdeactivated( WindowEvent we ) { // MyActionEvent JFrame 1 addactionlistener ActListener addwindowlistener WinListener addxxxxlistener XXXX ActListener ActionListener actionperformed \Button Pressed!!" WinListener WindowListener windowclosing System.exit( 0 ) 1 2 WinListener windowclosing Java (adapter) 12

MouseListener MouseAdapter WindowListener WindowAdapter MyActionEvent.java // MyActionEvent.java... mybutton.addactionlistener( new ActListener() ) addwindowlistener( new WinListener() )... // MyActionEvent.java... mybutton.addactionlistener( new ActListener() ) addwindowlistener( new WinAdapter() )... // WinAdapter.java // import java.awt.event.* public class WinAdapter extends WindowAdapter { public void windowclosing( WindowEvent we ) { System.exit( 0 ) // // // // // addwindowlistener (anonymous inner class) 12-4 1 \Mouse Clicked!" 13

12.4 2 1. 250 70 JFrame ( 12-1) 2. ( 12-2) 3. 3 1 ( 12-3) 4. 1 \Mouse Clicked!" ( 12-4) 2 1. Swing AWT MyChoice.java AWT 2. Swing MyChoice.java 3. BoxLayout 12.7 1) 3 Java,, 2) JAVA,, Patrick Niemeyer & Joshua Peck, 3) Java,, Paul Tyma, Gabriel Torok, & Troy Downing, 4) Java,, 5) JAVA,, David Flanagan, 6) JAVA,, Nathan Gurewich & Ori Gurewich, 7) Internet Language Java,, 14

12.7: 8) Java,, Laura Lemay, & Charles L. Perkins,, &, & 9) JAVA2,, 10) Java,, Joseph O'Neil, 11) Java Swing,, Satyaraj Pantham, 12) Swing Java GUI,, 13) Swing Java GUI II,, 14) Swing Java GUI III,, 15) Java Swing Black Book,, Steven Holzner & 16) JBuilder Java,, 15

: xv : Num Lock Num Lock xv $ /usr/local4/bin/xv & xv 12.8: xv xv 12.9: 16

Grab 12.10: Grab xv 12.11 xv 12.11: save 17

12.12: Format: Save File: PostScript LATEX2e \includegraphics LATEX2e A 18