Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Content count

  • Joined

  • Last visited


About C30N9

  • Rank
    Senior Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Single Status Update

See all updates by C30N9

  1. Here is a code for a calculator using GUI and event driven programming. One annoying problem is that the numbered buttons call the action method twice. Suggestions to improve the program is much appreciated.

    EDIT: An error found. Putting 0s in front of numbers might manipulate the calculation a bit.


    1. Maes


      Regarding the registering each action twice, that's because you're just listening for all events without filtering them out by type (e.g. button pressed, button released, etc.), and even buttons can generate many kinds of events, not just "pressed". Whenever you click on a button, you generate at least a "button pressed" and "button released" event, while I think there's also a "button clicked" event which only triggers upon a complete press-release cycle.

    2. C30N9


      It should invoke ActionPerformed(ActionEvent e) on press and release. The +, -, * and / buttons work fine.

    3. C30N9


      It turns out that I added the listener two times, that's why it happened. Still though the program does not work perfectly, as I said, when I write 0s in front of numbers, values are manipulated. There must be something faulty in the library I imported. Any suggestions?