home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / JFC.bin / MotifButtonUI.java < prev    next >
Encoding:
Java Source  |  1998-06-30  |  2.9 KB  |  94 lines

  1. /*
  2.  * @(#)MotifButtonUI.java    1.12 98/04/10
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.plaf.motif;
  22.  
  23. import com.sun.java.swing.*;
  24. import com.sun.java.swing.border.*;
  25. import com.sun.java.swing.plaf.basic.*;
  26. import java.awt.*;
  27. import java.awt.event.*;
  28. import com.sun.java.swing.plaf.*;
  29.  
  30. /**
  31.  * MotifButton implementation
  32.  * <p>
  33.  * Warning: serialized objects of this class will not be compatible with
  34.  * future swing releases.  The current serialization support is appropriate
  35.  * for short term storage or RMI between Swing1.0 applications.  It will
  36.  * not be possible to load serialized Swing1.0 objects with future releases
  37.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  38.  * baseline for the serialized form of Swing objects.
  39.  *
  40.  * @version 1.12 04/10/98
  41.  * @author Rich Schiavi
  42.  */
  43. public class MotifButtonUI extends BasicButtonUI {
  44.   /**
  45.    * border & margin
  46.    */
  47.   protected final static Insets defaultMargin = new Insets(2,4,2,4);
  48.  
  49.   private final static MotifButtonUI motifButtonUI = new MotifButtonUI();
  50.  
  51.  
  52.   public static ComponentUI createUI(JComponent c){
  53.     return motifButtonUI;
  54.   }
  55.  
  56.   protected BasicButtonListener createListener(JComponent c){
  57.     return new MotifButtonListener((AbstractButton) c);
  58.   }
  59.  
  60.   protected void paintFocus(Graphics g, AbstractButton b,
  61.                 Rectangle viewRect, Rectangle textRect, Rectangle iconRect){
  62.     // focus painting is handled by the border
  63.   }
  64.  
  65.   protected void paintButtonPressed(Graphics g, AbstractButton b){
  66.      Color oldColor = g.getColor();
  67.      Dimension size = b.getSize();
  68.      Insets insets = b.getInsets();
  69.      Border border = b.getBorder();
  70.      if (border instanceof BorderUIResource) {
  71.          // Unfortunately the BorderUIResource hides the Border
  72.          // it's wrapping, so we have to make an assumption here.
  73.          border = MotifBorderFactory.getButtonBorder();
  74.          insets = border.getBorderInsets(b);
  75.      }
  76.      g.setColor( getSelectColor());
  77.      g.fillRect(insets.left, insets.top, 
  78.                    size.width - insets.left - insets.right,
  79.                    size.height - insets.top - insets.bottom);
  80.      g.setColor(oldColor);
  81.   }
  82.  
  83.   public Insets getDefaultMargin(AbstractButton b){
  84.     return defaultMargin;
  85.   }
  86.  
  87. }
  88.  
  89.  
  90.  
  91.  
  92.                                   
  93.   
  94.