< prev index next >

src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifGraphicsUtils.java

Print this page




 122             drawWidth = SwingUtilities2.stringWidth(c, fontMetrics, aString);
 123             if (drawWidth > width) {
 124                 drawWidth = width;
 125             }
 126             startX = x + width - drawWidth;
 127         } else {
 128             startX = x;
 129         }
 130 
 131         delta = (height - fontMetrics.getAscent() - fontMetrics.getDescent()) / 2;
 132         if (delta < 0) {
 133             delta = 0;
 134         }
 135 
 136         startY = y + height - delta - fontMetrics.getDescent();
 137 
 138         SwingUtilities2.drawString(c, g, aString, startX, startY);
 139     }
 140 
 141   /**
 142    * This method is not being used to paint menu item since
 143    * 6.0 This code left for compatibility only. Do not use or
 144    * override it, this will not cause any visible effect.
 145    */

 146   public static void paintMenuItem(Graphics g, JComponent c,
 147                                    Icon checkIcon, Icon arrowIcon,
 148                                    Color background, Color foreground,
 149                                    int defaultTextIconGap)
 150     {
 151 
 152         JMenuItem b = (JMenuItem) c;
 153         ButtonModel model = b.getModel();
 154 
 155         Dimension size = b.getSize();
 156         Insets i = c.getInsets();
 157 
 158         Rectangle viewRect = new Rectangle(size);
 159 
 160         viewRect.x += i.left;
 161         viewRect.y += i.top;
 162         viewRect.width -= (i.right + viewRect.x);
 163         viewRect.height -= (i.bottom + viewRect.y);
 164 
 165         Rectangle iconRect = new Rectangle();




 122             drawWidth = SwingUtilities2.stringWidth(c, fontMetrics, aString);
 123             if (drawWidth > width) {
 124                 drawWidth = width;
 125             }
 126             startX = x + width - drawWidth;
 127         } else {
 128             startX = x;
 129         }
 130 
 131         delta = (height - fontMetrics.getAscent() - fontMetrics.getDescent()) / 2;
 132         if (delta < 0) {
 133             delta = 0;
 134         }
 135 
 136         startY = y + height - delta - fontMetrics.getDescent();
 137 
 138         SwingUtilities2.drawString(c, g, aString, startX, startY);
 139     }
 140 
 141   /**
 142    * @deprecated This method is not being used to paint menu item since
 143    * 6.0 This code left for compatibility only. Do not use or
 144    * override it, this will not cause any visible effect.
 145    */
 146   @Deprecated(since = "9")
 147   public static void paintMenuItem(Graphics g, JComponent c,
 148                                    Icon checkIcon, Icon arrowIcon,
 149                                    Color background, Color foreground,
 150                                    int defaultTextIconGap)
 151     {
 152 
 153         JMenuItem b = (JMenuItem) c;
 154         ButtonModel model = b.getModel();
 155 
 156         Dimension size = b.getSize();
 157         Insets i = c.getInsets();
 158 
 159         Rectangle viewRect = new Rectangle(size);
 160 
 161         viewRect.x += i.left;
 162         viewRect.y += i.top;
 163         viewRect.width -= (i.right + viewRect.x);
 164         viewRect.height -= (i.bottom + viewRect.y);
 165 
 166         Rectangle iconRect = new Rectangle();


< prev index next >