All pastes #526226 Raw Edit

Miscellany

public text v1 · immutable
#526226 ·published 2007-05-31 18:37 UTC
rendered paste body
import java.awt.*;
import java.applet.Applet;
import javax.swing.*;
import java.awt.event.*;
 
 
 
public class MeinApplet extends Applet 
{
 
JButton berechnen=new JButton("Berechnen");
JTextField eingabe1=new JTextField("Volt");
JTextField eingabe2=new JTextField("Amphere");
JTextField ausgabe=new JTextField("Ohm");
JLabel eingabe1text=new JLabel("Volt");
JLabel eingabe1text2=new JLabel("Amphere");
JLabel eingabe1text3=new JLabel("Ohm");
 
public void init()
{
setLayout(null);
setBackground(Color.green); 
 
}
 
public void start()
{
eingabe1.setBounds(0,0,100,20);
eingabe2.setBounds(0,20,100,20);
ausgabe.setBounds(0,40,100,20);
eingabe1text.setBounds(105,0,100,20);
eingabe1text2.setBounds(105,20,100,20);
eingabe1text3.setBounds(105,40,100,20);
berechnen.setBounds(0,70,100,20);
 
berechnen.addActionListener(new ActionListener(){public void actionPerformed (ActionEvent e){berechnen();}});
 

add(eingabe1);
add(eingabe2);
add(ausgabe);
add(eingabe1text);
add(eingabe1text2);
add(eingabe1text3);
add(berechnen);
 
}
 
 
 
 
 

public void berechnen()
{
float volt=Float.parseFloat(eingabe1.getText());
float amphere=Float.parseFloat(eingabe2.getText());
float Ergebnis=volt/amphere;
ausgabe.setText(Float.toString(Ergebnis));
 
}
 
 
 
 
 
 
 
 
 
 
 

}