I have this program right now, but I need to modify it to output to the JTextPane.
What I mean is, when someone clicks on the 1 button, it needs to output to the TextArea a 1. None of the add, subtract, multiply, divide symbols need to....just the numbers and the decimal point. I have no idea how to do this. Can anyone help me? Here's the program.
/*
* Calculator.java
*
* Created on December 12, 2006, 10:00 PM
* Created by Ken Garlitz
*/
/**
*
* @author Erekose
*/
public class Calculator extends javax.swing.JFr ame {
/** Creates new form Calculator */
public Calculator() {
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.
*/
// <editor-fold defaultstate="c ollapsed" desc=" Generated Code ">
private void initComponents( ) {
jScrollPane1 = new javax.swing.JSc rollPane();
jTextPane1 = new javax.swing.JTe xtPane();
jButton1 = new javax.swing.JBu tton();
jButton2 = new javax.swing.JBu tton();
jButton3 = new javax.swing.JBu tton();
jButton4 = new javax.swing.JBu tton();
jButton5 = new javax.swing.JBu tton();
jButton6 = new javax.swing.JBu tton();
jButton7 = new javax.swing.JBu tton();
jButton8 = new javax.swing.JBu tton();
jButton9 = new javax.swing.JBu tton();
jButton10 = new javax.swing.JBu tton();
jButton11 = new javax.swing.JBu tton();
jButton12 = new javax.swing.JBu tton();
jButton13 = new javax.swing.JBu tton();
jButton14 = new javax.swing.JBu tton();
jButton15 = new javax.swing.JBu tton();
jButton16 = new javax.swing.JBu tton();
setDefaultClose Operation(javax .swing.WindowCo nstants.EXIT_ON _CLOSE);
jScrollPane1.se tViewportView(j TextPane1);
jButton1.setFon t(new java.awt.Font(" Tahoma", 1, 12));
jButton1.setTex t("7");
jButton2.setFon t(new java.awt.Font(" Tahoma", 1, 12));
jButton2.setTex t("8");
jButton3.setFon t(new java.awt.Font(" Tahoma", 1, 12));
jButton3.setTex t("9");
jButton4.setFon t(new java.awt.Font(" Tahoma", 1, 12));
jButton4.setTex t("/");
jButton5.setFon t(new java.awt.Font(" Tahoma", 1, 12));
jButton5.setTex t("4");
jButton6.setFon t(new java.awt.Font(" Tahoma", 1, 12));
jButton6.setTex t("5");
jButton7.setFon t(new java.awt.Font(" Tahoma", 1, 12));
jButton7.setTex t("6");
jButton8.setFon t(new java.awt.Font(" Tahoma", 1, 12));
jButton8.setTex t("*");
jButton9.setFon t(new java.awt.Font(" Tahoma", 1, 12));
jButton9.setTex t("1");
jButton10.setFo nt(new java.awt.Font(" Tahoma", 1, 12));
jButton10.setTe xt("2");
jButton11.setFo nt(new java.awt.Font(" Tahoma", 1, 12));
jButton11.setTe xt("3");
jButton12.setFo nt(new java.awt.Font(" Tahoma", 1, 12));
jButton12.setTe xt("-");
jButton13.setFo nt(new java.awt.Font(" Tahoma", 1, 12));
jButton13.setTe xt("0");
jButton13.addAc tionListener(ne w java.awt.event. ActionListener( ) {
public void actionPerformed (java.awt.event .ActionEvent evt) {
jButton13Action Performed(evt);
}
});
jButton13.addKe yListener(new java.awt.event. KeyAdapter() {
public void keyPressed(java .awt.event.KeyE vent evt) {
jButton13KeyPre ssed(evt);
}
});
jButton14.setFo nt(new java.awt.Font(" Tahoma", 1, 12));
jButton14.setTe xt(".");
jButton15.setFo nt(new java.awt.Font(" Tahoma", 1, 12));
jButton15.setTe xt("=");
jButton16.setFo nt(new java.awt.Font(" Tahoma", 1, 12));
jButton16.setTe xt("+");
org.jdesktop.la yout.GroupLayou t layout = new org.jdesktop.la yout.GroupLayou t(getContentPan e());
getContentPane( ).setLayout(lay out);
layout.setHoriz ontalGroup(
layout.createPa rallelGroup(org .jdesktop.layou t.GroupLayout.L EADING)
.add(layout.cre ateSequentialGr oup()
.addContainerGa p()
.add(layout.cre ateParallelGrou p(org.jdesktop. layout.GroupLay out.LEADING)
.add(jScrollPan e1, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, 366, Short.MAX_VALUE )
.add(layout.cre ateSequentialGr oup()
.add(layout.cre ateParallelGrou p(org.jdesktop. layout.GroupLay out.LEADING, false)
.add(jButton13, 0, 0, Short.MAX_VALUE )
.add(jButton5, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, Short.MAX_VALUE )
.add(jButton9, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, Short.MAX_VALUE )
.add(jButton1, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 87, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E))
.addPreferredGa p(org.jdesktop. layout.LayoutSt yle.RELATED)
.add(layout.cre ateParallelGrou p(org.jdesktop. layout.GroupLay out.LEADING)
.add(jButton10, 0, 0, Short.MAX_VALUE )
.add(jButton14, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, 86, Short.MAX_VALUE )
.add(jButton6, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, 86, Short.MAX_VALUE )
.add(jButton2, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, 86, Short.MAX_VALUE ))
.addPreferredGa p(org.jdesktop. layout.LayoutSt yle.RELATED)
.add(layout.cre ateParallelGrou p(org.jdesktop. layout.GroupLay out.LEADING)
.add(jButton7, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, 91, Short.MAX_VALUE )
.add(org.jdeskt op.layout.Group Layout.TRAILING , jButton3, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 90, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E)
.add(jButton15, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, 91, Short.MAX_VALUE )
.add(layout.cre ateSequentialGr oup()
.addPreferredGa p(org.jdesktop. layout.LayoutSt yle.RELATED)
.add(jButton11, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 91, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E)))
.addPreferredGa p(org.jdesktop. layout.LayoutSt yle.RELATED)
.add(layout.cre ateParallelGrou p(org.jdesktop. layout.GroupLay out.TRAILING)
.add(org.jdeskt op.layout.Group Layout.LEADING, layout.createSe quentialGroup()
.add(layout.cre ateParallelGrou p(org.jdesktop. layout.GroupLay out.LEADING)
.add(jButton16, 0, 0, Short.MAX_VALUE )
.add(jButton12, 0, 0, Short.MAX_VALUE )
.add(layout.cre ateSequentialGr oup()
.add(jButton8, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 84, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E)
.addPreferredGa p(org.jdesktop. layout.LayoutSt yle.RELATED)))
.addPreferredGa p(org.jdesktop. layout.LayoutSt yle.RELATED))
.add(jButton4, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 84, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E))))
.addContainerGa p())
);
layout.setVerti calGroup(
layout.createPa rallelGroup(org .jdesktop.layou t.GroupLayout.L EADING)
.add(layout.cre ateSequentialGr oup()
.addContainerGa p()
.add(jScrollPan e1, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, org.jdesktop.la yout.GroupLayou t.DEFAULT_SIZE, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E)
.addPreferredGa p(org.jdesktop. layout.LayoutSt yle.RELATED)
.add(layout.cre ateParallelGrou p(org.jdesktop. layout.GroupLay out.BASELINE)
.add(jButton4, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 66, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E)
.add(jButton3, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 66, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E)
.add(jButton2, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 64, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E)
.add(jButton1, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 65, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E))
.add(layout.cre ateParallelGrou p(org.jdesktop. layout.GroupLay out.LEADING)
.add(layout.cre ateSequentialGr oup()
.addPreferredGa p(org.jdesktop. layout.LayoutSt yle.RELATED)
.add(layout.cre ateParallelGrou p(org.jdesktop. layout.GroupLay out.BASELINE)
.add(jButton5, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 65, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E)
.add(jButton7, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 64, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E)
.add(jButton6, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E, 64, org.jdesktop.la yout.GroupLayou t.PREFERRED_SIZ E)))
.add(layout.cre ateSequentialGr oup()
.add(6, 6, 6)
.add(jButton8,