The code isn´t complete yet, but it should run:
Code: Select all
import java.awt.*;
import java.awt.event.*;
abstract class Rate_GUIapp extends Frame
implements WindowListener, ActionListener {
public static void main(String args[]) {}
public boolean handleEvent (Event e) {
if (e.target == buttonVersuch && e.id == Event.ACTION_EVENT) {
versuchClicked();
}
if (e.target == buttonNeu && e.id == Event.ACTION_EVENT) {
neuClicked();
}
if (e.target == buttonInfo && e.id == Event.ACTION_EVENT) {
infoClicked();
}return false;
}
public void windowClosing (WindowEvent e) {
dispose();
System.exit(0);
}
public void windowClosed (WindowEvent e) {}
public void windowOpened (WindowEvent e) {}
public void windowActivated (WindowEvent e) {}
public void windowDeactivated (WindowEvent e) {}
public void windowIconified (WindowEvent e) {}
public void windowDeiconified (WindowEvent e) {}
public void actionPerformed (ActionEvent e) {
if (e.getSource()==buttonNeu) {
neuClicked();
}
if (e.getSource()==buttonInfo) {
infoClicked();
}
if (e.getSource()==buttonVersuch) {
versuchClicked();
}
}
private void neuClicked() {
textareaInfo.append("\"Neues Spiel\" geklickt\n");
}
private void versuchClicked() {
textareaInfo.append("\"Versuch\" geklickt\n");
}
private void infoClicked() {
textareaInfo.append("\"Info\" geklickt\n");
}
Label labelSuche1, labelSuche2, labelSuche3;
Label labelText1, labelText2;
TextField textfieldVersuch1, textfieldVersuch2, textfieldVersuch3;
Button buttonInfo, buttonNeu, buttonVersuch;
Font fntFett, fntHead, fntAusgabe;
TextArea textareaInfo;
public Rate_GUIapp() {
setLayout(null);
labelText1 = new Label ("Raten Sie die 3 Ziffern");
labelText2 = new Label ("Lösungen");
labelSuche1 = new Label ("X");
labelSuche2 = new Label ("X");
labelSuche3 = new Label ("X");
textfieldVersuch1 = new TextField("");
textfieldVersuch2 = new TextField("");
textfieldVersuch3 = new TextField("");
fntFett = new Font("SansSerif",1,14);
fntHead = new Font("SansSerif",1,20);
fntAusgabe = new Font("monospaced",0,12);
buttonInfo = new Button("Info");
buttonNeu = new Button("Neues Spiel");
buttonVersuch = new Button("Versuchen");
textareaInfo = new TextArea();
labelText1.setBounds(20,25,350,25);
labelText2.setBounds(20,70,120,25);
labelSuche1.setBounds(175,70,25,25);
labelSuche2.setBounds(255,70,25,25);
labelSuche3.setBounds(335,70,25,25);
textfieldVersuch1.setBounds(170,110,25,25);
textfieldVersuch2.setBounds(250,110,25,25);
textfieldVersuch3.setBounds(330,110,25,25);
buttonInfo.setBounds(20,160,80,25);
buttonNeu.setBounds(140,160,100,25);
buttonVersuch.setBounds(280,160,100,25);
textareaInfo.setBounds(20,210,360,140);
labelText1.setFont(fntHead);
labelText2.setFont(fntFett);
labelSuche1.setFont(fntHead);
labelSuche2.setFont(fntHead);
labelSuche3.setFont(fntHead);
textfieldVersuch1.setFont(fntFett);
textfieldVersuch2.setFont(fntFett);
textfieldVersuch3.setFont(fntFett);
buttonInfo.setFont(fntFett);
buttonNeu.setFont(fntFett);
buttonVersuch.setFont(fntFett);
textareaInfo.setFont(fntAusgabe);
add(labelText1); add(labelText2);
add(labelSuche1); add(labelSuche2); add(labelSuche3);
add(textfieldVersuch1); add(textfieldVersuch2); add(textfieldVersuch3);
add(buttonInfo); add(buttonNeu); add(buttonVersuch);
add(textareaInfo);
buttonInfo.addActionListener(this);
buttonNeu.addActionListener(this);
buttonVersuch.addActionListener(this);
addWindowListener(this);
setVisible (true);
}
}