java - Why am I getting the error: Incompatible types; JButton cannot be converted to a JTextfield -


so i'm getting error , i'm confused. i'm not trying that..here's have:

    import javax.swing.jframe;     import java.awt.*;     import java.awt.event.actionevent;     import java.awt.event.actionlistener;     import javax.swing.jbutton;     import javax.swing.jlabel;     import javax.swing.jtextfield;     import javax.swing.swingconstants;       public class answerfinder extends jframe {     private static final int width = 400;     private static final int heighth = 300;      private jlabel ial, ratelabel,earn1, earn2, earn3, earn4, earn5, earn10;     private jlabel equalabel;     private jtextfield ratein,initialamin, earn1out, earn2out, earn3out, earn4out, earn5out,   earn10out;     private jbutton calculatebut;     private calculatebuttonhandler cbhandler;      public answerfinder() {          // adding labels         ial = new jlabel("enter initial amount:",swingconstants.right);         ratelabel = new jlabel("enter growth percentage (just numbers):",swingconstants.right);         earn1 = new jlabel("total year 1:",swingconstants.right);         earn2 = new jlabel("total year 2:",swingconstants.right);         earn3 = new jlabel("total year 3:",swingconstants.right);         earn4 = new jlabel("total year 4:",swingconstants.right);         earn5 = new jlabel("total year 5:",swingconstants.right);         earn10 = new jlabel("total year 10:",swingconstants.right);         equalabel = new jlabel("press calculate: ");          //adding textfields         ratein = new jtextfield();         initialamin = new jtextfield();         earn1out =           //adding button         calculatebut = new jbutton("calculate");         cbhandler = new calculatebuttonhandler();         calculatebut.addactionlistener(cbhandler);          // sets title of program         settitle("exponential growth calculator");        // sets size of frame, whether or not it's visible, , on close         setsize(width, heighth);         setvisible(true);         setdefaultcloseoperation(exit_on_close);          // establishes container , sets layout         container pane = getcontentpane();         pane.setlayout(new gridlayout (8,2));          pane.add(ial);         pane.add(initialamin);         pane.add(ratelabel);         pane.add(ratein);         pane.add(equalabel);         pane.add(calculatebut);         pane.add(earn1);     }      private class calculatebuttonhandler implements actionlistener {           @override         public void actionperformed(actionevent e) {              double rate, initamount, returns1, returns2, returns3, returns4, returns5, returns10;              rate = double.parsedouble(ratein.gettext());             if (rate > 1) {                 rate = (rate / 100) + 1;             } else {                 rate = rate +1;             }             initamount = double.parsedouble(initialamin.gettext());             returns1 = initamount * math.pow(rate, 1);             returns2 = initamount * math.pow(rate, 2);             returns3 = initamount * math.pow(rate, 3);             returns4 = initamount * math.pow(rate, 4);             returns5 = initamount * math.pow(rate, 5);             returns10 = initamount * math.pow(rate, 10);         }     }  } 

i'm making program find exponential growth of numbers entered user. credit project algebra course. please ignore ugly ugly code, i'm high school student who's starting out.

you appear have half-written code in there:

initialamin = new jtextfield(); earn1out =  //adding button calculatebut = new jbutton("calculate"); 

you should either finish earn1out = line, or remove it.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -