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

Print this page


   1 /*
   2  * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 183     }
 184 
 185     public Dimension getMaximumSize(JComponent c){
 186         return getMinimumSize(c);
 187     }
 188 
 189     /**
 190       * Returns the default desktop icon.
 191       */
 192     public Icon getDefaultIcon() {
 193         return defaultIcon;
 194     }
 195 
 196     /**
 197       * Sets the icon used as the default desktop icon.
 198       */
 199     public void setDefaultIcon(Icon newIcon) {
 200         defaultIcon = newIcon;
 201     }
 202 

 203     protected class IconLabel extends JPanel {
 204         JInternalFrame frame;
 205 
 206         IconLabel(JInternalFrame f) {
 207             super();
 208             this.frame = f;
 209             setFont(defaultTitleFont);
 210 
 211             // Forward mouse events to titlebar for moves.
 212             addMouseMotionListener(new MouseMotionListener() {
 213                 public void mouseDragged(MouseEvent e) {
 214                     forwardEventToParent(e);
 215                 }
 216                 public void mouseMoved(MouseEvent e) {
 217                     forwardEventToParent(e);
 218                 }
 219             });
 220             addMouseListener(new MouseListener() {
 221                 public void mouseClicked(MouseEvent e) {
 222                     forwardEventToParent(e);


 274             g.setClip(0, 0, getWidth(), getHeight());
 275             g.drawLine(maxX - 1, 1, maxX - 1, 1);
 276             g.drawLine(maxX, 0, maxX, 0);
 277 
 278             // fill background
 279             g.setColor(UIManager.getColor("inactiveCaption"));
 280             g.fillRect(2, 1, maxX - 3, LABEL_HEIGHT + 1);
 281 
 282             // draw text -- clipping to truncate text like CDE/Motif
 283             g.setClip(2, 1, maxX - 4, LABEL_HEIGHT);
 284             int y = LABEL_HEIGHT - SwingUtilities2.getFontMetrics(frame, g).
 285                                                    getDescent();
 286             g.setColor(UIManager.getColor("inactiveCaptionText"));
 287             String title = frame.getTitle();
 288             if (title != null) {
 289                 SwingUtilities2.drawString(frame, g, title, 4, y);
 290             }
 291         }
 292     }
 293 

 294     protected class IconButton extends JButton {
 295         Icon icon;
 296 
 297         IconButton(Icon icon) {
 298             super(icon);
 299             this.icon = icon;
 300             // Forward mouse events to titlebar for moves.
 301             addMouseMotionListener(new MouseMotionListener() {
 302                 public void mouseDragged(MouseEvent e) {
 303                     forwardEventToParent(e);
 304                 }
 305                 public void mouseMoved(MouseEvent e) {
 306                     forwardEventToParent(e);
 307                 }
 308             });
 309             addMouseListener(new MouseListener() {
 310                 public void mouseClicked(MouseEvent e) {
 311                     forwardEventToParent(e);
 312                 }
 313                 public void mousePressed(MouseEvent e) {


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 183     }
 184 
 185     public Dimension getMaximumSize(JComponent c){
 186         return getMinimumSize(c);
 187     }
 188 
 189     /**
 190       * Returns the default desktop icon.
 191       */
 192     public Icon getDefaultIcon() {
 193         return defaultIcon;
 194     }
 195 
 196     /**
 197       * Sets the icon used as the default desktop icon.
 198       */
 199     public void setDefaultIcon(Icon newIcon) {
 200         defaultIcon = newIcon;
 201     }
 202 
 203     @SuppressWarnings("serial") // Superclass is not serializable across versions
 204     protected class IconLabel extends JPanel {
 205         JInternalFrame frame;
 206 
 207         IconLabel(JInternalFrame f) {
 208             super();
 209             this.frame = f;
 210             setFont(defaultTitleFont);
 211 
 212             // Forward mouse events to titlebar for moves.
 213             addMouseMotionListener(new MouseMotionListener() {
 214                 public void mouseDragged(MouseEvent e) {
 215                     forwardEventToParent(e);
 216                 }
 217                 public void mouseMoved(MouseEvent e) {
 218                     forwardEventToParent(e);
 219                 }
 220             });
 221             addMouseListener(new MouseListener() {
 222                 public void mouseClicked(MouseEvent e) {
 223                     forwardEventToParent(e);


 275             g.setClip(0, 0, getWidth(), getHeight());
 276             g.drawLine(maxX - 1, 1, maxX - 1, 1);
 277             g.drawLine(maxX, 0, maxX, 0);
 278 
 279             // fill background
 280             g.setColor(UIManager.getColor("inactiveCaption"));
 281             g.fillRect(2, 1, maxX - 3, LABEL_HEIGHT + 1);
 282 
 283             // draw text -- clipping to truncate text like CDE/Motif
 284             g.setClip(2, 1, maxX - 4, LABEL_HEIGHT);
 285             int y = LABEL_HEIGHT - SwingUtilities2.getFontMetrics(frame, g).
 286                                                    getDescent();
 287             g.setColor(UIManager.getColor("inactiveCaptionText"));
 288             String title = frame.getTitle();
 289             if (title != null) {
 290                 SwingUtilities2.drawString(frame, g, title, 4, y);
 291             }
 292         }
 293     }
 294 
 295     @SuppressWarnings("serial") // Superclass is not serializable across versions
 296     protected class IconButton extends JButton {
 297         Icon icon;
 298 
 299         IconButton(Icon icon) {
 300             super(icon);
 301             this.icon = icon;
 302             // Forward mouse events to titlebar for moves.
 303             addMouseMotionListener(new MouseMotionListener() {
 304                 public void mouseDragged(MouseEvent e) {
 305                     forwardEventToParent(e);
 306                 }
 307                 public void mouseMoved(MouseEvent e) {
 308                     forwardEventToParent(e);
 309                 }
 310             });
 311             addMouseListener(new MouseListener() {
 312                 public void mouseClicked(MouseEvent e) {
 313                     forwardEventToParent(e);
 314                 }
 315                 public void mousePressed(MouseEvent e) {