212 } 213 214 final ImageIcon prev = (ImageIcon)getIcon(); 215 final ImageIcon pressedIcon = new ImageIcon(AquaUtils.generateSelectedDarkImage(prev.getImage())); 216 setIcon(pressedIcon); 217 super.paint(g); 218 setIcon(prev); 219 } 220 221 boolean mouseInIcon(final MouseEvent e) { 222 return getBounds().contains(e.getX(), e.getY()); 223 } 224 225 public Dimension getPreferredSize() { 226 return new Dimension(64, 64); //$ Dock preferred size 227 } 228 } 229 230 @SuppressWarnings("serial") // Superclass is not serializable across versions 231 class DockLabel extends JLabel { 232 final static int NUB_HEIGHT = 7; 233 final static int ROUND_ADDITIONAL_HEIGHT = 8; 234 final static int ROUND_ADDITIONAL_WIDTH = 12; 235 236 DockLabel(final String text) { 237 super(text); 238 setBorder(null); 239 setOpaque(false); 240 setFont(AquaFonts.getDockIconFont()); 241 242 final FontMetrics metrics = getFontMetrics(getFont()); 243 setSize(SwingUtilities.computeStringWidth(metrics, getText()) + ROUND_ADDITIONAL_WIDTH * 2, metrics.getAscent() + NUB_HEIGHT + ROUND_ADDITIONAL_HEIGHT); 244 } 245 246 public void paint(final Graphics g) { 247 final int width = getWidth(); 248 final int height = getHeight(); 249 250 final Font font = getFont(); 251 final FontMetrics metrics = getFontMetrics(font); 252 g.setFont(font); 253 254 final String text = getText().trim(); | 212 } 213 214 final ImageIcon prev = (ImageIcon)getIcon(); 215 final ImageIcon pressedIcon = new ImageIcon(AquaUtils.generateSelectedDarkImage(prev.getImage())); 216 setIcon(pressedIcon); 217 super.paint(g); 218 setIcon(prev); 219 } 220 221 boolean mouseInIcon(final MouseEvent e) { 222 return getBounds().contains(e.getX(), e.getY()); 223 } 224 225 public Dimension getPreferredSize() { 226 return new Dimension(64, 64); //$ Dock preferred size 227 } 228 } 229 230 @SuppressWarnings("serial") // Superclass is not serializable across versions 231 class DockLabel extends JLabel { 232 static final int NUB_HEIGHT = 7; 233 static final int ROUND_ADDITIONAL_HEIGHT = 8; 234 static final int ROUND_ADDITIONAL_WIDTH = 12; 235 236 DockLabel(final String text) { 237 super(text); 238 setBorder(null); 239 setOpaque(false); 240 setFont(AquaFonts.getDockIconFont()); 241 242 final FontMetrics metrics = getFontMetrics(getFont()); 243 setSize(SwingUtilities.computeStringWidth(metrics, getText()) + ROUND_ADDITIONAL_WIDTH * 2, metrics.getAscent() + NUB_HEIGHT + ROUND_ADDITIONAL_HEIGHT); 244 } 245 246 public void paint(final Graphics g) { 247 final int width = getWidth(); 248 final int height = getHeight(); 249 250 final Font font = getFont(); 251 final FontMetrics metrics = getFontMetrics(font); 252 g.setFont(font); 253 254 final String text = getText().trim(); |