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

REGRESSION: No caret is shown on empty Textpanes with Synth Look and Feel

    Details

      Description

      FULL PRODUCT VERSION :
      Version 1.5.0_05 or higher

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Appears only when a Synth Look and Feel is set.

      A DESCRIPTION OF THE PROBLEM :
      By using a Synth Look and Feel and an _empty_ JTextPane no caret will be displayed. This occurs only with JVM 1.5.0_05 or higher including Mustang. With JVM 1.5.0_04 the problem doesn't occur.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import java.awt.Color;
      import java.awt.Dimension;
      import java.awt.Graphics;
      import java.io.ByteArrayInputStream;
      import java.io.InputStream;

      import javax.swing.JFrame;
      import javax.swing.JTextPane;
      import javax.swing.UIManager;
      import javax.swing.plaf.synth.SynthContext;
      import javax.swing.plaf.synth.SynthLookAndFeel;
      import javax.swing.plaf.synth.SynthPainter;

      public class TextPaneTest extends JFrame
      {
        private static String synthXml = "<synth>" +
        " <style id=\"all\">" +
        " <object id=\"customPainter\" class=\"TextPaneTest$TextPanePainter\" />" +
        " <font name=\"Verdana\" size=\"12\"/>" +
        " </style>" +
        " <bind style=\"all\" type=\"REGION\" key=\".*\"/>" +
        " <style id=\"textPane\">" +
        " <state>" +
        " <color value=\"#FFFFFF\" type=\"BACKGROUND\"/>" +
        " <painter method=\"textPaneBackground\" idref=\"customPainter\" />" +
        " </state>" +
        " </style>" +
        " <bind style=\"textPane\" type=\"region\" key=\"TextPane\"/>" +
        "</synth>";
       
        public static void main(String[] args) throws Exception
        {
          InputStream is = new ByteArrayInputStream(synthXml.getBytes("UTF8"));
          SynthLookAndFeel laf = new SynthLookAndFeel();
          laf.load(is, TextPaneTest.class);
          UIManager.setLookAndFeel(laf);
          new TextPaneTest();
        }

        public TextPaneTest()
        {
          JTextPane textPane = new JTextPane();
          textPane.setText("Delete this text - caret disappers!");
          add(textPane);

          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setSize(new Dimension(400, 300));
          setLocationRelativeTo(null);
          setVisible(true);
        }

        public static class TextPanePainter extends SynthPainter
        {
          public void paintTextPaneBackground(SynthContext sc, Graphics g, int
      x, int y, int w, int h)
          {
            //Also changes the caret color for empty textPanes with Java 1.5.0_05 or later!
            g.setColor(Color.YELLOW);
            g.fillRect(x, y, w, h);
          }
        }
         
      }

      ---------- END SOURCE ----------

      Release Regression From : 5.0u4
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                svioletsunw Scott Violet (Inactive)
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: