I didn't want to start another topic for this, so I'm
abusing this thread

.
The following code will compile without a hitch, but
appletviewer will start and display "Applet not initialized".
I don't have another computer at my disposal right
now, so could someone please compile and run this for
me?
First the applet:
code:<HR>
Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Container;
public class abstand extends JApplet
implements ActionListener {
JLabel a1, b1, a2, b2;
JTextField x1, y1, x2, y2, ausgabe;
JButton rechnen;
public void init()
{
Container c = getContentPane();
c.setLayout( new FlowLayout() );
a1 = new JLabel( "x1:" );
c.add( a1 );
x1 = new JTextField( 10 );
c.add( x1 );
b1 = new JLabel( "y1:" );
c.add( b1 );
y1 = new JTextField( 10 );
c.add( y1 );
a2 = new JLabel( "x2:" );
c.add( a2 );
x2 = new JTextField( 10 );
c.add( x2 );
a2 = new JLabel( "y2:" );
c.add( b2 );
y2 = new JTextField( 10 );
c.add( y2 );
rechnen = new JButton( "Berechnen" );
rechnen.addActionListener( this );
c.add( rechnen );
ausgabe = new JTextField( 25 );
ausgabe.setEditable( false );
c.add( ausgabe );
}
public void actionPerformed( ActionEvent e )
{
double dx1, dx2, dy1, dy2, abstand;
dx1 = Double.parseDouble( x1.getText() );
dy1 = Double.parseDouble( y1.getText() );
dx2 = Double.parseDouble( x2.getText() );
dy2 = Double.parseDouble( y2.getText() );
showStatus( "Berechnung läuft" );
abstand = Math.sqrt ( (dx2 - dx1) * (dx2 - dx1) + (dy2 - dy1) * (dy2 - dy1) );
showStatus( "Fertig" );
ausgabe.setText( Double.toString( abstand ) );
}
}
I know there's german in there, but surely that's not the
problem...
My Java instructor wants us to use german expressions,
and,as I intend to finish this semester, I'll humour him.
Just to clear it up:
abstand == distance
rechnen == calculate
ausgabe == output
"Berechnung läuft" == "Calculating"
"Fertig" == "Ready"
The HTML-Code is as follows:
code:<HR>
Code:
<html>
<applet code="abstand.class" width=500 height=500>
</applet>
</html>
I would appreciate it very much, if one of you
could somehow either run this, so I can kick my
computer, or tell me where I went wrong, so I can
kick myself.
Thx,
FXT