Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java calculator problems. Old homework just never completed correctly  RSS feed

 
Michael W Adams
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote this code directly from the book code block after code block. For my own learning experience following and typing the code myself helps me learn the syntax of code better than any copy and paste. Anyways I found myself debugging the code because of typos on my part, which is another learning experience. I cleared all bugs and it complies fine, but when I run the calculator it does not show the buttons at all. I used import java.swing.JOptionPane; at first and found that import javax.swing.JOptionPane; is the correct import format, but is this still causing the buttons not to show. I am using TextPad, but also using NetBeans because I want to move away from TextPad, they both are running the same results.

 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,

You need to add the line to your constructor so your keypad is part of your Frame.

Les
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also the code needs to use the equals() method to compare Strings. not the == operator.
 
Michael W Adams
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Les, that definitely helped. I went back into the book and seen that I had another typo after placing you response in the Frame. Found a few more mistakes that I had to correct, good learning experience. Thanks Norm, I am going to look into your response also, as of right now it is working correctly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!