import java.awt.*; import java.awt.event.*; public class GUIaa extends Frame { Button b0 = new Button("judge!"); 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, 100, 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(""); int hanteihensuu=0; for (int count=2; count < i;++count){ if(i%count == 0) hanteihensuu = 1; } if(hanteihensuu == 0) { x0.setText(i + " is Prime"); } else { x0.setText(i + " is not Prime"); } } }); } public static void main(String[] args) { Frame win = new GUIaa(); win.setSize(200, 150); win.setVisible(true); win.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); } }[�l�@]
[��ȋ@�\]
button
�w�肵���͈͓��Ń}�E�X���N���b�N����ƁA"�{�^����������"�܂��B
TextField
��������͂���t�B�[���h������A�͈͂Ȃǂ��w��ł��܂��B
(String "���͂��ꂽ����",int "�T�C�Y��")
ActionEvent
����̃A�N�V����������Ɛ��������B