G
Guest
Gast
So hi, mein Problem ist, dass wenn ich mich im "bin" Ordner im Verzeichnis java befinde (in der Eingabeaufforderung bei XP) und dann "appletviewer "C:\...(steht für Verzeichnis)\startApplet.html" eingebe, sich zwar ein Fenster öffnet, in der linken unteren Ecke aber "Start: Applet nicht initialisiert" steht und mein Programm somit nicht angezeigt wird. Meine Frage ist jetzt.. wie bekomm ich das zum laufen?
Der Quelltext sieht wie folgt aus (abgeändertes Programm, nur input und outputPrompt1 verändert, also den Text im Label):
Vielen Dank schonmal
PS: hab auch den compiler drüber laufen lassen, ohne Fehlermeldung
Der Quelltext sieht wie folgt aus (abgeändertes Programm, nur input und outputPrompt1 verändert, also den Text im Label):
Code:
//Temperatur.java
//
// Transforms Celsius to Fahrenheit
import java.awt.*;
import java.applet.Applet;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class CircleApplet extends Applet
{
// variables for the problem
double fahrenheit, celsius;
// objects for the graphical user interface
Label inputPrompt, outputPrompt1, outputPrompt2;
TextField input, output;
// setup the graphical user interface components
// and initialize labels and text fields
public void init() {
// define font and applet size
setFont(new Font("Times", Font.PLAIN, 24));
setSize(900, 100);
// define labels and textfields
inputPrompt = new Label("Geben sie den Radius "
+ "in cm an und druecken Sie Return.");
outputPrompt1 = new Label("Der Durchmesser in "
+ "cm betraegt");
outputPrompt2 = new Label(" Grad.");
input = new TextField(10);
input.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
calculateTemperature();
}
}); // action will be on input field
output = new TextField( 10 );
output.setEditable( false );
// disable editing in output field (13)
// add labels and textfields to the applet
add(inputPrompt);
add(input);
add(outputPrompt1);
add(output);
add(outputPrompt2);
}
// process user's action on the input text field
public void calculateTemperature() {
// get input number
celsius = Double.parseDouble(input.getText());
// calculate fahrenheit and round it to 1/100 degrees
fahrenheit = 9.0 / 5 * celsius + 32;
// use Math class for round
fahrenheit= Math.round(fahrenheit * 100);
fahrenheit= fahrenheit / 100.0;
// show result in textfield output
output.setText(Double.toString(fahrenheit));
}
}
PS: hab auch den compiler drüber laufen lassen, ohne Fehlermeldung