Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IDE single selection  RSS feed

 
Aditya Khare
Greenhorn
Posts: 4
Chrome Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I'm using netbeans and have developed a gui calculator. Now i have a decimal (.) button. i want this button to be pressed only once! so is there something like SINGLE SELECTION for a jButton? With IDE or without doesn't matter!
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aditya Khare wrote:... so is there something like SINGLE SELECTION for a jButton? ...

No.

Again, there were some similar topics here, why not disable that button once you press it so user can't do it again? Once you delete decimal point (on whatever way your calculator provides) you enable that button again. But you need to implement good logic on when to.disable it. What if a user wants to calculate 10.3 * 2.5. If you disable itt at first decimal point he won't be able to type in second number as 2.5.

Another approach would be not to disable it at all. But when you parse the expression user wants to calculate if there are decimal points where they shouldn't be stop evaluation and report error to the user so he can correct the input.

Edit: Sorry for typos, I'm replying over phone.
 
Aditya Khare
Greenhorn
Posts: 4
Chrome Firefox Browser Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No worry. I used two different variables to store two values. Just tell of how to disable it
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!