ja ok, aber nich wundern das ding is wirklich schlampig programmiert. also in eclipse läuft alles wunderbar wenn ich auch run -> java bean gehe.
hier nochmal der gesamte code:
import java.awt.Frame;
import java.awt.Dimension;
import javax.swing.JTextField;
import java.awt.Rectangle;
import javax.swing.JButton;
import java.awt.Point;
public class TR extends Frame {
private static final long serialVersionUID = 1L;
private JTextField TF = null;
private JButton b1 = null;
private JButton b2 = null;
private JButton b3 = null;
private JButton b4 = null;
private JButton b5 = null;
private JButton b6 = null;
private JButton b7 = null;
private JButton b8 = null;
private JButton b9 = null;
private JButton b0 = null;
private JButton bpl = null;
private JButton bmi = null;
private JButton bma = null;
private JButton bdu = null;
private JButton bgl = null;
double zahl1;
double zahl2;
double rechne;
byte zeichen;
/**
* This is the default constructor
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
public TR() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setLayout(null);
this.setSize(215, 211);
this.setTitle("Taschenrechner");
this.add(getTF(), null);
this.add(getB1(), null);
this.add(getB2(), null);
this.add(getB3(), null);
this.add(getB4(), null);
this.add(getB5(), null);
this.add(getB6(), null);
this.add(getB7(), null);
this.add(getB8(), null);
this.add(getB9(), null);
this.add(getB0(), null);
this.add(getBpl(), null);
this.add(getBmi(), null);
this.add(getBma(), null);
this.add(getBdu(), null);
this.add(getBgl(), null);
this.add(getBgls(), null);
this.add(getBglm(), null);
this.add(getBgld(), null);
this.add(getBce(), null);
this.add(getBk(), null);
}
/**
* This method initializes TF
*
* @return javax.swing.JTextField
*/
private JTextField getTF() {
if (TF == null) {
TF = new JTextField();
TF.setBounds(new Rectangle(14, 34, 195, 21));
}
return TF;
}
/**
* This method initializes b1
*
* @return javax.swing.JButton
*/
String zahl;
private JButton bgls = null;
private JButton bglm = null;
private JButton bgld = null;
private JButton bce = null;
private JButton bk = null;
private JButton getB1() {
if (b1 == null) {
b1 = new JButton();
b1.setLocation(new Point(16, 59));
b1.setText("1");
b1.setSize(new Dimension(45, 25));
b1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + "1");
}
});
}
return b1;
}
/**
* This method initializes b2
*
* @return javax.swing.JButton
*/
private JButton getB2() {
if (b2 == null) {
b2 = new JButton();
b2.setLocation(new Point(65, 59));
b2.setText("2");
b2.setSize(new Dimension(45, 25));
b2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + "2");
}
});
}
return b2;
}
/**
* This method initializes b3
*
* @return javax.swing.JButton
*/
private JButton getB3() {
if (b3 == null) {
b3 = new JButton();
b3.setLocation(new Point(114, 59));
b3.setText("3");
b3.setSize(new Dimension(45, 25));
b3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + "3");
}
});
}
return b3;
}
/**
* This method initializes b4
*
* @return javax.swing.JButton
*/
private JButton getB4() {
if (b4 == null) {
b4 = new JButton();
b4.setLocation(new Point(16, 88));
b4.setText("4");
b4.setSize(new Dimension(45, 25));
b4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + "4");}
});
}
return b4;
}
/**
* This method initializes b5
*
* @return javax.swing.JButton
*/
private JButton getB5() {
if (b5 == null) {
b5 = new JButton();
b5.setLocation(new Point(65, 88));
b5.setText("5");
b5.setSize(new Dimension(45, 25));
b5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + "5");}
});
}
return b5;
}
/**
* This method initializes b6
*
* @return javax.swing.JButton
*/
private JButton getB6() {
if (b6 == null) {
b6 = new JButton();
b6.setLocation(new Point(114, 88));
b6.setText("6");
b6.setSize(new Dimension(45, 25));
b6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + "6");}
});
}
return b6;
}
/**
* This method initializes b7
*
* @return javax.swing.JButton
*/
private JButton getB7() {
if (b7 == null) {
b7 = new JButton();
b7.setLocation(new Point(16, 118));
b7.setText("7");
b7.setSize(new Dimension(45, 25));
b7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + "7");}
});
}
return b7;
}
/**
* This method initializes b8
*
* @return javax.swing.JButton
*/
private JButton getB8() {
if (b8 == null) {
b8 = new JButton();
b8.setLocation(new Point(65, 118));
b8.setText("8");
b8.setSize(new Dimension(45, 25));
b8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + "8");}
});
}
return b8;
}
/**
* This method initializes b9
*
* @return javax.swing.JButton
*/
private JButton getB9() {
if (b9 == null) {
b9 = new JButton();
b9.setLocation(new Point(114, 118));
b9.setText("9");
b9.setSize(new Dimension(45, 25));
b9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + "9");}
});
}
return b9;
}
/**
* This method initializes b0
*
* @return javax.swing.JButton
*/
private JButton getB0() {
if (b0 == null) {
b0 = new JButton();
b0.setLocation(new Point(65, 148));
b0.setText("0");
b0.setSize(new Dimension(45, 25));
b0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + "0");}
});
}
return b0;
}
/**
* This method initializes bpl
*
* @return javax.swing.JButton
*/
private JButton getBpl() {
if (bpl == null) {
bpl = new JButton();
bpl.setSize(new Dimension(45, 25));
bpl.setText("+");
bpl.setLocation(new Point(163, 59));
bpl.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
zahl1 = Double.parseDouble(TF.getText());
bgl.setVisible(true);
bgls.setVisible(false);
bglm.setVisible(false);
bgld.setVisible(false);
TF.setText("");
TF.requestFocus();
}
});
}
return bpl;
}
/**
* This method initializes bmi
*
* @return javax.swing.JButton
*/
private JButton getBmi() {
if (bmi == null) {
bmi = new JButton();
bmi.setSize(new Dimension(45, 25));
bmi.setText("-");
bmi.setLocation(new Point(163, 88));
bmi.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
zahl1 = Double.parseDouble(TF.getText());
bgl.setVisible(false);
bgls.setVisible(true);
bglm.setVisible(false);
bgld.setVisible(false);
TF.setText("");
TF.requestFocus();
}
});
}
return bmi;
}
/**
* This method initializes bma
*
* @return javax.swing.JButton
*/
private JButton getBma() {
if (bma == null) {
bma = new JButton();
bma.setSize(new Dimension(45, 25));
bma.setText("*");
bma.setLocation(new Point(163, 118));
bma.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
zahl1 = Double.parseDouble(TF.getText());
bgl.setVisible(false);
bgls.setVisible(false);
bglm.setVisible(true);
bgld.setVisible(false);
TF.setText("");
TF.requestFocus();
}
});
}
return bma;
}
/**
* This method initializes bdu
*
* @return javax.swing.JButton
*/
private JButton getBdu() {
if (bdu == null) {
bdu = new JButton();
bdu.setSize(new Dimension(45, 25));
bdu.setText("/");
bdu.setLocation(new Point(163, 148));
bdu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
zahl1 = Double.parseDouble(TF.getText());
bgl.setVisible(false);
bgls.setVisible(false);
bglm.setVisible(false);
bgld.setVisible(true);
TF.setText("");
TF.requestFocus();
}
});
}
return bdu;
}
/**
* This method initializes bgl
*
* @return javax.swing.JButton
*/
private JButton getBgl() {
if (bgl == null) {
bgl = new JButton();
bgl.setSize(new Dimension(45, 25));
bgl.setText("=");
bgl.setLocation(new Point(114, 148));
bgl.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
zahl2 = Double.parseDouble(TF.getText());
rechne = zahl1 + zahl2;
TF.setText(Double.toString(rechne));
TF.requestFocus();
}
});
}
return bgl;
}
/**
* This method initializes bgls
*
* @return javax.swing.JButton
*/
private JButton getBgls() {
if (bgls == null) {
bgls = new JButton();
bgls.setLocation(new Point(114, 148));
bgls.setText("=");
bgls.setSize(new Dimension(45, 25));
bgls.setVisible(false);
bgls.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
zahl2 = Double.parseDouble(TF.getText());
rechne = zahl1 - zahl2;
TF.setText(Double.toString(rechne));
TF.requestFocus();
}
});
}
return bgls;
}
/**
* This method initializes bglm
*
* @return javax.swing.JButton
*/
private JButton getBglm() {
if (bglm == null) {
bglm = new JButton();
bglm.setLocation(new Point(114, 148));
bglm.setText("=");
bglm.setSize(new Dimension(45, 25));
bglm.setVisible(false);
bglm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
zahl2 = Double.parseDouble(TF.getText());
rechne = zahl1 * zahl2;
TF.setText(Double.toString(rechne));
TF.requestFocus();
}
});
}
return bglm;
}
/**
* This method initializes bgld
*
* @return javax.swing.JButton
*/
private JButton getBgld() {
if (bgld == null) {
bgld = new JButton();
bgld.setLocation(new Point(114, 148));
bgld.setText("=");
bgld.setSize(new Dimension(45, 25));
bgld.setVisible(false);
bgld.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
zahl2 = Double.parseDouble(TF.getText());
rechne = zahl1 / zahl2;
TF.setText(Double.toString(rechne));
TF.requestFocus();
}
});
}
return bgld;
}
/**
* This method initializes bce
*
* @return javax.swing.JButton
*/
private JButton getBce() {
if (bce == null) {
bce = new JButton();
bce.setSize(new Dimension(192, 26));
bce.setText("CE - NEUE RECHNUNG");
bce.setLocation(new Point(16, 178));
bce.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
zahl1 = 0; // variable zahl1 auf 0 setzen
zahl2 = 0; //variable zahl2 auf 0 setzen
rechne = 0; //variable rechne auf 0 setzen
TF.setText(""); //text leer setzen
TF.requestFocus(); //Cursor in Textfeld setztn
}
});
}
return bce;
}
/**
* This method initializes bk
*
* @return javax.swing.JButton
*/
private JButton getBk() {
if (bk == null) {
bk = new JButton();
bk.setLocation(new Point(16, 148));
bk.setText(",");
bk.setSize(new Dimension(45, 25));
bk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
TF.setText(TF.getText() + ".");}
});
}
return bk;
}
}
// @jve:decl-index=0:visual-constraint="28,33"
so außerdem hab ich meine jar datei jetzt mal in der console geöffnet damit ich mal sehe was der von mir will und stelle fest, das ich mit der meldung auch nix anfangen kann:
C:\Users\Midnight Ghost\Desktop>rechner.jar
Exception in thread “main” java.lang.NoClassDefFoundError: C:\Users\Midnight Gho
st\Desktop\rechner/jar