Display issue / duplicate buttons-panels
Hi,
Here's one wearied but interesting display issue in one of our product (code not written by me :) .. somebody else has written it.. and I am maintaining it currently), which is running on java 1.3.
Need some experts comments on this.. I need to explain the problem little elaborately to give the idea.
Problem
--
The issue doesnt happen always .. it happens very rarely .. once in a while.. From user's perspective the issue is like this..
There's one screen which is made of several JPanel(s) and many JToggleButton(s) inside those panels.. It normally works as expected (all the buttons will respond properly and function as expected on click) when the screen is displayed.
But when the issue happens, none of the buttons (buttons are placed in a vertical row) will respond, you will click on those toggle buttons and nothing will happen as if you are clicking on a label or something (basically you will not visibly see buttons getting pressed/clicked only)
(Adding to that behavior).. now suddenly when you move your mouse little bit right hand side (away from that set of buttons), you will see the duplicate buttons of all those buttons getting popped up one by one as you move your mouse, and they will respond to mouse clicks.
My Investigation
-
Now as an investigation, we checked the entire code but didn抰 see anything obvious happening that would clearly indicate where the problem is. (panel/any component getting added twice, double listeners, etc... nothing of that sort is happening)
Finally we found one piece of code where one panel (which contains those buttons) was getting positioned at logically incorrect coordinates (where it shouldn't be as per the panels design). Right now it looks like this could be the problem (though not able to directly relate how it would show duplicate buttons etc).. but basically there are two things that I am not able to understand ..
- The parent panel to this panel (which is getting shifted) has border layout, so technically this piece of code should not affect.. it should simply be ignored (don抰 know why that kind of code itself is there at the first place).
- Why the behavior is not consistent ? Think for a while that border layout is not working properly, but if coordinates being passed are incorrect (since that's the code which gets executed always) then that panel should always be placed at that incorrect position, which is not the case.
It's that deprecated method "reshape" which is used to position that panel. Using that could again be the problem since its deprecated.
So it looks like when we position that panel using "reshape" within BorderLayout, java mostly ignores this piece of code, but sometimes (once in while) it failes in that and gives those passed coordinates to that panel, which is the failure mode.
Proposed Fix
Now as a fix I could have removed that piece of code only .. but want to avoid that if possible (this product is running in the market from last 5 years.. dont know what else might break bcoz of that change) .. so instread of removing just corrected those coordinates with the proper values, and I didn't see that issue happening after this change (atleast in last couple of round of cycling that we did).
If anybody has seen/experienced such issue before, and can give any kind of input/information/suggestion to throw some light .. would be great.
Basically before delivering the patch with this change, I want a rock-solid confirmation that this change will fix the issue.
Any suggestion is welcome.
Thanks for reading, and for help in advance,
Rajiv

