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

[macos] JOptionPane blocks drawing string on another component

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 11, 14
    • client-libs
    • b10
    • x86_64
    • os_x

      FULL PRODUCT VERSION :
      openjdk version "14-ea" 2020-03-17
      OpenJDK Runtime Environment (build 14-ea+23-1048)
      OpenJDK 64-Bit Server VM (build 14-ea+23-1048, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X

      A DESCRIPTION OF THE PROBLEM :
      When JOptionPane appears, Graphics2D.drawString for another component doesn't work with Mac OS X.
      It works with Linux and Windows.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile and launch the sample code
      2. Input some characters to JTextField on JOptionPane.
      3. Press enter key

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected:
      Input text was drawn in Canvas on parent JFrame
      Actual:
      No drawing

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ADDITIONAL INFORMATION:
      The original problem is about Java Input Method. The following are steps for Java IM case.
      1. Enable CityIM demo
      2. Launch OptionPaneInput sample here
      3. Set focus to a passive component; in the sample, icon or button.
      4. Input "jfk"
      => IM CompositeArea shows only "j".

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class OptionPaneInput {
          public static void main(String[] args){
              JFrame f = new JFrame();
              Canvas c = new Canvas();
              JTextField t = new JTextField();
              f.add(c);

              t.addActionListener(e->{
                      String text = t.getText();
                      Graphics2D g2 = (Graphics2D)(c.getGraphics());
                      g2.setColor(Color.BLACK);
                      g2.drawString(text, 10, 10);
                      System.out.println("drawing "+text);
              });

              f.setSize(300,100);
              f.setVisible(true);
              JOptionPane.showMessageDialog(f, t);
          }
      }
      ---------- END SOURCE ---------- 

            achung Alisen Chung
            tnakamura Toshio Nakamura
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: