jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollButton.java
changeset 25178 dbab904451e9
parent 22574 7f8ce0c8c20a
equal deleted inserted replaced
25177:487a5e71f6dd 25178:dbab904451e9
    57   private static Color highlightColor;
    57   private static Color highlightColor;
    58   private boolean isFreeStanding = false;
    58   private boolean isFreeStanding = false;
    59 
    59 
    60   private int buttonWidth;
    60   private int buttonWidth;
    61 
    61 
       
    62         /**
       
    63          * Constructs an instance of {@code MetalScrollButton}.
       
    64          *
       
    65          * @param direction the direction
       
    66          * @param width the width
       
    67          * @param freeStanding the free standing value
       
    68          */
    62         public MetalScrollButton( int direction, int width, boolean freeStanding )
    69         public MetalScrollButton( int direction, int width, boolean freeStanding )
    63         {
    70         {
    64             super( direction );
    71             super( direction );
    65 
    72 
    66             shadowColor = UIManager.getColor("ScrollBar.darkShadow");
    73             shadowColor = UIManager.getColor("ScrollBar.darkShadow");
    68 
    75 
    69             buttonWidth = width;
    76             buttonWidth = width;
    70             isFreeStanding = freeStanding;
    77             isFreeStanding = freeStanding;
    71         }
    78         }
    72 
    79 
       
    80         /**
       
    81          * Sets the free standing value.
       
    82          *
       
    83          * @param freeStanding the free standing value
       
    84          */
    73         public void setFreeStanding( boolean freeStanding )
    85         public void setFreeStanding( boolean freeStanding )
    74         {
    86         {
    75             isFreeStanding = freeStanding;
    87             isFreeStanding = freeStanding;
    76         }
    88         }
    77 
    89 
   113 
   125 
   114                 // Draw the arrow
   126                 // Draw the arrow
   115                 g.setColor( arrowColor );
   127                 g.setColor( arrowColor );
   116                 int startY = ((h+1) - arrowHeight) / 2;
   128                 int startY = ((h+1) - arrowHeight) / 2;
   117                 int startX = (w / 2);
   129                 int startX = (w / 2);
   118                 //                  System.out.println( "startX :" + startX + " startY :"+startY);
   130 
   119                 for (int line = 0; line < arrowHeight; line++) {
   131                 for (int line = 0; line < arrowHeight; line++) {
   120                     g.drawLine( startX-line, startY+line, startX +line+1, startY+line);
   132                     g.drawLine( startX-line, startY+line, startX +line+1, startY+line);
   121                 }
   133                 }
   122         /*      g.drawLine( 7, 6, 8, 6 );
       
   123                 g.drawLine( 6, 7, 9, 7 );
       
   124                 g.drawLine( 5, 8, 10, 8 );
       
   125                 g.drawLine( 4, 9, 11, 9 );*/
       
   126 
   134 
   127                 if (isEnabled) {
   135                 if (isEnabled) {
   128                     g.setColor( highlightColor );
   136                     g.setColor( highlightColor );
   129 
   137 
   130                     if ( !isPressed )
   138                     if ( !isPressed )
   165                 g.setColor( arrowColor );
   173                 g.setColor( arrowColor );
   166 
   174 
   167                 int startY = (((h+1) - arrowHeight) / 2)+ arrowHeight-1;
   175                 int startY = (((h+1) - arrowHeight) / 2)+ arrowHeight-1;
   168                 int startX = (w / 2);
   176                 int startX = (w / 2);
   169 
   177 
   170                 //          System.out.println( "startX2 :" + startX + " startY2 :"+startY);
       
   171 
       
   172                 for (int line = 0; line < arrowHeight; line++) {
   178                 for (int line = 0; line < arrowHeight; line++) {
   173                     g.drawLine( startX-line, startY-line, startX +line+1, startY-line);
   179                     g.drawLine( startX-line, startY-line, startX +line+1, startY-line);
   174                 }
   180                 }
   175 
       
   176         /*      g.drawLine( 4, 5, 11, 5 );
       
   177                 g.drawLine( 5, 6, 10, 6 );
       
   178                 g.drawLine( 6, 7, 9, 7 );
       
   179                 g.drawLine( 7, 8, 8, 8 ); */
       
   180 
   181 
   181                 if (isEnabled) {
   182                 if (isEnabled) {
   182                     g.setColor( highlightColor );
   183                     g.setColor( highlightColor );
   183 
   184 
   184                     if ( !isPressed )
   185                     if ( !isPressed )
   217                 g.setColor( arrowColor );
   218                 g.setColor( arrowColor );
   218 
   219 
   219                 int startX = (((w+1) - arrowHeight) / 2) + arrowHeight-1;
   220                 int startX = (((w+1) - arrowHeight) / 2) + arrowHeight-1;
   220                 int startY = (h / 2);
   221                 int startY = (h / 2);
   221 
   222 
   222                 //System.out.println( "startX2 :" + startX + " startY2 :"+startY);
       
   223 
       
   224                 for (int line = 0; line < arrowHeight; line++) {
   223                 for (int line = 0; line < arrowHeight; line++) {
   225                     g.drawLine( startX-line, startY-line, startX -line, startY+line+1);
   224                     g.drawLine( startX-line, startY-line, startX -line, startY+line+1);
   226                 }
   225                 }
   227 
       
   228 
       
   229 /*              g.drawLine( 5, 4, 5, 11 );
       
   230                 g.drawLine( 6, 5, 6, 10 );
       
   231                 g.drawLine( 7, 6, 7, 9 );
       
   232                 g.drawLine( 8, 7, 8, 8 );*/
       
   233 
   226 
   234                 if (isEnabled) {
   227                 if (isEnabled) {
   235                     g.setColor( highlightColor );
   228                     g.setColor( highlightColor );
   236 
   229 
   237                     if ( !isPressed )
   230                     if ( !isPressed )
   272 
   265 
   273                 for (int line = 0; line < arrowHeight; line++) {
   266                 for (int line = 0; line < arrowHeight; line++) {
   274                     g.drawLine( startX+line, startY-line, startX +line, startY+line+1);
   267                     g.drawLine( startX+line, startY-line, startX +line, startY+line+1);
   275                 }
   268                 }
   276 
   269 
   277         /*      g.drawLine( 6, 7, 6, 8 );
       
   278                 g.drawLine( 7, 6, 7, 9 );
       
   279                 g.drawLine( 8, 5, 8, 10 );
       
   280                 g.drawLine( 9, 4, 9, 11 );*/
       
   281 
       
   282                 if (isEnabled) {
   270                 if (isEnabled) {
   283                     g.setColor( highlightColor );
   271                     g.setColor( highlightColor );
   284 
   272 
   285 
   273 
   286                     if ( !isPressed )
   274                     if ( !isPressed )
   339         public Dimension getMaximumSize()
   327         public Dimension getMaximumSize()
   340         {
   328         {
   341             return new Dimension( Integer.MAX_VALUE, Integer.MAX_VALUE );
   329             return new Dimension( Integer.MAX_VALUE, Integer.MAX_VALUE );
   342         }
   330         }
   343 
   331 
       
   332         /**
       
   333          * Returns the width of the button.
       
   334          *
       
   335          * @return the width of the button
       
   336          */
   344         public int getButtonWidth() {
   337         public int getButtonWidth() {
   345             return buttonWidth;
   338             return buttonWidth;
   346         }
   339         }
   347 }
   340 }