4 p.2 4 GUI public void mousepressed(mouseevent e) { /* 5 */ public void mousereleased(mouseevent e) { /* 5 */ public void mouseentered(mouseevent e)
|
|
|
- あきみ さわい
- 9 years ago
- Views:
Transcription
1 4 p.1 4 GUI GUI GUI Java Java try catch C MouseTest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; /* 1 */ public class MouseTest extends JApplet implements MouseListener { /* 2 */ int x=50, y=20; public void init() { addmouselistener(this); /* 3 */ public void mouseclicked(mouseevent e) { /* 4 */ x = e.getx(); y = e.gety(); repaint(); return;
2 4 p.2 4 GUI 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); g.drawstring("hello WORLD!", x, y); java.awt.event.* import /* 1 */ import mouseclicked MouseListener implement /* 2 */ init addmouselistener(this) this /* 3 */ this mouseclicked mouseclicked /* 4 */ mouseclicked MouseEvent MouseListener mousepressed, mousereleased, mouseentered, mouseexited /* 5 */ x, y mouseclicked MouseEvent getx, gety repaint repaint JApplet paint C
3 4.2. this 4 p.3 MouseTest x, y MouseTest JApplet x, y int paint mouseclicked x, y Othello.java i j this this Java self Java object.method(arg1, arg2,... ). object this 4.3 interface C++ Java 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);
4 4 p.4 4 GUI MouseListener mouseclicked addmouselistener MouseListener Q Foo JApplet mouseclicked import public class Foo extends JApplet 2 : public class Foo extends JApplet Q mouseclicked repaint() MouseTest.java? : Othello.java Mouse Key MouseTest.java U(p), D(own) KeyTest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class KeyTest extends JApplet implements KeyListener { int x=50, y=20; public void init() { setfocusable(true);
5 p.5 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; repaint(); public void keyreleased(keyevent e) { public void keypressed(keyevent e) { KeyListener keypressed, keyreleased, keytyped 3 keypressed keyreleased KeyEvent getkeycode keytyped keypressed, keyreleased KeyEvent getkeychar ( Shift, a A ) Q Bar JApplet keytyped import public class Bar extends JApplet 2 : public class Bar extends JApplet KeyTest.java KeyTest.java : (JDKDIR)/docs/ja/api/java.awt.event.KeyEvent.html
6 4 p.6 4 GUI 4.5 GUI GUI GUI ChangeColor.java Factorial.java mouseclicked keypressed GUI ActionEvent ActionEvent ChangeColor.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class ChangeColor extends JApplet implements ActionListener { Color[] cs = {Color.RED, Color.BLUE, Color.GREEN, Color.ORANGE; int i=0; public void init() { 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);
7 4.5. GUI 4 p.7 public void actionperformed(actionevent e) { i=(i+1)%cs.length; repaint(); JButton /* 3 */ /* 2 */ add FlowLayout actionperformed b actionperformed b addactionlistener /* 1 */ GUI 1 actionperformed e actionperformed i GUI 2 Q Baz JApplet actionperformed import public class Baz extends JApplet 2 : public class Baz extends JApplet Factorial.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Factorial extends JApplet implements ActionListener { JTextField input; JLabel output; public void init() { input = new JTextField("0", 8); output = new JLabel(" 1"); input.addactionlistener(this); setlayout(new FlowLayout());
8 4 p.8 4 GUI 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 public void actionperformed(actionevent e) { try { int n = Integer.parseInt(input.getText()); output.settext(" "+factorial(n)); catch (NumberFormatException ex) { input.settext("!"); JTextField String int 2 JLabel GUI actionperformed actionperformed input JTextField gettext output JLabel settext java.lang.integer java.lang.integer : public static int parseint(string s) 10 factorial return C,... {... public C
9 4.6. Java 4 p.9 Q str String "123" 123 int Java : 4.6 Java try catch try 1 catch ( ) catch 2 catch ( ) catch catch try catch try catch finally finally finally catch 0 ArithmeticException TryCatchTest.java public class TryCatchTest { public static void main(string[] args) { int i; for (i=-3; i<=3; i++) { try { System.out.printf("10/%d = %d%n", i, 10/i); catch (ArithmeticException e) { System.out.println(": "+e.tostring()); System.out.println(" "); 10/-3 = -3 10/-2 = -5 10/-1 = -10 : java.lang.arithmeticexception: / by zero
10 4 p.10 4 GUI 10/1 = 10 10/2 = 5 10/3 = 3 i 0 catch try catch Q public class TryCatchTest { public static void main(string[] args) { int i; try { for (i=-3; i<=3; i++) { System.out.printf("10/%d = %d%n", i, 10/i); catch (ArithmeticException e) { System.out.println(": "+e.tostring()); System.out.println(" "); : ArithmeticException java.lang java.lang import import NullPointerException NumberFormatException ArrayIndexOutOfBoundsException null C NULL null Integer.parseInt 4.6.1
11 4.7. throw 4 p.11 try catch java.io.ioexception N gon.java 4.7 throw throw throw ; Exception main args 0 break TryCatchTest2.java public class TryCatchTest2 { public static void main(string[] args) { int i, m=1; try { for (i=0; i<args.length; i++) { m *= foo(args[i]); catch (Exception e) { m = 0; System.out.println(" " + m + ""); public static int foo(string arg) throws Exception { int a = Integer.parseInt(arg); if (a==0) throw new Exception("zero"); return a; java TryCatchTest , 4, 5, 6 foo try catch throws,
12 4 p.12 4 GUI 4.8 String split Graph.java Graph2.java import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Graph2 extends JApplet implements ActionListener { int[] is = {; JTextField input; Color[] cs = {Color.RED, Color.BLUE; int scale = 15; public void init() { input = new JTextField("", 16); input.addactionlistener(this); setlayout(new FlowLayout()); add(input); public void paint(graphics g) { super.paint(g); int i; int n = is.length; for (i=0; i<n; i++) { g.setcolor(cs[i%cs.length]); g.fillrect(0, i*scale+30, is[i]*scale, scale); public void actionperformed(actionevent e) { String[] args = input.gettext().split(" "); int n = args.length; is = new int[n]; int i; for(i=0; i<n; i++) { is[i] = Integer.parseInt(args[i]); repaint();
13 p.13 String java.lang.string : public String[] split(string regex) (regex) Integer.parseInt init split "," Java java.util.regex.pattern (JD- KDIR)/docs/ja/api/java/util/regex/Pattern.html Q str String " " - String Java : 4.9 new n int int C n 0 null int new int arr[] = {1, 7, 4, 10; ArrayIndexOutOfBoundsException n n-1
14 4 p.14 4 GUI :45 12:35 4:42 AddTime2.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class AddTime2 extends JApplet implements ActionListener { JTextField input; // e.g. 2:45 1:25 3:34 2:47 0:24 JLabel output; public void init() { input = new JTextField("", 16); output = new JLabel("00:00"); input.addactionlistener(this); setlayout(new FlowLayout()); add(input); add(new JLabel("")); add(output); add(new JLabel("")); // static int[] addtime(int[] t1, int[] t2) { // 2 int[] t3 = { t1[0]+t2[0], t1[1]+t2[1] ; if(t3[1]>=60) { // t3[0]++; t3[1]-=60; return t3; //
15 p.15 public void actionperformed(actionevent e) { String[] args = input.gettext().split("\\s+"); int[] t = { 0, 0 ; for (String s : args) { String[] stime = s.split(":"); t = addtime(t, new int[] { Integer.parseInt(stime[0]), Integer.parseInt(stime[1]) ); // addtime // GC output.settext(string.format("%02d:%02d", t[0], t[1])); addtime new C malloc init addtime Garbage Collection, GC C free GC 4.10 generic classjdk5.0 ArrayList, HashMap, LinkedList ArrayList ArrayList String ArrayList ArrayList<String> // ArrayList ArrayList<String> arr1 = new ArrayList<String>(); // arr1.add("aaa"); arr1.add("bbb"); arr1.add("ccc"); // String s = arr1.get(1); add get ArrayList ArrayList Java 8 ArrayList<String> arr1 = new ArrayList<>();
16 4 p.16 4 GUI Q Color ArrayList colors ArrayList : int, double Integer, Double Java int char double boolean Integer Character Double Boolean int Integer // ArrayList ArrayList<Integer> arr2 = new ArrayList<>(); // arr2.add(123); arr2.add(456); arr2.add(789); // int i = arr2.get(1); ArrayList<String> int add ArrayList<Integer> String get ArrayList<String> arr1 = new ArrayList<> (); arr1.add(333); // ArrayList<Integer> arr2 = new ArrayList<> ();... String t = arr2.get(2); // API E java.util.arraylist<e>: public ArrayList() public boolean add(e e) e
17 p.17 public E get(int index) index Q double ArrayList ds ArrayList : ArrayList mouseclicked paint ArrayList MouseDraw.java import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.arraylist; public class MouseDraw extends JApplet implements MouseListener { ArrayList<int[]> points; public void init() { points = new ArrayList<>(); addmouselistener(this); public void mouseclicked(mouseevent e) { points.add(new int[] { e.getx(), e.gety() ); repaint(); public void mouseentered(mouseevent e) { public void mouseexited(mouseevent e) { public void mousepressed(mouseevent e) { public void mousereleased(mouseevent e) { public void paint(graphics g) { super.paint(g); int i, n = points.size(); for (i=1; i<n; i++) { int[] p0 = points.get(i-1); int[] p1 = points.get(i);
18 4 p.18 4 GUI g.drawline(p0[0], p0[1], p1[0], p1[1]); HashMap int String HashMap HashMap<String, Color> String Color put get java.util.hashmap<k,v>: public HashMap() HashMap public V put(k key, V value) value key public V get(object key) key Object java.lang.object Java ColorName.java import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.hashmap; public class ColorName extends JApplet implements ActionListener { HashMap<String, Color> hm; JTextField input; public void init() { // hm = new HashMap<>(); hm.put(" ", new Color(0xf7acbc)); hm.put(" ", new Color(0xed1941)); hm.put(" ", new Color(0xf26522)); hm.put(" ", new Color(0xf58f98)); hm.put(" ", new Color(0xaa2116)); // input = new JTextField(" ", 8); input.addactionlistener(this);
19 4.11. GUI 4 p.19 setlayout(new FlowLayout()); add(input); public void paint(graphics g) { String text = input.gettext(); super.paint(g); g.setfont(new Font("SansSerif", Font.BOLD, 64)); int i; for (i=0; i<text.length(); i++) { String c = text.substring(i, i+1); Color color = hm.get(c); if (color==null) { color = Color.BLACK; g.setcolor(color); g.drawstring(c, 64*i, 100); public void actionperformed(actionevent e) { repaint(); java.util.linkedlist, java.util.arraydeque 4.11 GUI UpDownButton.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class UpDownButton extends JApplet implements ActionListener { int x=20; JButton lbtn, rbtn; public void init() { lbtn = new JButton("Left"); rbtn = new JButton("Right"); lbtn.addactionlistener(this);
20 4 p.20 4 GUI rbtn.addactionlistener(this); setlayout(new FlowLayout()); add(lbtn); add(rbtn); public void paint(graphics g) { super.paint(g); g.drawstring("hello WORLD!", x, 55); public void actionperformed(actionevent e) { Object source = e.getsource(); if (source == lbtn) { // lbtn x-=10; else if (source == rbtn) { // rbtn x+=10; repaint(); GUI 2 actionperformed ActionEvent getsource == Factorial.java =
21 p.21 String double java.lang.double java.lang.double : public static double parsedouble(string s) String double Integer.parseInt double double String java.lang.string : public static String format(string format, Object... args) PrintWrite printf System.out.printf Q str String "3.14" 3.14 double Java : Q x double 1.0/3 "0.333" 3 String Java : 4.12 GUI if else getsource, inner class UpDownButton.java UpDownButton2.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class UpDownButton2 extends JApplet {
22 4 p.22 4 GUI int x=20; public class LeftListener implements ActionListener { public void actionperformed(actionevent e) { x-=10; repaint(); public class RightListener implements ActionListener { public void actionperformed(actionevent e) { x+=10; repaint(); public void init() { JButton lbtn = new JButton("Left"); JButton rbtn = new JButton("Right"); lbtn.addactionlistener(new LeftListener()); rbtn.addactionlistener(new RightListener()); setlayout(new FlowLayout()); add(lbtn); add(rbtn); public void paint(graphics g) { super.paint(g); g.drawstring("hello WORLD!", x, 55); Java C LeftListener RightListeneractionPerformed x repaint addactionlistner getsource ,
23 p.23 new ( ) { ) { { ActionListener () java.lang.object UpDownButton.java anonymous class UpDownButton3.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class UpDownButton3 extends JApplet { int x=20; public void init() { JButton lbtn = new JButton("Left"); JButton rbtn = new JButton("Right"); lbtn.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { x-=10; repaint(); ); rbtn.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { x+=10; repaint(); ); setlayout(new FlowLayout()); add(lbtn); add(rbtn); public void paint(graphics g) { super.paint(g); g.drawstring("hello WORLD!", x, 55);
24 4 p.24 4 GUI 4.14 final final FinalExample.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class FinalExample extends JApplet { static final Color[] colors = {Color.RED, Color.GREEN, Color.BLUE; int c = 0; public void init() { JButton button = new JButton("Push"); button.setforeground(colors[c]); button.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { c = (c+1) % colors.length; button.setforeground(colors[c]); ); setlayout(new FlowLayout()); add(button); final final JButton button = new JButton("Push");
25 p.25 Java 7 final Java 8 final final colors final final Q Factorial.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Factorial { public void init() { JTextField input = new JTextField("0", 8); JLabel output = new JLabel(" 1"); input.addactionlistener( { public void actionperformed(actionevent e) { // actionperformed ); setlayout(new FlowLayout()); add(input); add(new JLabel(" ")); add(output); add(new JLabel("")); // factorial MouseTest.java, KeyTest.java 4.15 Java 8 ActionListener (lambda expression, λ expression) MouseListener KeyListener UpDownButton.java
26 4 p.26 4 GUI UpDownButton4.java import javax.swing.*; import java.awt.*; /* <applet code="updownbutton4.class" width="200" height="70"> </applet> */ public class UpDownButton4 extends JApplet { int x=20; public void init() { JButton lbtn = new JButton("Left"); JButton rbtn = new JButton("Right"); lbtn.addactionlistener(e -> { x-=10; repaint(); ); rbtn.addactionlistener(e -> { x+=10; repaint(); ); setlayout(new FlowLayout()); add(lbtn); add(rbtn); public void paint(graphics g) { super.paint(g); g.drawstring("hello WORLD!", x, 55); -> ( 1 1, 2 2,..., n n ) -> { ( 1, 2,..., n ) -> { -> { return { return ; ( 1 1, 2 2,..., n n ) -> ( 1, 2,..., n ) -> ->
27 p FinalExample.java JTextArea, JPanel, JCheckBox, JComboBox, JList, JTable, JTree GUI FlowLayout GUI Layout keytyped, mouseclicked, actionperformed, interface, MouseListener, KeyListener, ActionListener, this, MouseEvent, KeyEvent, ActionEvent, add, JButton, JLabel, JTextField, Integer.parseInt, split,, ArrayList, HashMap, LinkedList
28
4 p.2 4 GUI return; public void mousepressed(mouseevent e) { /* 5 */ public void mousereleased(mouseevent e) { /* 5 */ public void mouseentered(mousee
4 p.1 4 GUI GUI GUI Java Java try catch C 4.1 4.1.1 4.1.1 MouseTest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; /* 1 */ public class MouseTest extends JPanel implements MouseListener
I 4 p.2 4 GUI java.awt.event.* import /* 1 */ import mouseclicked MouseListener implement /* 2 */ init addmouselistener(this) this /* 3 */ this mousec
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
I 3 p.2 3 Java 3.1.2 AddTime.java public class AddTime extends JApplet { int hour1, minute1, hour2, minute2; public void init() { hour1 = Integer.pars
I 3 p.1 3 Java Java Java try catch C Java if for while C 3.1 boolean Java if C if ( ) 1 if ( ) 1 else 2 1 1 2 2 1, 2 { 2 boolean Graphics draw3drect fill3drect C int C OK while (1)... 3.1.1 int boolean...............
3 p.1 3 Java Java Java try catch C Java if for while C 3.1 boolean Java if C if ( ) 1 if ( ) 1 else , 2 { } boolean true false 2 boolean Gr
3 p.1 3 Java Java Java try catch C Java if for while C 3.1 boolean Java if C if ( ) 1 if ( ) 1 else 2 1 1 2 2 1, 2 { boolean true false 2 boolean Graphics draw3drect fill3drect C int C OK while (1)...
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 (
2016 07 29 10:30 12:00 I. I V II. III. IV. ( a d) V. VI. 80 100 60 : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeylistener KE KeyEvent M MouseListener am addmouselistener
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
2018 06 08 11:00 12:00 I. I III II. III. IV. ( a d) V. VI. 80 40 40 100 60 : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeylistener KE KeyEvent M MouseListener am addmouselistener
: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
2014 8 01 10:30 12:00 I. I VII II. III. IV. ( a d) V. VI. 80 100 60 : this==null, T == N A ActionListener A addactionlistener C class D actionperformed E ActionEvent G getsource I implements J JApplet
KeyListener init addkeylistener addactionlistener addkeylistener addkeylistener( this ); this.addkeylistener( this ); KeyListener public void keytyped
KeyListener keypressed(keyevent e) keyreleased(keyevent e) keytyped(keyevent e) MouseListener mouseclicked(mouseevent e) mousepressed(mouseevent e) mousereleased(mouseevent e) mouseentered(mouseevent e)
Chapter JDK KeyListener keypressed(keyevent e ) keyreleased(keyevent e ) keytyped(keyevent e ) MouseListener mouseclicked(mouseeven
Chapter 11. 11.1. JDK1.1 11.2. KeyListener keypressed(keyevent e ) keyreleased(keyevent e ) keytyped(keyevent e ) MouseListener mouseclicked(mouseevent e ) mousepressed(mouseevent e ) mousereleased(mouseevent
I HTML HashMap (i) (ii) :.java import java.net.*; import java.io.*; import java.util.hashmap; public class SimpleStopWatch { public static voi
II Java 10 2 12 10:30 12:00 I. I III II. III. IV. ( a d) V. : this==null, T == N A ActionListener C class D actionperformed G getsource I implements K KeyListener J JApplet L addmouselistener M MouseListener
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
II Java 09 2 13 10: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 KeyListener J JApplet L addmouselistener M MouseListener
Microsoft PowerPoint prog1_doc2x.pptx
アプレット public class extends Applet { public void paint(graphics g) { // アプレット描画 g.drawstring( Hello World, 10, 20 ); page 1 アプレット : 色 public class extends Applet { Color col; // カラークラス int red, grn, blu;
Microsoft PowerPoint prog1_doc2.pptx
2011 年 12 月 6 日 ( 火 ) プログラミング Ⅰ Java Applet プログラミング 文教大学情報学部経営情報学科堀田敬介 アプレット Applet public class クラス名 extends Applet { public void paint(graphics g) { // アプレット描画 g.drawstring( Hello World, 10, 20); 10
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
Java 3 p.1 3 Java Java if for while C 3.1 if Java if C if if ( ) 1 if ( ) 1 else 2 1 1 2 2 1, 2 { Q 3.1.1 1. int n = 2; if (n
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;
5 p.1 5 JPanel (toy example) 5.1 2 extends : Object java.lang.object extends... extends Object Point.java 1 public class Point { // public int x; public int y; Point x y 5.1.1, 5 p.2 5 5.2 Point int Java
Java 2 - Lesson01
第 2 回 GUI コンポーネントのイベント処理 GUI Component Event Handling キーポイント イベント イベントリスナー イベント処理とは何か? ActionEventとActionListenerについて ItemEventとItemListenerについて TextEventとTextListenerについて KeyEventとKeyListenerについて AdjustmentEventとadjustmentListenerについて
次の演習課題(1),(2)のプログラムを完成させよ
次の演習課題 (1),(2) のプログラムを作成せよ. 課題 (1) ボタン押下時の処理を追加し以下の実行結果となるようにプログラムを作成しなさい ( ボタン押下時の処理 ) import java.lang.*; class Figure extends JFrame implements ActionListener{ JPanel panel; JScrollPane scroll; JTextArea
r3.dvi
10 3 2010.9.21 1 1) 1 ( 1) 1: 1) 1.0.1 : Java 1 import java.awt.*; import javax.swing.*; public class Sample21 extends JPanel { public void paintcomponent(graphics g) { g.setcolor(new Color(255, 180, 99));
新・明解Java入門
537,... 224,... 224,... 32, 35,... 188, 216, 312 -... 38 -... 38 --... 102 --... 103 -=... 111 -classpath... 379 '... 106, 474!... 57, 97!=... 56 "... 14, 476 %... 38 %=... 111 &... 240, 247 &&... 66,
2008 e-learning T050050
e-learning T050050 e-learning B NintendoDS e-learning html 1 e-learning Java Applet html 2 2008 e-learning T050050 1 1 1.1.................................. 1 1.2............................ 1 2 2 2.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 +=
Safari AppletViewer Web HTML Netscape Web Web 13-1 Applet Web Applet init Web paint Web start Web HTML stop destroy update init Web paint start Web update Event Driven paint Signature Overwriting Overriding
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
try catch Exception Java try catch catch ( Exception e ) { e 16-1 try catch 0 int x = 0; int y = 10 / x; catch ( Exception e ) { System.err.println( " " ); Copyright by Tatsuo Minohara 2004 Rev. C on Dec.
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
2 p.1 2 Java Java JDK Sun Microsystems Oracle JDK javac Java java JVM appletviewer IDESun Microsystems NetBeans, IBM 1 Eclipse 2 IDE GUI JDK Java 2.1 Hello World! 2.1.1 Java 2.1.1 Hello World Emacs Hello0.java
JAVA入門
JAVA 入 門 後 期 3 JAVAのGUI (JavaのGUI 基 本 構 造 いろいろなアプレット) 1.GUI 構 造 GUI 構 造 JAVAでGUIを 構 築 するクラスとして 下 記 のがあります 1アプレットパッケージ 2AWT 3Swing 特 に2 3はコンポーネント パッケージを 利 用 1アプレット 概 要 特 徴 GUI 構 造 1. 最 初 から GUI 環 境 が 用
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
[email protected] [email protected] http://www.misojiro.t.u-tokyo.ac.jp/ tutimura/sem3/ 2002 12 11 p.1/33 10/16 1. 10/23 2. 10/30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20
Java演習(4) -- 変数と型 --
50 20 20 5 (20, 20) O 50 100 150 200 250 300 350 x (reserved 50 100 y 50 20 20 5 (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics; (reserved public class Blocks1 extends
Java 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 2.
Java 2 p.1 2 Java Java JDK Sun Microsystems Oracle JDK javac Java java JVM appletviewer IDE Sun Microsystems NetBeans, IBM 1 Eclipse 2 IDE GUI JDK Java 2.1 Hello World! 2.1.1 Java 2.1.1 Hello World Emacs
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
1-1 1-2 IE6 2 BMI 3-1 3-2 4 5 chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chapter8 : 13-1 13-2 14 15 PersonTest.java KazuateGame.java
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
2 p.1 2 Java Java JDK Sun Microsystems Oracle JDK javac Java java JVM appletviewer IDESun Microsystems NetBeans, IBM 1 Eclipse 2 IDE GUI JDK Java 2.1 Hello World! 2.1.1 Java 2.1.1 Hello World Emacs Hello0.java
Assignment_.java /////////////////////////////////////////////////////////////////////// // 課題 星の画像がマウスカーソルを追従するコードを作成しなさい 次 ///////////////////
Assignment_.java 0 0 0 0 0 /////////////////////////////////////////////////////////// // 課題 次のようにマウスのカーソルに同期しメッセージを /////////////////////////////////////////////////////////// class Assignment_ extends
2 p.2 2 Java > javac Hello0.java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.j
2 p.1 2 Java Java JDK Sun Microsystems Oracle JDK javac Java java JVM appletviewer IDESun Microsystems Oracle NetBeans, IBM 1 Eclipse 2, JetBrains IntelliJ IDEA IDE GUI JDK Java 2.1 Hello World! 2.1.1
Java言語 第1回
Java 言語 第 11 回ウインドウ型アプリケーション (2) 知的情報システム工学科 久保川淳司 [email protected] メニュー (1) メニューを組み込むときには,MenuBar オブジェクトに Menu オブジェクトを登録し, その Menu オブジェクトに MenuItem オブジェクトを登録する 2 つの Menu オブジェクト File New
やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF
pref : 2004/6/5 (11:8) pref : 2004/6/5 (11:8) pref : 2004/6/5 (11:8) 3 5 14 18 21 23 23 24 28 29 29 31 32 34 35 35 36 38 40 44 44 45 46 49 49 50 pref : 2004/6/5 (11:8) 50 51 52 54 55 56 57 58 59 60 61
目 次 Java GUI 3 1 概要 クラス構成 ソースコード例 課題...7 i
Java GUI 3 Java GUI 3 - サンプルプログラム (1) - 2011-09-25 Version 1.00 K. Yanai 目 次 Java GUI 3 1 概要...1 2 クラス構成...2 3 ソースコード例...3 4 課題...7 i 1 概要まずは簡単なサンプルプログラムをみながら Java GUI の基本的なことを学びましょう 本サンプルは 図に示すようなひとつのメイン画面を使用します
public class Kadai _02 { public static void main(string[] args) { MyFrame frame = new MyFrame("Kadai _02"); (2) フレームのクラス名は MyFrame とし 以下
オブジェクト指向プログラミング演習課題 20071128 以下のような GUI 画面を表示するプログラムを完成させなさい 前回演習で作成したプログラムにイベント処理を追加します 注意 : ファイル名が同じものがあるので 課題毎にディレクトリーを分ける等してください 課題 20071128_01 講義資料内で紹介したイベント処理の例 2 を作成し 動作を確認せよ (1) コントロールクラス (main
Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1
Java (9) 1 Lesson 7 2008-05-20 Java System.out.println() 1 Java API 1 Java Java 1 GUI 2 Java 3 1.1 5 3 1.0 10.0, 1.0, 0.5 5.0, 3.0, 0.3 4.0, 1.0, 0.6 1 2 4 3, ( 2 3 2 1.2 Java (stream) 4 1 a 5 (End of
< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>
2 次関数のグラフの向きと広がり [Java アプレット ] [Java アプリケーション ] 1. はじめに 2 2 y=ax のグラフについて x の係数 aが正のときと負のときでは グラフにどのような違いがあるでしょうか 2 2 y=ax のグラフについて x の係数 aが正のとき 係数 aの値が大きくなるにつれて グラフの広がりはどうなるでしょうか 2 2 y=ax のグラフについて x の係数
< F2D82518CC282CC D2E6A7464>
2 個のさいころ 1. はじめに [Java アプレット ] [Java アプリケーション ] 2 個のさいころを同時に投げたときの目の出方を考えてみましょう この 2 個のさいころをそれぞれ さいころ Ⅰ さいころ Ⅱ とすると その目の出方は順に 1 1 2 1 3 1 4 1 5 1 6 1 1 2 2 2 3 2 4 2 5 2 6 2 1 3 2 3 3 3 4 3 5 3 6 3 1 4
Java演習(9) -- クラスとメソッド --
Java (9) Java (9) Java (9) 3 (x, y) x 1 30 10 (0, 50) 1 2 10 10 (width - 10, 80) -2 3 50 10 (width / 2, 110) 2 width 3 (RectMove4-1.java) import javax.swing.japplet; import javax.swing.timer; import java.awt.graphics;
Java言語 第1回
Java 言語 第 8 回ウインドウ部品を用いる (1) 知的情報システム工学科 久保川淳司 [email protected] 前回の課題 (1) マウスを使って, 前回課題で作成した 6 4 のマスの図形で, \ をマウスクリックによって代わるようにしなさい 前回の課題 (2) import java.applet.applet; import java.awt.*;
PowerPoint Presentation
ソフトウェア演習 B GUI を持つ Java プログラムの 設計と実装 4.1 例題 :GUI を持った電卓を作ろう プロジェクトCalculator パッケージ名 :example ソースファイル : Calculator.java GUI.java EventProcessor.java 2 4.2 GUI とイベント処理 GUI の構成 :Swing GUI の場合 フレーム JFrame:
r3.dvi
00 3 2000.6.10 0 Java ( 7 1 7 1 GSSM 1? 1 1.1 4 4a 4b / / 0 255 HTML X 0 255 16 (0,32,255 #0020FF Java xclock -bg #0020FF xclock ^C (Control C xclock 4c 1 import java.applet.applet; import java.awt.*;
Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem
Java Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem 2 MenuComponent MenuComponent setfont() void setfont(font f) MenuBar MenuBar MenuBar() MenuBar add() Menu add(menu m) Menu Menu Menu String
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
2 p.1 2 Java Java JDK Sun Microsystems Oracle JDK javac Java java JVM IDESun Microsystems Oracle NetBeans, IBM 1 Eclipse 2, JetBrains IntelliJ IDEA IDE GUI JDK Java 2.1 Hello World! 2.1.1 Java 2.1.1 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
55 7 Java C Java TCP/IP TCP/IP 7.1 7.1.1 TCP TCP_RO.java import java.net.*; import java.io.*; public class TCP_RO { public static void main(string[] argv) { Socket readsocket = new Socket(argv[0], Integer.parseInt(argv[1]));
< F2D82518E9F8AD CC95BD8D7388DA93AE2E6A7464>
2 次関数のグラフの平行移動 [Java アプレット ] [Java アプリケーション ] 1. はじめに 2 2 y=ax のグラフとy=a(x-b) +c のグラフは 位置は違うけれど 形も広がりも全く同じです 2 2 y=a(x-b) +c のグラフは y=ax のグラフをx 軸方向に ( 右方向に ) +b y 軸方向に ( 上方向に ) +c だけ平行移動したものです 2 シミュレーションソフト
extends (*) (*) extend extends 2
2007-2-1-4 1 1.1 1 extends (*) (*) extend extends 2 class Person { private String name; String name() {return name; Person(String name) { this.name=name; class Worker extends Person { private int salary;
