lundi 20 avril 2015
geänderten Textfeldinhalt mit parse auslesen
Posted on 09:56 by verona
Hallo, habe ein kleines Problem.
Ich habe ein Programm programmiert das komplexe Zahlen verarbeitet. Habe nun im GUI einen Rechner gebaut und funktioniert soweit, nur wenn ich das Textfeld ändere ( andere Zahl hineinschreibe), verarbeitet er noch immer die ursprünglichen Zahlen, wird wohl irgendwie am passe liegen, da ich es im Konstruktion vielleicht schon aufrufe. Bitte um Hilfe :D, LG
Ich habe ein Programm programmiert das komplexe Zahlen verarbeitet. Habe nun im GUI einen Rechner gebaut und funktioniert soweit, nur wenn ich das Textfeld ändere ( andere Zahl hineinschreibe), verarbeitet er noch immer die ursprünglichen Zahlen, wird wohl irgendwie am passe liegen, da ich es im Konstruktion vielleicht schon aufrufe. Bitte um Hilfe :D, LG
Java Code:
-
-
-
-
ImaginaryNumber n1;
-
ImaginaryNumber n2;
-
-
-
-
/**
-
* Creates new form Rechner
-
*/
-
public Rechner() {
-
initComponents();
-
-
-
n1 = new ImaginaryNumber(re1,im1);
-
n2 = new ImaginaryNumber(re2,im2);
-
-
-
-
}
-
-
-
/**
-
* This method is called from within the constructor to initialize the form.
-
* WARNING: Do NOT modify this code. The content of this method is always
-
* regenerated by the Form Editor.
-
*/
-
@SuppressWarnings("unchecked")
-
// <editor-fold defaultstate="collapsed" desc="Generated Code">
-
private void initComponents() {
-
-
-
-
-
-
-
im1text.setText("2");
-
im1textActionPerformed(evt);
-
}
-
});
-
gridBagConstraints.gridx = 2;
-
gridBagConstraints.gridy = 1;
-
getContentPane().add(im1text, gridBagConstraints);
-
-
-
jLabel1.setText("+");
-
gridBagConstraints.gridx = 1;
-
gridBagConstraints.gridy = 1;
-
getContentPane().add(jLabel1, gridBagConstraints);
-
-
-
re2text.setText("1");
-
re2textActionPerformed(evt);
-
}
-
});
-
gridBagConstraints.gridx = 0;
-
gridBagConstraints.gridy = 3;
-
getContentPane().add(re2text, gridBagConstraints);
-
-
-
jLabel2.setText("+");
-
gridBagConstraints.gridx = 1;
-
gridBagConstraints.gridy = 3;
-
getContentPane().add(jLabel2, gridBagConstraints);
-
-
-
absbtn.setText("abs");
-
absbtnActionPerformed(evt);
-
}
-
});
-
gridBagConstraints.gridx = 4;
-
gridBagConstraints.gridy = 0;
-
getContentPane().add(absbtn, gridBagConstraints);
-
-
-
plusbtn.setText("+");
-
plusbtnActionPerformed(evt);
-
}
-
});
-
gridBagConstraints.gridx = 4;
-
gridBagConstraints.gridy = 1;
-
getContentPane().add(plusbtn, gridBagConstraints);
-
-
-
mulbtn.setText("*");
-
mulbtnActionPerformed(evt);
-
}
-
});
-
gridBagConstraints.gridx = 4;
-
gridBagConstraints.gridy = 2;
-
getContentPane().add(mulbtn, gridBagConstraints);
-
-
-
divbtn.setText("/");
-
divbtnActionPerformed(evt);
-
}
-
});
-
gridBagConstraints.gridx = 4;
-
gridBagConstraints.gridy = 3;
-
getContentPane().add(divbtn, gridBagConstraints);
-
-
-
jLabel3.setText("Ergebnis:");
-
gridBagConstraints.gridx = 5;
-
gridBagConstraints.gridy = 0;
-
getContentPane().add(jLabel3, gridBagConstraints);
-
-
-
jLabel5.setText("Imaginärzahl1");
-
gridBagConstraints.gridx = 1;
-
gridBagConstraints.gridy = 0;
-
getContentPane().add(jLabel5, gridBagConstraints);
-
-
-
jLabel6.setText("i");
-
gridBagConstraints.gridx = 3;
-
gridBagConstraints.gridy = 1;
-
getContentPane().add(jLabel6, gridBagConstraints);
-
-
-
jLabel7.setText("i");
-
gridBagConstraints.gridx = 3;
-
gridBagConstraints.gridy = 3;
-
getContentPane().add(jLabel7, gridBagConstraints);
-
-
-
jLabel8.setText("Imaginärzahl2");
-
gridBagConstraints.gridx = 1;
-
gridBagConstraints.gridy = 2;
-
getContentPane().add(jLabel8, gridBagConstraints);
-
-
-
re1text.setText("2");
-
re1textActionPerformed(evt);
-
}
-
});
-
gridBagConstraints.gridx = 0;
-
gridBagConstraints.gridy = 1;
-
getContentPane().add(re1text, gridBagConstraints);
-
-
-
im2text.setText("1");
-
im2textActionPerformed(evt);
-
}
-
});
-
gridBagConstraints.gridx = 2;
-
gridBagConstraints.gridy = 3;
-
getContentPane().add(im2text, gridBagConstraints);
-
gridBagConstraints.gridx = 5;
-
gridBagConstraints.gridy = 1;
-
getContentPane().add(erg, gridBagConstraints);
-
-
-
pack();
-
}// </editor-fold>
-
-
-
erg.setText("");
-
n1.abs();
-
}
-
-
-
-
}
-
-
-
-
}
-
-
-
-
}
-
-
-
-
}
-
-
-
erg.setText("");
-
n1.add(n2);
-
erg.setText(n1.add(n2).toString());
-
}
-
-
-
erg.setText("");
-
n1.multipleBy(n2);
-
erg.setText(n1.multipleBy(n2).toString());
-
}
-
-
-
erg.setText("");
-
n1.divideBy(n2);
-
erg.setText(n1.divideBy(n2).toString());
-
}
-
-
-
-
-
-
/**
-
* @param args the command line arguments
-
*/
-
/* Set the Nimbus look and feel */
-
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
-
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
-
* For details see <a href="http://ift.tt/1DavAg2; target="_blank">How to Set the Look and Feel (The Java⢠Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)</a>
-
*/
-
try {
-
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
-
if ("Nimbus".equals(info.getName())) {
-
break;
-
}
-
}
-
java.util.logging.Logger.getLogger(Rechner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
-
java.util.logging.Logger.getLogger(Rechner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
-
java.util.logging.Logger.getLogger(Rechner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
-
java.util.logging.Logger.getLogger(Rechner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
-
}
-
//</editor-fold>
-
-
-
/* Create and display the form */
-
public void run() {
-
new Rechner().setVisible(true);
-
}
-
});
-
}
-
-
-
// Variables declaration - do not modify
-
// End of variables declaration
-
}
geänderten Textfeldinhalt mit parse auslesen
Categories: geänderten Textfeldinhalt mit parse auslesen
Inscription à :
Publier les commentaires (Atom)
0 commentaires:
Enregistrer un commentaire