Please help me out with this... Sorry, Don't know how to post in coding option.
this might be hard to understand.
|
I just copy it and posted it....
thanks in advance.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewJFrameko2.java
 *
 * Created on May 13, 2010, 3:00:08 PM
 */

package cab;

import java.text.DecimalFormat;
import javax.swing.JOptionPane;

/**
 *
 * @author IT2PC1
 */
public class NewJFrameko2 extends javax.swing.JFrame {
    DecimalFormat jas= new DecimalFormat("0.00");

    /** Creates new form NewJFrameko2 */
    public NewJFrameko2() {
        initComponents();
    }

    /** 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">//GEN-BEGIN:initComponents
    private void initComponents() {


    int plusclick=1, plusminus=1, divideclick=1, mulclick=1, minusclick=1, decimalclick=1;

     double addnum1, addnum2, totalvalue;

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jTextField1ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        jTextField1.setText(jTextField1.getText()+ jButton1.getText());

        // TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        jTextField1.setText(jTextField1.getText()+ jButton2.getText());
        // TODO add your handling code here:
}//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        jTextField1.setText(jTextField1.getText()+ jButton3.getText());
        // TODO add your handling code here:
}//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        jTextField1.setText(jTextField1.getText()+ jButton4.getText());
        // TODO add your handling code here:
}//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        if (decimalclick==0)
        {

            jTextField1.setText(jTextField1.getText()+jButton15.getText());
        plusclick=1;
        }



        // TODO add your handling code here:
}//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed

        jTextField1.setText(jTextField1.getText()+ jButton6.getText());
}//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        jTextField1.setText(jTextField1.getText()+ jButton7.getText());
        // TODO add your handling code here:
}//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        jTextField1.setText(jTextField1.getText()+ jButton8.getText());
}//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        jTextField1.setText(jTextField1.getText()+ jButton9.getText());
        // TODO add your handling code here:
}//GEN-LAST:event_jButton9ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed

        addnum1=Double.parseDouble(String.valueOf(jTextField1.getText()));
        jTextField1.setText(" ");
        plusclick=1;
        decimalclick=0;

        // TODO add your handling code here:
}//GEN-LAST:event_jButton10ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        jTextField1.setText(jTextField1.getText()+ jButton11.getText());
        // TODO add your handling code here:
}//GEN-LAST:event_jButton11ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        jTextField1.setText(jTextField1.getText()+ jButton12.getText());
        // TODO add your handling code here:
}//GEN-LAST:event_jButton12ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed

        addnum1=Double.parseDouble(String.valueOf(jTextField1.getText()));
        jTextField1.setText("");
            minusclick=1;
            decimalclick=0;

        // TODO add your handling code here:
}//GEN-LAST:event_jButton13ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
      addnum1=Double.parseDouble(String.valueOf(jTextField1.getText()));
        jTextField1.setText("");
        mulclick=1;
        decimalclick=0;

        // TODO add your handling code here:
}//GEN-LAST:event_jButton14ActionPerformed

    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed



        addnum2=Double.parseDouble(String.valueOf(jTextField1.getText()));
        if(plusclick>0)

        {
            totalvalue= addnum1 + addnum2;
            jTextField1.setText(String.valueOf(jas.format(totalvalue)));
            addnum1=0;
            addnum2=0;
            plusclick=0;
        }
        if(minusclick>0)


        {
            totalvalue= addnum1 - addnum2;
            jTextField1.setText(String.valueOf(jas.format(totalvalue)));
            addnum1=0;
            addnum2=0;
            minusclick=0;

        }
        if(mulclick>0)


        {
            totalvalue= addnum1 * addnum2;
            jTextField1.setText(String.valueOf(jas.format(totalvalue)));
            addnum1=0;
            addnum2=0;
            mulclick=0;
        }
        if(divideclick>0) {
            totalvalue= addnum1 / addnum2;
            jTextField1.setText(String.valueOf(jas.format(totalvalue)));
            addnum1=0;
            addnum2=0;
            divideclick=0;
        }
        // TODO add your handling code here:
}//GEN-LAST:event_jButton15ActionPerformed

    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed
        jTextField1.setText(jTextField1.getText()+ jButton16.getText());
        // TODO add your handling code here:
}//GEN-LAST:event_jButton16ActionPerformed

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        jTextField1.setText(jTextField1.getText()+ jButton17.getText());
        jTextField1.setText(" ");
        // TODO add your handling code here:
}//GEN-LAST:event_jButton17ActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed

        addnum1=Double.parseDouble(String.valueOf(jTextField1.getText()));
        jTextField1.setText("");
        divideclick=1;

        // TODO add your handling code here:
}//GEN-LAST:event_jButton19ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed

        this.dispose();
        new about().setVisible(true);

        // TODO add your handling code here:
}//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
JOptionPane.showMessageDialog(null," Calculator is easy to use \n Just enter the number\n click the operation neeeded\n and the equal sign to get\n the final answer");        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrameko2().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration

}

Edited 3 Years Ago by Dani: Formatting fixed

How can i Write the value of Math book which is 225 to a certain texfield.
It must appear on the textfield where in if i click the Math text in the Combobox button
the value of it wich is 225 must appear to jtextfield1.
upto 5 books and 5 different values each.
We are using Netbeans 6.8 IDE.

thanks.

package ngaun;

/**
 *
 * @author IT2PC1
 */
public class combobox extends javax.swing.JFrame {

    /** Creates new form combobox */
    public combobox() {
        initComponents();
    }


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {


    double quantity, total;

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed



        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        if(jComboBox1.getSelectedItem()=="Math")
        {

            jComboBox1.setText(String.valueOf(total);
        }
    }//GEN-LAST:event_jComboBox1ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new combobox().setVisible(true);
            }
        });
    }


    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables

}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Please take a moment to clean up your code; the code posted is totaly wrong and did not compile!

This article has been dead for over six months. Start a new discussion instead.