< prev index next >

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

Print this page




 243                 e.getX(), e.getY(), e.getXOnScreen(),
 244                 e.getYOnScreen(), e.getClickCount(),
 245                 e.isPopupTrigger(), MouseEvent.NOBUTTON));
 246         }
 247 
 248         @SuppressWarnings("deprecation")
 249         public boolean isFocusTraversable() {
 250             return false;
 251         }
 252 
 253         public Dimension getMinimumSize() {
 254             return new Dimension(defaultIcon.getIconWidth() + 1,
 255                                  LABEL_HEIGHT + LABEL_DIVIDER);
 256         }
 257 
 258         public Dimension getPreferredSize() {
 259             String title = frame.getTitle();
 260             FontMetrics fm = frame.getFontMetrics(defaultTitleFont);
 261             int w = 4;
 262             if (title != null) {
 263                 w += SwingUtilities2.stringWidth(frame, fm, title);
 264             }
 265             return new Dimension(w, LABEL_HEIGHT + LABEL_DIVIDER);
 266         }
 267 
 268         public void paint(Graphics g) {
 269             super.paint(g);
 270 
 271             // touch-up frame
 272             int maxX = getWidth() - 1;
 273             Color shadow =
 274                 UIManager.getColor("inactiveCaptionBorder").darker().darker();
 275             g.setColor(shadow);
 276             g.setClip(0, 0, getWidth(), getHeight());
 277             g.drawLine(maxX - 1, 1, maxX - 1, 1);
 278             g.drawLine(maxX, 0, maxX, 0);
 279 
 280             // fill background
 281             g.setColor(UIManager.getColor("inactiveCaption"));
 282             g.fillRect(2, 1, maxX - 3, LABEL_HEIGHT + 1);
 283 
 284             // draw text -- clipping to truncate text like CDE/Motif
 285             g.setClip(2, 1, maxX - 4, LABEL_HEIGHT);
 286             int y = LABEL_HEIGHT - SwingUtilities2.getFontMetrics(frame, g).
 287                                                    getDescent();
 288             g.setColor(UIManager.getColor("inactiveCaptionText"));
 289             String title = frame.getTitle();
 290             if (title != null) {
 291                 SwingUtilities2.drawString(frame, g, title, 4, y);
 292             }
 293         }
 294     }
 295 
 296     @SuppressWarnings("serial") // Superclass is not serializable across versions
 297     protected class IconButton extends JButton {
 298         Icon icon;
 299 
 300         IconButton(Icon icon) {
 301             super(icon);
 302             this.icon = icon;
 303             // Forward mouse events to titlebar for moves.
 304             addMouseMotionListener(new MouseMotionListener() {
 305                 public void mouseDragged(MouseEvent e) {
 306                     forwardEventToParent(e);
 307                 }
 308                 public void mouseMoved(MouseEvent e) {
 309                     forwardEventToParent(e);
 310                 }
 311             });




 243                 e.getX(), e.getY(), e.getXOnScreen(),
 244                 e.getYOnScreen(), e.getClickCount(),
 245                 e.isPopupTrigger(), MouseEvent.NOBUTTON));
 246         }
 247 
 248         @SuppressWarnings("deprecation")
 249         public boolean isFocusTraversable() {
 250             return false;
 251         }
 252 
 253         public Dimension getMinimumSize() {
 254             return new Dimension(defaultIcon.getIconWidth() + 1,
 255                                  LABEL_HEIGHT + LABEL_DIVIDER);
 256         }
 257 
 258         public Dimension getPreferredSize() {
 259             String title = frame.getTitle();
 260             FontMetrics fm = frame.getFontMetrics(defaultTitleFont);
 261             int w = 4;
 262             if (title != null) {
 263                 w += getTextUIDrawing().getStringWidth(frame, fm, title);
 264             }
 265             return new Dimension(w, LABEL_HEIGHT + LABEL_DIVIDER);
 266         }
 267 
 268         public void paint(Graphics g) {
 269             super.paint(g);
 270 
 271             // touch-up frame
 272             int maxX = getWidth() - 1;
 273             Color shadow =
 274                 UIManager.getColor("inactiveCaptionBorder").darker().darker();
 275             g.setColor(shadow);
 276             g.setClip(0, 0, getWidth(), getHeight());
 277             g.drawLine(maxX - 1, 1, maxX - 1, 1);
 278             g.drawLine(maxX, 0, maxX, 0);
 279 
 280             // fill background
 281             g.setColor(UIManager.getColor("inactiveCaption"));
 282             g.fillRect(2, 1, maxX - 3, LABEL_HEIGHT + 1);
 283 
 284             // draw text -- clipping to truncate text like CDE/Motif
 285             g.setClip(2, 1, maxX - 4, LABEL_HEIGHT);
 286             int y = LABEL_HEIGHT - SwingUtilities2.getFontMetrics(frame, g).
 287                                                    getDescent();
 288             g.setColor(UIManager.getColor("inactiveCaptionText"));
 289             String title = frame.getTitle();
 290             if (title != null) {
 291                 getTextUIDrawing().drawString(frame, g, title, 4, y);
 292             }
 293         }
 294     }
 295 
 296     @SuppressWarnings("serial") // Superclass is not serializable across versions
 297     protected class IconButton extends JButton {
 298         Icon icon;
 299 
 300         IconButton(Icon icon) {
 301             super(icon);
 302             this.icon = icon;
 303             // Forward mouse events to titlebar for moves.
 304             addMouseMotionListener(new MouseMotionListener() {
 305                 public void mouseDragged(MouseEvent e) {
 306                     forwardEventToParent(e);
 307                 }
 308                 public void mouseMoved(MouseEvent e) {
 309                     forwardEventToParent(e);
 310                 }
 311             });


< prev index next >