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

SynthTextPaneUI.installUI() doesn't set component to opaque as specified

XMLWordPrintable

    • b91
    • generic
    • generic

      Method SynthTextPaneUI.installUI(JComponent c) says:

          Installs the UI for a component. This does the following things.
          1. Sets the associated component to opaque ...

      Actually it doesn't happen.
      See the following code sample:
      ----------------------------------------------------------------
      import javax.swing.*;
      import javax.swing.plaf.synth.*;

      public class InstallUIComponentOpaque {

          public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                  @Override public void run() {
                      doTheTest();
                  }
              });
          }

          private static void doTheTest() {
              try {
                  UIManager.setLookAndFeel(new SynthLookAndFeel());
              } catch (UnsupportedLookAndFeelException e) {
                  throw new RuntimeException(e);
              }
              JTextPane textPane = new JTextPane();
              SynthTextPaneUI ui = new SynthTextPaneUI() {
                  @Override
                  public void installUI(JComponent c) {
                      System.out.println("c.isOpaque() = " + c.isOpaque());
                      super.installUI(c);
                      System.out.println("InstallUIComponentOpaque.installUI called");
                      System.out.println("c.isOpaque() = " + c.isOpaque());
                  }
              };
              textPane.setOpaque(false);
              textPane.setUI(ui);
          }
      }
      ----------------------------------------------------------------
      The output will be:

      c.isOpaque() = false
      InstallUIComponentOpaque.installUI called
      c.isOpaque() = false

            rupashka Pavel Porvatov (Inactive)
            dbessono Dmitry Bessonov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: