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

SynthTabbedPaneUI.paintTabArea() is not called when tabbed pane is painted

XMLWordPrintable

    • b89
    • generic
    • generic

      Platform: all
      JDK: 7b84 (since availability of SynthTabbedPaneUI for use)

      Method SynthTabbedPaneUI.paintTabArea() says:

         Description copied from class: BasicTabbedPaneUI
         Paints the tabs in the tab area. Invoked by paint().
         ...

      Class has two overloaded methods

       1. paint(SynthContext context, Graphics g)
       2. paint(Graphics g, JComponent c)

      The original description of paintTabArea() mentions the second one which is not used in SynthUI.
      The spec should be updated or method paintTabArea() should be called from the first paint() method.

      Please see the following code sample as the illustration:
      ---
      import javax.swing.*;
      import javax.swing.plaf.synth.*;
      import java.awt.*;

      public class PaintTest {

          public static void main(String[] args) throws Exception {
              SwingUtilities.invokeAndWait(new Runnable() {
                  @Override
                  public void run() {
                      runTest();
                  }
              });
          }

          private static void runTest() {
              try {
                  UIManager.setLookAndFeel(new SynthLookAndFeel());
              } catch (UnsupportedLookAndFeelException e) {
                  throw new RuntimeException(e);
              }
              JTabbedPane tabbedPane = new JTabbedPane();
              tabbedPane.add("first", new JLabel("first"));
              tabbedPane.add("second", new JLabel("second"));
              tabbedPane.add("third", new JLabel("third"));
              tabbedPane.setUI(new SynthTabbedPaneUI() {
                  @Override
                  public void paint(Graphics g, JComponent c) {
                      System.out.println("called paint(Graphics g, JComponent c)");
                      super.paint(g, c);
                  }
                  @Override
                  protected void paint(SynthContext context, Graphics g) {
                      System.out.println("called paint(SynthContext context, Graphics g)");
                      super.paint(context, g);
                  }
                  @Override
                  protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) {
                      System.out.println("called called paint(SynthContext context, Graphics g)");
                      super.paintTabArea(g, tabPlacement, selectedIndex);
                  }
              });
              JFrame jFrame = new JFrame();
              jFrame.getContentPane().add(tabbedPane);
              jFrame.pack();
              jFrame.setVisible(true);
          }
      }
      ---

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: