deltaphi-soft - java demo
Das Applet, der Quellcode:
//Titel: Hello World //Version: 1.0.0 //Copyright: GPL 12/2000 //Autor: Daphne Bastek //Organisation: DeltaPhi-Soft import java.awt.*; import java.applet.Applet; public class Applet5 extends Applet { String displayText = "und wie grüßt Du?"; String fontFace = "TimesRoman"; Choice OrtChoise; Label LabelAve; Label Labelvon; public void init() { setBackground(Color.green); Labelvon = new Label("Ich bin von "); add(Labelvon); OrtChoise = new Choice(); OrtChoise.addItem("Ostfriesland"); OrtChoise.addItem("Hamburg"); OrtChoise.addItem("München"); OrtChoise.addItem("Köln"); OrtChoise.addItem("Berlin"); OrtChoise.addItem("Wien"); add(OrtChoise); LabelAve = new Label("Moin, Moin "); add(LabelAve); } public void paint(Graphics g) { g.setFont(new Font(fontFace,Font.PLAIN,24)); g.drawString(displayText,135,60); } public boolean action(Event e, Object arg) { if (e.target instanceof Choice) { int i=0; String gruss="--"; String[] gruesse={"Moin, Moin", "Hummel, Hummel", "Grüß' Gott", "Alaf", "Merhaba", "Servus"}; Color[] myColor={Color.green, Color.red, Color.cyan, Color.pink, Color.lightGray, Color.pink}; i=OrtChoise.getSelectedIndex(); gruss=gruesse[i]; //Gruß auswählen setBackground(myColor[i]); //und entsprechende Farbe LabelAve.setText(gruss); LabelAve.setBackground(myColor[i]); //sicherheitshalber Labelvon.setBackground(myColor[i]); repaint(); return true; } return false; } }
home
referenzen
kontakt
freeware