Report#7


²ÝÂêÆâÍÆ
©¡¶ö¿ô´ñ¿ôȽÄê¥×¥í¥°¥é¥à(GUIaa)¤ò¥¿¥¤¥×¤·¡¢¤½¤ÎÆ°ºî¤ò¹Í»¡¤»¤è¡£
©¢Îã³°½èÍý¤Ë¤Ä¤¤¤Æ¹Í»¡¤»¤è¡£
©£¾å½Ò¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë½Ð¤Æ¤­¤¿GUIÉôÉʤòÁ´¤Æ»È¤Ã¤¿¥×¥í¥°¥é¥à¤òºîÀ®¤»¤è¡£
©¤Àݻᤫ¤é²Ú»á¡¢²Ú»á¤«¤éÀÝ»á¤Ø¤Î²¹ÅÙ´¹»»¤¬½ÐÍè¤ë¥×¥í¥°¥é¥à¤òºîÀ®¤»¤è¡£
©¥¡ØÅÅÂî¡Ù¥×¥í¥°¥é¥à¡£Ãæ¿È¤Ï¼«Í³¡£


¶ö¿ô´ñ¿ôȽÄê¥×¥í¥°¥é¥à(GUIaa)¤ò¥¿¥¤¥×¤·¡¢¤½¤ÎÆ°ºî¤ò¹Í»¡¤»¤è

01:import java.awt.*;
02:import java.awt.event.*;

public class GUIaa extends Frame {
Button b0 = new Button("Even/Odd?");
Label x0 = new Label("Type a number and press...");
TextField t0 = new TextField();

public GUIaa() {
setLayout(null);
add(t0); t0.setBounds(10, 40, 90, 30);
add(b0); b0.setBounds(110, 40, 80, 30);
add(x0); x0.setBounds(10, 80, 180, 30);
b0.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int i = (new Integer(t0.getText())).intValue();
t0.setText("");
if(i % 2 == 0) {
x0.setText(i + " is Even");
} else {
x0.setText(i + " is Odd");
}
}
});
}
public static void main(String[] args) {
Frame win = new GUI();
win.setSize(200, 150); win.setVisible(true);
win.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
});
}
}

¼Â¹Ô·ë²Ì

¹Í»¡

Â礭¤¯¤ï¤±¤ë¤È¼¡¤Î¤è¤¦¤Ë¤Ê¤ë
(1)¥¤¥ó¥Ý¡¼¥ÈÉôʬ
java.awt¥Ñ¥Ã¥±¡¼¥¸¤Èjava.awt.event¥Ñ¥Ã¥±¡¼¥¸¤òimport¤·¤Æ¤¤¤ë¡£
import java.awt.*¤Çjava.awtÆâ¤Î¤¹¤Ù¤Æ¤Î¥¯¥é¥¹¤Ï»²¾È¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ë¤¬
java.awtÃæ¤Î¥Ñ¥Ã¥±¡¼¥¸Æâ¤Î¥¯¥é¥¹¤Þ¤Ç¤Ï»²¾È¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
¤½¤Î¤¿¤á¡¢¤µ¤é¤Ëimport java.awt.event.*¤òµ­½Ò¤·¤Æ¤¤¤ë¡£
4¹ÔÌܤÇFrame¥¯¥é¥¹¤Î¥µ¥Ö¥¯¥é¥¹¤òºîÀ®

(2)GUIÉôÉʤΥª¥Ö¥¸¥§¥¯¥È²½ awt¥Ñ¥Ã¥±¡¼¥¸¤Î¤Ê¤«¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¥¯¥é¥¹¤ò¥ª¥Ö¥¸¥§¥¯¥È²½¤·¤Æ¼ÂÁõ¤·¤Þ¤¹¡£
Buttan¤ÈLabel¤ÈTextField¤ò»ÈÍÑ

(3)¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ÎÇÛÃÖ¤ò·è¤á¤ë
etLayout(null);¤Ë¤è¤ê¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î°ÌÃÖ¤ò»ØÄê
add()¤Î¥á¥½¥Ã¥É¤Ç¤³¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¥³¥ó¥Ý¡¼¥Í¥ó¥È¤òÄɲä·¤Þ¤¹¡£
obj.setBounds(x, y, width, height); ¤Î¥á¥½¥Ã¥É¤Ç¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î°ÌÃÖ¤ÈÂ礭¤µ¤ò»ØÄꤷ¤Þ¤¹
°ú¿ô¤Ï¤¹¤Ù¤Æint·¿¤Ç¤¹¡£
x¤Èy¤Ç¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Îº¸¾å¤ÎºÂɸ¤ò¡¢width¤ÇÉý¤ò¡¢height¤Ç¹â¤µ¤ò¤½¤ì¤¾¤ì»ØÄꤷ¤Þ¤¹¡£

(4)¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤È¤­¤Î¥¤¥Ù¥ó¥È¤ÎÀßÄê
¤³¤Î¥×¥í¥°¥é¥à¤Ç¥¢¥¯¥·¥ç¥ó¥¤¥Ù¥ó¥È¤Ï¥Ü¥¿¥ó¤ò²¡¤·¤¿¤È¤­¤ËÀ¸À®¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤È¤­¤Ë¥Æ¥­¥¹¥È¥Õ¥£¡¼¥ë¥É¤Ë¤¢¤ëʸ»úÎó¤òint·¿¤ËÊÑ´¹¤·¤ÆÊÑ¿ô¤ËÂåÆþ¤·,
¤½¤Î¸å¥Æ¥­¥¹¥È¥Õ¥£¡¼¥ë¥É¤Ë¤¢¤ëʸ»úÎó¤ò¾Ãµî
¤¢¤Þ¤ê¤Ë´ó¤ëȽÄê¤Ç¶ö¿ô¤Ê¤é¡Áis Even ¡¢´ñ¿ô¤Ê¤é¡Áis Odd¤È½ÐÎÏ

(5)main¥á¥½¥Ã¥É¤È¥×¥í¥°¥é¥à¤Î½ªÎ»
java¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ËɬÍפÊmain¥á¥½¥Ã¥É¤òÄêµÁ¡£
GUIaa¤ò¥ª¥Ö¥¸¥§¥¯¥È²½¤·¤Æ¼Â¹Ô¤Ç¤­¤ë·Á¤Ë¤·¤Þ¤¹¡£
¥¦¥£¥ó¥É¥¦¤ÎÊĤ¸¤ë¥Ü¥¿¥ó¤ò²¡¤·¤¿¤È¤­¤ËÀ¸À®¤µ¤ì¤ë¥¤¥Ù¥ó¥È¤òÄêµÁ¤¹¤ë¡£
¤³¤Î¥¤¥Ù¥ó¥È¤òÀßÄꤷ¤Ê¤¤¤È¡¢ÊĤ¸¤ë¥Ü¥¿¥ó¤ò¤ª¤·¤Æ¤â¥¦¥£¥ó¥É¥¦¤¬¾Ã¤¨¤Ê¤¤¾õ¶·¤Ë¤Ê¤ë

GUI¤È¤Ï¾ðÊó¤Îɽ¼¨¤Ë¥°¥é¥Õ¥£¥Ã¥¯µ¡Ç½¤ò¿ÍѤ·¶¥¤Æ¤¯¤ÊÁàºî¤ò¥Þ¥¦¥¹Åù¤Î¥Ý¥¤¥ó¥Æ¥£¥ó¥°¤Ç¥Ð¥¤¥¹¤Ë¤è¤Ã¤Æ¹Ô¤¦
¥æ¡¼¥¶¡¼¥¤¥ó¥¿¡¼¥Õ¥§¥¤¥¹¤Î¤³¤È¤ò»Ø¤¹¡£³¨¤ä¥¢¥¤¥³¥ó¤Çɽ¤¹¤Î¤Ç½é¿´¼Ô¤Ë¤âÍưפËÁàºî¤¬²Äǽ¤È¤Ê¤ë¡£
GUI¥×¥í¥°¥é¥à¤Ï¥¤¥Ù¥ó¥È¤ò¼õ¤±¤ë¤³¤È¤Ç½èÍý¤ò¹Ô¤¦

Îã³°½èÍý¤Ë¤Ä¤¤¤Æ¹Í»¡¤»¤è

Îã³°½èÍý¡á¥¨¥é¡¼½èÍý¡¡¹½Ê¸¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£

try{¡¡¡¡ ¡¡¡¡¡¡Îã³°¤ÎȯÀ¸¤òÃΤ餻¤ëʸ; ¡¡¡¡} catch(Îã³°¤Î¥¯¥é¥¹¡¡ÊÑ¿ô̾){ Îã³°¤¬µ¯¤­¤¿»þ¤ËÂн褹¤ëʸ; } finally{ ¡¡¡¡¡¡ºÇ½ª½èÍý ¡¡¡¡}

¤³¤Î¹½Ê¸¤Ï¼¡¤Î¤è¤¦¤Ê½çÈ֤ǽèÍý¤µ¤ì¤Þ¤¹¡£
£±¡¡try¥Ö¥í¥Ã¥¯Ãæ¤ÇÎã³°¤¬µ¯¤­¤ë¤È¡¢¤½¤³¤Ç½èÍý¤òÃæÃǤ¹¤ë¡£
£²¡¡Îã³°¤¬catch¥Ö¥í¥Ã¥¯¤Î()Æâ¤ÎÎã³°¤Î¼ïÎब°ìÃפ·¤Æ¤¤¤ì¤Ð¡¢¤½¤Îcatch¥Ö¥í¥Ã¥¯Æâ¤Î½èÍý¤ò¹Ô¤¦¡£
£³¡¡catch¥Ö¥í¥Ã¥¯¤¬½ª¤ï¤Ã¤¿¤é¡¢¤½¤Îtry¡Ácatch¥Ö¥í¥Ã¥¯¤Î¤¢¤È¤«¤é½èÍý¤¬Â³¤±¤é¤ì¤ë¡£
Îã³°½èÍý¤ò¹Ô¤¦¤È¡¢¥×¥í¥°¥é¥à¤¬ÅÓÃæ¤Ç½ªÎ»¤¹¤ë»ö¤Ï¤¢¤ê¤Þ¤»¤ó¡¢¤Þ¤ºÎã³°¤ò¼õ¤±¼è¤Ã¤Æcatch¥Ö¥í¥Ã¥¯¤Ç¡ÖÇÛÎó¤ÎÍ×ÁǤò¤³¤¨¤Æ¤¤¤Þ¤¹¡£¡×
¤È¤¤¤¦¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò½ÐÎϤ·¤Æ¤¤¤Þ¤¹¡£¤½¤·¤ÆºÇ¸å¤Þ¤Ç̵»ö¤Ë½èÍý¤¬¼Â¹Ô¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£ ¾¤Ëfinally¥Ö¥í¥Ã¥¯¤È¤¤¤¦¤Î¤¬¤¢¤ê¤Þ¤¹¤¬¡¢¤³¤Î¥Ö¥í¥Ã¥¯¤ÏÎã³°¤¬µ¯¤­¤ë¡¢µ¯¤­¤Ê¤¤´Ø¤ï¤é¤ºÉ¬¤ººÇ¸å¤Ë½èÍý¤µ¤ì¤ë¥Ö¥í¥Ã¥¯¤Ç¤¹¡£ ¥½¡¼¥¹¤Ç¤Ïcatch¥Ö¥í¥Ã¥¯¤Î²¼¤Ë½ñ¤«¤ì¤Þ¤¹¡£

b0.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try{
int i = (new Integer(t0.getText())).intValue();
t0.setText("¿ô»ú¤òÆþÎÏ");
if(i % 2 == 0) {
x0.setText(i + " ¡á¶ö¿ô");
} else {
throw new ArithmeticException();
}
}catch (ArithmeticException ex) {
x0.setText("´ñ¿ô");
}
catch (NumberFormatException ex) {
x0.setText("¿ô»ú¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤");
}
finally{
t0.setText("¼Â¹Ô·ë²Ì");
} } });

¾åµ­¤òÁȤ߹þ¤ó¤À·ë²ÌÎã³°½èÍý¤¬½ÐÍ褿¡£

¾å½Ò¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë½Ð¤Æ¤­¤¿GUIÉôÉʤòÁ´¤Æ»È¤Ã¤¿¥×¥í¥°¥é¥à¤òºîÀ®¤»¤è

import java.awt.*;
import java.awt.event.*;
public class GUI extends Frame {
Button b0 = new Button("END");
Label x0 = new Label("ưʪ¤Ë¤Ä¤¤¤Æ¤Î¥¢¥ó¥±¡¼¥È¤Ç¤¹");
Label x1 = new Label("Q1:¤¢¤Ê¤¿¤Ï²¿ºÐ¤Ç¤¹¤«");
Label x2 = new Label("Q2:¼¡¤Î¤¦¤Á¤É¤ì¤¬°ìÈÖ¹¥¤­¤Ç¤¹¤«?");
Label x3 = new Label("Q3:¤¢¤Æ¤Ï¤Þ¤ë¤â¤Î¤òÁ´¤Æ¥Á¥§¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤");
Label x4 = new Label("Q4:¤³¤Î¥¢¥ó¥±¡¼¥È¤Ç¤ÎÀ­³Ê¿ÇÃǤò´õ˾¤·¤Þ¤¹¤«¡©");
Label x5 = new Label();
TextField t0 = new TextField();

Checkbox c0 = new Checkbox("¤É¤ó¤ÊÁê¼ê¤Ç¤â¤­¤Ã¤Èʬ¤«¤ê¹ç¤¨¤ë");
Checkbox c1 = new Checkbox("¢¬¤½¤ó¤Ê¤³¤È¤Ï̵¤¤");
Checkbox c2 = new Checkbox("Ãî¤Ë¤Ï»¦ÃîºÞ");
Checkbox c3 = new Checkbox("¥é¥¤¥ª¥ó¤À¤Ã¤ÆÇ­¤ß¤¿¤¤¤Ê¤â¤ó¤µ");
Checkbox c4 = new Checkbox("¥Ú¥Ã¥È¤È¸À¤Ã¤¿¤é¸¤¤äÇ­");
Checkbox c5 = new Checkbox("Q2¤ÇÁª¤ó¤À¤Î¤Ï¥Ú¥Ã¥È¤Ë¤·¤¿¤¤Æ°Êª¤Ç¤¢¤ë");
Choice c01 = new Choice();
List l1 = new List();

public GUI() {
setLayout(null);
add(b0); b0.setBounds(10, 580, 90, 20);

add(x0); x0.setBounds(10, 30, 80, 20);
add(x1); x1.setBounds(10, 70, 80, 20);
add(x2); x2.setBounds(10, 140, 80, 20);
add(x3); x3.setBounds(10, 210, 80, 20);
add(x4); x4.setBounds(10, 490, 80, 20);
add(x5); x5.setBounds(10, 610, 200, 20);
add(t0); t0.setBounds(20, 100, 30, 20);

add(c0); c0.setBounds(10, 250, 600, 20);
add(c1); c1.setBounds(10, 290, 600, 20);
add(c2); c2.setBounds(10, 330, 600, 20);
add(c3); c3.setBounds(10, 370, 600, 20);
add(c4); c4.setBounds(10, 410, 600, 20);
add(c5); c5.setBounds(10, 450, 600, 20);

add(c01); c01.setBounds(10, 170, 80, 20);
c01.add("");
c01.add("1.Ç­");
c01.add("2.¸¤");
c01.add("3.¥Í¥º¥ß");
c01.add("4.¤ÏÃîÎà");
c01.add("5.Ä»Îà");
c01.add("6.¿Í´Ö");
c01.add("7.Ãϵ峰À¸Ì¿ÂÎ");
add(l1); l1.setBounds(10, 520, 80, 40);
l1.add(" ¤Ï¤¤ "); l1.add(" ¤¤¤¤¤¨ ");
b0.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
x5.setText("by¡¡Ë̶˷§");
}
});
}

public static void main(String[] args) {
Frame win = new GUI();
win.setSize(600, 650); win.setVisible(true);
win.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt){
System.exit(0);
}
});
}
}

¼Â¹Ô·ë²Ì


Àݻᤫ¤é²Ú»á¡¢²Ú»á¤«¤éÀÝ»á¤Ø²¹ÅÙÊÑ´¹¤¹¤ë¥×¥í¥°¥é¥à

import java.awt.*;
import java.awt.event.*;

public class ondo extends Frame {
Button b0 = new Button("Àݻᢪ²Ú»á");
Button b1 = new Button("²Ú»á¢ªÀÝ»á");
Label x0 = new Label("²¹ÅÙ´¹»»¥½¥Õ¥È");
Label x1 = new Label("·ë²Ì¢ª");

TextField t0 = new TextField();
TextField t1 = new TextField();

public ondo() {
setLayout(null);
add(t0); t0.setBounds(10, 40, 80, 30);
add(t1); t1.setBounds(100, 120, 80, 30);
add(b0); b0.setBounds(100, 40, 80, 30);
add(b1); b1.setBounds(100, 80, 80, 30);

add(x0); x0.setBounds(50, 20, 180, 30);
add(x1); x1.setBounds(10, 130, 180, 30);

b0.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try{
int i = (new Integer(t0.getText())).intValue();
t1.setText("" + (i*1.8+32));
}catch(Exception ex) {
t1.setText("¼ºÇԤå¹");
}
}
});

b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try{
int i = (new Integer(t0.getText())).intValue();
t1.setText("" + (i-32)/1.8);
}catch(Exception ex) {
t1.setText("¥ß¥¹");
}
}
});
}

public static void main(String[] args) {
Frame win = new ondo();
win.setSize(200, 160);
win.setVisible(true);
win.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent evt){
System.exit(0);
}
});
}
}

¼Â¹Ô·ë²Ì

¡ØÅÅÂî¡Ù¥×¥í¥°¥é¥à¤òÃæ¿È¤Ï¼«Í³¤ËºîÀ®¤»¤è

import java.awt.*;
import java.awt.event.*;

public class GUI extends Frame {
int l1,l2;
Button b0 = new Button("0");
Button b1 = new Button("1");
Button b2 = new Button("2");
Button b3 = new Button("3");
Button b4 = new Button("4");
Button b5 = new Button("5");
Button b6 = new Button("6");
Button b7 = new Button("7");
Button b8 = new Button("8");
Button b9 = new Button("9");
Button ba = new Button("+");
Button bb = new Button("-");
Button bc = new Button("*");
Button bd = new Button("/");
Button be = new Button("=");
Button bf = new Button("C");
Button bg = new Button("AC");
TextField t0 = new TextField("0");

public GUI() {
setLayout(null);
add(t0); t0.setBounds(10, 50, 230, 40);
add(b0); b0.setBounds(10, 230, 120, 34);
add(b1); b1.setBounds(10, 200, 60, 34);
add(b2); b2.setBounds(68, 200, 60, 34);
add(b3); b3.setBounds(126, 200, 60, 34);
add(b4); b4.setBounds(10, 170, 60, 34);
add(b5); b5.setBounds(68, 170, 60, 34);
add(b6); b6.setBounds(126, 170, 60, 34);
add(b7); b7.setBounds(10, 140, 60, 34);
add(b8); b8.setBounds(68, 140, 60, 34);
add(b9); b9.setBounds(126, 140, 60, 34);
add(ba); ba.setBounds(184, 170, 60, 34);
add(bb); bb.setBounds(184, 140, 60, 34);
add(bc); bc.setBounds(126, 110, 60, 34);
add(bd); bd.setBounds(68, 110, 60, 34);
add(be); be.setBounds(184, 200, 60, 64);
add(bf); bf.setBounds(10, 110, 60, 34);
add(bg); bg.setBounds(184, 110, 60, 34);

ba.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
l1 =(new Integer(t0.getText())).intValue();----()
t0.setText("0");
l2=0;
}
});
bb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
l1 =(new Integer(t0.getText())).intValue();
t0.setText("0");
l2=1;
}
});
bc.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
l1 =(new Integer(t0.getText())).intValue();
t0.setText("0");
l2=2;
}
});
bd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
l1 =(new Integer(t0.getText())).intValue();
t0.setText("0");
l2=3;
}
});

be.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int i =(new Integer(t0.getText())).intValue();----(a)
if(l2 == 0){ //-----------------(b)
int sum =( l1 + i);
t0.setText(""+sum);

}
else if(l2 == 1){
int sum = l1 - i;
t0.setText(""+sum);
}
else if(l2 == 2){
int sum = l1 * i;
t0.setText(""+sum);
}
else if(l2 == 3){
int sum = l1 / i;
t0.setText(""+sum);
}
else {
int sum=l1;
t0.setText(""+sum);
}
}
});
bf.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int l1=Integer.parseInt(t0.getText());
t0.setText("0");
l2=5; //---------------------------(c)
}
});
bg.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
t0.setText("0");
}
});
b0.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int j = Integer.parseInt(t0.getText());
int sum = j*10; //----------(d)
String s = Integer.toString(sum); //----------(e)
t0.setText(s);
}
});
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int j = Integer.parseInt(t0.getText());
int sum = j * 10 + 1;
String s = Integer.toString(sum);
t0.setText(s);
}
});
b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int j = Integer.parseInt(t0.getText());
int sum = j * 10 + 2;
String s = Integer.toString(sum);
t0.setText(s);
}
});
b3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int j = Integer.parseInt(t0.getText());
int sum = j * 10 + 3;
String s = Integer.toString(sum);
t0.setText(s);
}
});
b4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int j = Integer.parseInt(t0.getText());
int sum = j * 10 + 4;
String s = Integer.toString(sum);
t0.setText(s);
}
});
b5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int j = Integer.parseInt(t0.getText());
int sum = j * 10 + 5;
String s = Integer.toString(sum);
t0.setText(s);
}
});
b6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int j = Integer.parseInt(t0.getText());
int sum = j * 10 + 6;
String s = Integer.toString(sum);
t0.setText(s);
}
});
b7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int j = Integer.parseInt(t0.getText());
int sum = j * 10 + 7;
String s = Integer.toString(sum);
t0.setText(s);
}
});
b8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int j = Integer.parseInt(t0.getText());
int sum = j * 10 + 8;
String s = Integer.toString(sum);
t0.setText(s);
}
});
b9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int j = Integer.parseInt(t0.getText());
int sum = j * 10 + 9;
String s = Integer.toString(sum);
t0.setText(s);
}
});

}
public static void main(String[] args) {
GUI win = new GUI();
win.setSize(250, 280);
win.setVisible(true);
win.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
});
}
}

¼Â¹Ô·ë²Ì

´¶ÁÛ¤ÈÈ¿¾Ê

Ť¤¥×¥í¥°¥é¥à¤òºî¤ë¤Î¤ÏÈè¤ì¤ë......û¤¯¤Æ¤âºÙ¤«¤¤Éôʬ¤Ç¥ß¥¹¤ê¡¢ÂçÊѤʤΤÏÊѤï¤é¤Ê¤¤¤Î¤À¤¬
¡£ ¤µ¤é¤Ë¥¢¥Ã¥×¤·Ëº¤ì¤ë¤È¸À¤¦´ÖÈ´¤±¤µ¤âȯ´ø¤·¤Æ¤·¤Þ¤Ã¤¿¤Î¤Çº£¸å¤¬»×¤¤¤ä¤é¤ì¤ë......