Gabber19
Semiprofi
Thread Starter
- Mitglied seit
- 10.02.2003
- Beiträge
- 1.057
Hidiho!
Ich probe für die Schule eine kleines Dings.. das soll aus eigegebenen Werten neue berechnen (geht um aktive Alpässe).
nun bringt der aber immer Errors wenn ich dat Teil ausführe ..
also genauer gesagt wenn ich auf nen Button drücke!
hier der Quelllcode :
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class GUI1 extends Applet
implements ActionListener
{
public Label nLabel(int x, int y, int h, int w,String text)
{
Label temp_Label = new Label(text,Label.LEFT);
temp_Label.setBackground(Color.cyan);
temp_Label.setForeground(Color.black);
add(temp_Label);
temp_Label.setBounds(x,y,h,w);
return temp_Label;
}
public TextField nTF(int x, int y, int h, int w)
{
TextField temp_TF = new TextField(10);
temp_TF.setBackground(Color.yellow);
temp_TF.setForeground(Color.blue);
add(temp_TF);
temp_TF.setBounds(x,y,h,w);
return temp_TF;
}
public Button nButton(int x, int y, int h, int w,String text)
{
Button button_t = new Button(text);
button_t.setBackground(Color.black);
button_t.setForeground(Color.white);
add(button_t);
button_t.setBounds(x,y,h,w);
button_t.addActionListener(this);
return button_t;
}
public void Calc_HQ(int f, int q, int c)
{
Label HQ_Title = nLabel(600,0,60,height,"!High Q");
Label L_HQ_R1 = nLabel(300,100,100,height,"F="+Integer.toString(f));
Label L_HQ_R2 = nLabel(300,150,100,height,"Q="+Integer.toString(q));
Label L_HQ_R4 = nLabel(300,200,100,height,"C="+Integer.toString(c));
}
final int height = 25;
Button HQ,MQ,LQ;
TextField C1,Qp,Fp;
public void init()
{
setBackground(Color.cyan);
setForeground(Color.white);
setLayout(null);
}
public void paint(Graphics g)
{
Label A = nLabel(0,100,100,height,"Res. Frequenz:");
TextField Fp= nTF(110,100,60,height);
Label B = nLabel(0,150,70,height,"Güte");
TextField Qp= nTF(110,150,60,height);
Label C = nLabel(0,200,100,height,"Kapazität:");
TextField C1= nTF(110,200,60,height);
Button HQ = nButton(400,300,30,30,"HQ");
Button MQ = nButton(300,300,30,30,"MQ");
Button LQ = nButton(200,300,30,30,"LQ");
Calc_HQ(Integer.valueOf(C1.getText()).intValue(),Integer.valueOf(Qp.getText()).intValue(),Integer.valueOf(Fp.getText()).intValue());
repaint();
}
public void actionPerformed(ActionEvent e)
{
repaint();
}
}
hoffe es kennt sich einer damit aus
THX im Voraus / für das lesen
Ich probe für die Schule eine kleines Dings.. das soll aus eigegebenen Werten neue berechnen (geht um aktive Alpässe).
nun bringt der aber immer Errors wenn ich dat Teil ausführe ..
also genauer gesagt wenn ich auf nen Button drücke!
hier der Quelllcode :
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class GUI1 extends Applet
implements ActionListener
{
public Label nLabel(int x, int y, int h, int w,String text)
{
Label temp_Label = new Label(text,Label.LEFT);
temp_Label.setBackground(Color.cyan);
temp_Label.setForeground(Color.black);
add(temp_Label);
temp_Label.setBounds(x,y,h,w);
return temp_Label;
}
public TextField nTF(int x, int y, int h, int w)
{
TextField temp_TF = new TextField(10);
temp_TF.setBackground(Color.yellow);
temp_TF.setForeground(Color.blue);
add(temp_TF);
temp_TF.setBounds(x,y,h,w);
return temp_TF;
}
public Button nButton(int x, int y, int h, int w,String text)
{
Button button_t = new Button(text);
button_t.setBackground(Color.black);
button_t.setForeground(Color.white);
add(button_t);
button_t.setBounds(x,y,h,w);
button_t.addActionListener(this);
return button_t;
}
public void Calc_HQ(int f, int q, int c)
{
Label HQ_Title = nLabel(600,0,60,height,"!High Q");
Label L_HQ_R1 = nLabel(300,100,100,height,"F="+Integer.toString(f));
Label L_HQ_R2 = nLabel(300,150,100,height,"Q="+Integer.toString(q));
Label L_HQ_R4 = nLabel(300,200,100,height,"C="+Integer.toString(c));
}
final int height = 25;
Button HQ,MQ,LQ;
TextField C1,Qp,Fp;
public void init()
{
setBackground(Color.cyan);
setForeground(Color.white);
setLayout(null);
}
public void paint(Graphics g)
{
Label A = nLabel(0,100,100,height,"Res. Frequenz:");
TextField Fp= nTF(110,100,60,height);
Label B = nLabel(0,150,70,height,"Güte");
TextField Qp= nTF(110,150,60,height);
Label C = nLabel(0,200,100,height,"Kapazität:");
TextField C1= nTF(110,200,60,height);
Button HQ = nButton(400,300,30,30,"HQ");
Button MQ = nButton(300,300,30,30,"MQ");
Button LQ = nButton(200,300,30,30,"LQ");
Calc_HQ(Integer.valueOf(C1.getText()).intValue(),Integer.valueOf(Qp.getText()).intValue(),Integer.valueOf(Fp.getText()).intValue());
repaint();
}
public void actionPerformed(ActionEvent e)
{
repaint();
}
}
hoffe es kennt sich einer damit aus
THX im Voraus / für das lesen