Firstly-Sorry about my spelling
I'm trying to code, produce, calculating ''machine'' (hahaha) and I've tried various things(?). If else-statement.....blabla....see the text in yellow.
I'm trying to build on existing code that is working fine, the plus action is working. I'm trying to build more actions in it like a minus function...for starters. What I need is a sugestions on how to proceed This is the error I get in the Eclipse console:
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 693)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:97)
mport java.applet.Applet;// The code starts here. import java.awt.*; public class Reiknivel extends Applet // Reiknivel means calculator machine { /** * */ private static final long serialVersionUID = 1L; TextField t1, t2, tsvar;// svar means answer Button bplus; Button bminus; Label a1, a2, b3; Double D1, D2; double d1, d2, dsvar; public void init() { t1 = new TextField(3); t2 = new TextField(3); tsvar = new TextField(15); bplus = new Button("+"); bminus = new Button("-"); a1 = new Label ("Tala 1");//means number 1 a2 = new Label ("Tala 2");//means number 2 b3 = new Label ("Samanlagt"); this.add(a1); this.add(t1); this.add(bplus); this.add(bminus); this.add(a2); this.add(t2); this.add(b3); this.add(tsvar); } public boolean action(Event e,Object o) { if (e.target == bplus); { D1 = new Double(t1.getText()); d1 = D1.doubleValue(); D2 = new Double(t2.getText()); d2 = D2.doubleValue(); dsvar = d1 + d2; tsvar.setText("Summan er: " + dsvar); return true; } return false;// Here ends the original code. And it works just fine.[COLOR="#FFD700"] AND HERIN LIES MY PROBLEM. The thing that I'm trying to ''produce'' is to add -, * , / ...buttons and actions or functions [/COLOR] } public boolean action2(Event e,Object o)// I'm trying to continue here { if (e.target == bminus); D1 = new Double(t1.getText()); d1 = D1.doubleValue(); D2 = new Double(t2.getText()); d2 = D2.doubleValue(); dsvar = d1 - d2; tsvar.setText("Summan er: " + dsvar); return true; } }