Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6675886

Unexpected popup is shown in an unexpected location

    XMLWordPrintable

Details

    Description

      OPERATING SYSTEM(S):
      --------------------
      Windows Server 2008
      Windows Vista on x64 bit processor (intermittent)

      FULL JDK VERSION(S):
      -------------------
      java version "1.6.0_04"
      Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
      Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)

      DESCRIPTION:
      ------------

      While running the testcase (see below), an unexpected popup window is drawn in an unexpected location (at the upper left corner of the window).

      The testcase will show displayable characters. Clicking on the characters will bring a small popup window which will show the character clicked. However randomly clicking on characters, in particular sequence and shrinking and enlarging the window, causes an unexpected popup window to be drawn on the upper left corner of the window.

      Steps to recreate the issue:
      1. Compile and run below testcase
      2. Displayable characters are displayed
      3. Click 4th line several times randomly (possibly on the characters
         "g"/"f"/"h").
      4. Shrink window size (only horizontal side) by mouse, and release
         mouse button
      5. Enlarge window size (only horizontal side) by mouse (same as default
         window size)
      6. Click 3rd line (possibly on characters "V" /"W"/"Y"/"Z", then
         unexpeced popup is drawn on left-top of window
      7. If you cannot recreate this problem, please try step 3 - 6 again

      The issue is fairly easily (3 out of 5 attempts) recreatable in windows server 2008 on x64 processor (intel family). It is also recreatable on Vista on AMD64. The problem is not seen with Java 5.

      TESTCASE SOURCE:
      --------------------------------------------------------------------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.border.*;

      class CharacterView extends JFrame {
        private final int ROWS = 12;
        private final int COLS = 20;
        CharacterView() {
          JLabel label;
          JPanel p = new JPanel();
          setTitle("Character Viewer");
          p.setLayout(new GridLayout(0, COLS, 3, 3));
          Font font = new Font("Dialog", Font.PLAIN, 24);
          int c = 0x20;
          MyMouseListener mouseListener = new MyMouseListener();
          for(int i=0; i< ROWS*COLS ; i++) {
            while(Character.isISOControl(c) || !font.canDisplay(c)) c++;
            label = new JLabel(String.format("%c",c));
            c++;
            label.setFont(font);
            label.setHorizontalAlignment(JLabel.CENTER);
            label.setBackground(Color.white);
            label.setForeground(Color.black);
            label.setOpaque(true);
            label.addMouseListener(mouseListener);
            p.add(label);
          }
          setLayout(new BorderLayout());
          getContentPane().add(p, BorderLayout.CENTER);
          pack();
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setVisible(true);
        }
        class MyMouseListener implements MouseListener {
          private final int Y_OFFSET = 8;
          private JWindow popup;
          private JLabel label, codelabel;
          MyMouseListener() {
              popup = new JWindow();
              label = new JLabel();
              label.setFont(new Font("Dialog", Font.PLAIN, 24));
      label.setForeground(Color.black);
      label.setBackground(Color.white);
              codelabel = new JLabel();
              codelabel.setFont(new Font("Dialog", Font.PLAIN, 10));
      codelabel.setForeground(Color.black);
      codelabel.setBackground(Color.white);
              JPanel panel = new JPanel();
              panel.add(label);
              panel.add(codelabel);
              panel.setBackground(Color.white);
              panel.setBorder(new LineBorder(Color.black));
              popup.setContentPane(panel);
          }
          public void mouseClicked(MouseEvent me) {};
          public void mousePressed(MouseEvent me) {
              JLabel comp = (JLabel)me.getComponent();
              String text = comp.getText();
              Point p = comp.getLocationOnScreen();
              label.setText(text);
              codelabel.setText("0x" + Integer.toHexString((int)text.charAt(0)));
              popup.pack();
              popup.setLocation(p.x + me.getX(), p.y + me.getY() + Y_OFFSET);
              popup.setVisible(true);
          };
          public void mouseReleased(MouseEvent me) {
              if (popup.isVisible()) popup.setVisible(false);
          };
          public void mouseEntered(MouseEvent me) {};
          public void mouseExited(MouseEvent me) {};
        }
        public static void main(String[] args) {
          new CharacterView();
        }
      }
      --------------------------------------------------------------------

      Attachments

        Activity

          People

            Unassigned Unassigned
            dkorbel David Korbel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: