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

MetalBorders.TableHeaderBorder: not a UIResource, wrong Insets

    Details

    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: ssT124754 Date: 03/07/2001


      java version "1.3.0_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_02)
      Java HotSpot(TM) Client VM (build 1.3.0_02, mixed mode)

      Two things about javax.swing.plaf.metal.MetalBorders.TableHeaderBorder (which is
      used as "TableHeader.cellBorder" in the UIDefaults table).


      a) There is a mismatch between the Insets that are returned from
      getBorderInsets() and the actual paint code, which (underlined line) uses one
      pixel at the right, and not zero.

      Source code reproduced here (emphasis mine):


          public static class TableHeaderBorder extends
      javax.swing.border.AbstractBorder {
              protected Insets editorBorderInsets = new Insets( 2, 2, 2, 0 );

                                                                        ^^^
                                                                        ^^^


              public void paintBorder(Component c, Graphics g, int x, int y, int w,
      int h) {
      g.translate( x, y );

      g.setColor( MetalLookAndFeel.getControlDarkShadow() );
      g.drawLine( w-1, 0, w-1, h-1 );

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      g.drawLine( 1, h-1, w-1, h-1 );
      g.setColor( MetalLookAndFeel.getControlHighlight() );
      g.drawLine( 0, 0, w-2, 0 );
      g.drawLine( 0, 0, 0, h-2 );

      g.translate( -x, -y );
      }

              public Insets getBorderInsets( Component c ) {
      return editorBorderInsets;
      }
          }

      The value for Insets.right should at least be 1, probably 2 like in the other
      directions.


      b) Like all other LAF-provided borders, it should implement UIResource so that
      it doesn't stick to a component even when the LookAndFeel is changed.
      LookAndFeel.installBorder() will not exchange the border when it is not a
      UIResource.
      When using a custom table header (the component most likely to use this border),
      and switching from Metal to another LookAndFeel, the border above
      (MetalBorders.TableHeaderBorder) remains and is not replaced by the actual
      "TableHeader.cellBorder" provided by the new LAF, leading to visual
      inconsistencies.
      (Review ID: 118287)
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ssultanasunw Shaheen Sultana (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: