0% found this document useful (0 votes)
35 views

String Fstring

The document defines event handler methods for different Java GUI components that perform basic arithmetic operations on numeric values selected from drop-down menus. The values are stored as strings and floats, with buttons to add, subtract, multiply and divide the values and display the result in a third text field. A clear button resets all text fields.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

String Fstring

The document defines event handler methods for different Java GUI components that perform basic arithmetic operations on numeric values selected from drop-down menus. The values are stored as strings and floats, with buttons to add, subtract, multiply and divide the values and display the result in a third text field. A clear button resets all text fields.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

String fString="0",sString="0",tString="0";

float fFloat=0,sFloat=0,tFloat=0;
private void cb1ActionPerformed(java.awt.event.ActionEvent evt) {
{
JComboBox cb1=(JComboBox)evt.getSource();
String newSelection1=(String)cb1.getSelectedItem();
if(newSelection1.contentEquals("0"))
{
fString="0";
}
else
{
fString=newSelection1;
}
text1.setText(fString);
}
}

private void cb2ActionPerformed(java.awt.event.ActionEvent evt) {


{
JComboBox cb2=(JComboBox)evt.getSource();
String newSelection1=(String)cb2.getSelectedItem();
if(newSelection1.contentEquals("0"))
{
sString="0";
}
else
{
sString=newSelection1;
}
text2.setText(sString);
}
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


text1.setText(fString);
fFloat=(Float.parseFloat(String.valueOf(fString)));
text2.setText(sString);
sFloat=(Float.parseFloat(String.valueOf(sString)));
tFloat=fFloat+sFloat;
tString=(String.valueOf(tFloat));
text3.setText(tString);

}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
text1.setText(fString);
fFloat=(Float.parseFloat(String.valueOf(fString)));
text2.setText(sString);
sFloat=(Float.parseFloat(String.valueOf(sString)));
tFloat=fFloat-sFloat;
tString=(String.valueOf(tFloat));
text3.setText(tString);
}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {


text1.setText(fString);
fFloat=(Float.parseFloat(String.valueOf(fString)));
text2.setText(sString);
sFloat=(Float.parseFloat(String.valueOf(sString)));
tFloat=fFloat*sFloat;
tString=(String.valueOf(tFloat));
text3.setText(tString);
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {


text1.setText(fString);
fFloat=(Float.parseFloat(String.valueOf(fString)));
text2.setText(sString);
sFloat=(Float.parseFloat(String.valueOf(sString)));
tFloat=fFloat/sFloat;
tString=(String.valueOf(tFloat));
text3.setText(tString);
}

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {


this.text1.setText("");
this.text2.setText("");
this.text3.setText("");
}

You might also like