46 |
import javax.swing.Icon; |
import javax.swing.Icon; |
47 |
import javax.swing.JCheckBox; |
import javax.swing.JCheckBox; |
48 |
import javax.swing.JCheckBoxMenuItem; |
import javax.swing.JCheckBoxMenuItem; |
49 |
|
import javax.swing.JFileChooser; |
50 |
import javax.swing.JInternalFrame; |
import javax.swing.JInternalFrame; |
51 |
import javax.swing.JRadioButton; |
import javax.swing.JRadioButton; |
52 |
import javax.swing.JRadioButtonMenuItem; |
import javax.swing.JRadioButtonMenuItem; |
138 |
} |
} |
139 |
|
|
140 |
/** |
/** |
141 |
|
* An icon used for the "detail view" button on a {@link JFileChooser} under |
142 |
|
* the {@link MetalLookAndFeel}. |
143 |
|
* |
144 |
|
* @see MetalIconFactory#getFileChooserDetailViewIcon() |
145 |
|
*/ |
146 |
|
private static class FileChooserDetailViewIcon |
147 |
|
implements Icon, Serializable { |
148 |
|
|
149 |
|
/** |
150 |
|
* Creates a new icon. |
151 |
|
*/ |
152 |
|
public FileChooserDetailViewIcon() |
153 |
|
{ |
154 |
|
} |
155 |
|
|
156 |
|
/** |
157 |
|
* Returns the width of the icon, in pixels. |
158 |
|
* |
159 |
|
* @return The width of the icon. |
160 |
|
*/ |
161 |
|
public int getIconWidth() |
162 |
|
{ |
163 |
|
return 18; |
164 |
|
} |
165 |
|
|
166 |
|
/** |
167 |
|
* Returns the height of the icon, in pixels. |
168 |
|
* |
169 |
|
* @return The height of the icon. |
170 |
|
*/ |
171 |
|
public int getIconHeight() |
172 |
|
{ |
173 |
|
return 18; |
174 |
|
} |
175 |
|
|
176 |
|
/** |
177 |
|
* Paints the icon using colors from the {@link MetalLookAndFeel}. |
178 |
|
* |
179 |
|
* @param c the component (ignored). |
180 |
|
* @param g the graphics device. |
181 |
|
* @param x the x-coordinate for the top-left of the icon. |
182 |
|
* @param y the y-coordinate for the top-left of the icon. |
183 |
|
*/ |
184 |
|
public void paintIcon(Component c, Graphics g, int x, int y) |
185 |
|
{ |
186 |
|
Color savedColor = g.getColor(); |
187 |
|
g.setColor(MetalLookAndFeel.getBlack()); |
188 |
|
|
189 |
|
// file 1 outline |
190 |
|
g.drawLine(x + 2, y + 2, x + 5, y + 2); |
191 |
|
g.drawLine(x + 6, y + 3, x + 6, y + 7); |
192 |
|
g.drawLine(x + 2, y + 7, x + 6, y + 7); |
193 |
|
g.drawLine(x + 2, y + 2, x + 2, y + 7); |
194 |
|
|
195 |
|
// file 2 outline |
196 |
|
g.drawLine(x + 2, y + 10, x + 5, y + 10); |
197 |
|
g.drawLine(x + 6, y + 11, x + 6, y + 15); |
198 |
|
g.drawLine(x + 2, y + 15, x + 6, y + 15); |
199 |
|
g.drawLine(x + 2, y + 10, x + 2, y + 15); |
200 |
|
|
201 |
|
// detail lines |
202 |
|
g.drawLine(x + 8, y + 5, x + 15, y + 5); |
203 |
|
g.drawLine(x + 8, y + 13, x + 15, y + 13); |
204 |
|
|
205 |
|
// fill files |
206 |
|
g.setColor(MetalLookAndFeel.getPrimaryControl()); |
207 |
|
g.fillRect(x + 3, y + 3, 3, 4); |
208 |
|
g.fillRect(x + 3, y + 11, 3, 4); |
209 |
|
|
210 |
|
// highlight files |
211 |
|
g.setColor(MetalLookAndFeel.getPrimaryControlHighlight()); |
212 |
|
g.drawLine(x + 4, y + 4, x + 4, y + 5); |
213 |
|
g.drawLine(x + 4, y + 12, x + 4, y + 13); |
214 |
|
|
215 |
|
g.setColor(savedColor); |
216 |
|
} |
217 |
|
} |
218 |
|
|
219 |
|
/** |
220 |
|
* An icon used for the "home folder" button on a {@link JFileChooser} under |
221 |
|
* the {@link MetalLookAndFeel}. |
222 |
|
* |
223 |
|
* @see MetalIconFactory#getFileChooserHomeFolderIcon() |
224 |
|
*/ |
225 |
|
private static class FileChooserHomeFolderIcon |
226 |
|
implements Icon, Serializable { |
227 |
|
|
228 |
|
/** |
229 |
|
* Creates a new icon. |
230 |
|
*/ |
231 |
|
public FileChooserHomeFolderIcon() |
232 |
|
{ |
233 |
|
} |
234 |
|
|
235 |
|
/** |
236 |
|
* Returns the width of the icon, in pixels. |
237 |
|
* |
238 |
|
* @return The width of the icon. |
239 |
|
*/ |
240 |
|
public int getIconWidth() |
241 |
|
{ |
242 |
|
return 18; |
243 |
|
} |
244 |
|
|
245 |
|
/** |
246 |
|
* Returns the height of the icon, in pixels. |
247 |
|
* |
248 |
|
* @return The height of the icon. |
249 |
|
*/ |
250 |
|
public int getIconHeight() |
251 |
|
{ |
252 |
|
return 18; |
253 |
|
} |
254 |
|
|
255 |
|
/** |
256 |
|
* Paints the icon using colors from the {@link MetalLookAndFeel}. |
257 |
|
* |
258 |
|
* @param c the component (ignored). |
259 |
|
* @param g the graphics device. |
260 |
|
* @param x the x-coordinate for the top-left of the icon. |
261 |
|
* @param y the y-coordinate for the top-left of the icon. |
262 |
|
*/ |
263 |
|
public void paintIcon(Component c, Graphics g, int x, int y) |
264 |
|
{ |
265 |
|
Color savedColor = g.getColor(); |
266 |
|
g.setColor(MetalLookAndFeel.getBlack()); |
267 |
|
|
268 |
|
// roof |
269 |
|
g.drawLine(x + 1, y + 8, x + 8, y + 1); |
270 |
|
g.drawLine(x + 8, y + 1, x + 15, y + 8); |
271 |
|
|
272 |
|
// base of house |
273 |
|
g.drawLine(x + 3, y + 6, x + 3, y + 15); |
274 |
|
g.drawLine(x + 3, y + 15, x + 13, y + 15); |
275 |
|
g.drawLine(x + 13, y + 6, x + 13, y + 15); |
276 |
|
|
277 |
|
// door frame |
278 |
|
g.drawLine(x + 6, y + 9, x + 6, y + 15); |
279 |
|
g.drawLine(x + 6, y + 9, x + 10, y + 9); |
280 |
|
g.drawLine(x + 10, y + 9, x + 10, y + 15); |
281 |
|
|
282 |
|
// chimney |
283 |
|
g.drawLine(x + 11, y + 2, x + 11, y + 4); |
284 |
|
g.drawLine(x + 12, y + 2, x + 12, y + 5); |
285 |
|
|
286 |
|
g.setColor(MetalLookAndFeel.getControlDarkShadow()); |
287 |
|
|
288 |
|
// roof paint |
289 |
|
int xx = x + 8; |
290 |
|
for (int i = 0; i < 4; i++) |
291 |
|
g.drawLine(xx - i, y + 2 + i, xx + i, y + 2 + i); |
292 |
|
g.fillRect(x + 4, y + 6, 9, 2); |
293 |
|
|
294 |
|
// door knob |
295 |
|
g.drawLine(x + 9, y + 12, x + 9, y + 12); |
296 |
|
|
297 |
|
// house paint |
298 |
|
g.setColor(MetalLookAndFeel.getPrimaryControl()); |
299 |
|
g.drawLine(x + 4, y + 8, x + 12, y + 8); |
300 |
|
g.fillRect(x + 4, y + 9, 2, 6); |
301 |
|
g.fillRect(x + 11, y + 9, 2, 6); |
302 |
|
|
303 |
|
g.setColor(savedColor); |
304 |
|
} |
305 |
|
} |
306 |
|
|
307 |
|
/** |
308 |
|
* An icon used for the "list view" button on a {@link JFileChooser} under |
309 |
|
* the {@link MetalLookAndFeel}. |
310 |
|
* |
311 |
|
* @see MetalIconFactory#getFileChooserListViewIcon() |
312 |
|
*/ |
313 |
|
private static class FileChooserListViewIcon implements Icon, Serializable |
314 |
|
{ |
315 |
|
/** |
316 |
|
* Creates a new icon. |
317 |
|
*/ |
318 |
|
public FileChooserListViewIcon() |
319 |
|
{ |
320 |
|
} |
321 |
|
|
322 |
|
/** |
323 |
|
* Returns the width of the icon, in pixels. |
324 |
|
* |
325 |
|
* @return The width of the icon. |
326 |
|
*/ |
327 |
|
public int getIconWidth() |
328 |
|
{ |
329 |
|
return 18; |
330 |
|
} |
331 |
|
|
332 |
|
/** |
333 |
|
* Returns the height of the icon, in pixels. |
334 |
|
* |
335 |
|
* @return The height of the icon. |
336 |
|
*/ |
337 |
|
public int getIconHeight() |
338 |
|
{ |
339 |
|
return 18; |
340 |
|
} |
341 |
|
|
342 |
|
/** |
343 |
|
* Paints the icon using colors from the {@link MetalLookAndFeel}. |
344 |
|
* |
345 |
|
* @param c the component (ignored). |
346 |
|
* @param g the graphics device. |
347 |
|
* @param x the x-coordinate for the top-left of the icon. |
348 |
|
* @param y the y-coordinate for the top-left of the icon. |
349 |
|
*/ |
350 |
|
public void paintIcon(Component c, Graphics g, int x, int y) |
351 |
|
{ |
352 |
|
Color savedColor = g.getColor(); |
353 |
|
g.setColor(MetalLookAndFeel.getBlack()); |
354 |
|
|
355 |
|
// file 1 outline |
356 |
|
g.drawLine(x + 2, y + 2, x + 5, y + 2); |
357 |
|
g.drawLine(x + 6, y + 3, x + 6, y + 7); |
358 |
|
g.drawLine(x + 2, y + 7, x + 6, y + 7); |
359 |
|
g.drawLine(x + 2, y + 2, x + 2, y + 7); |
360 |
|
|
361 |
|
// file 2 outline |
362 |
|
g.drawLine(x + 2, y + 10, x + 5, y + 10); |
363 |
|
g.drawLine(x + 6, y + 11, x + 6, y + 15); |
364 |
|
g.drawLine(x + 2, y + 15, x + 6, y + 15); |
365 |
|
g.drawLine(x + 2, y + 10, x + 2, y + 15); |
366 |
|
|
367 |
|
// file 3 outline |
368 |
|
g.drawLine(x + 10, y + 2, x + 13, y + 2); |
369 |
|
g.drawLine(x + 14, y + 3, x + 14, y + 7); |
370 |
|
g.drawLine(x + 10, y + 7, x + 14, y + 7); |
371 |
|
g.drawLine(x + 10, y + 2, x + 10, y + 7); |
372 |
|
|
373 |
|
// file 4 outline |
374 |
|
g.drawLine(x + 10, y + 10, x + 13, y + 10); |
375 |
|
g.drawLine(x + 14, y + 11, x + 14, y + 15); |
376 |
|
g.drawLine(x + 10, y + 15, x + 14, y + 15); |
377 |
|
g.drawLine(x + 10, y + 10, x + 10, y + 15); |
378 |
|
|
379 |
|
g.drawLine(x + 8, y + 5, x + 8, y + 5); |
380 |
|
g.drawLine(x + 8, y + 13, x + 8, y + 13); |
381 |
|
g.drawLine(x + 16, y + 5, x + 16, y + 5); |
382 |
|
g.drawLine(x + 16, y + 13, x + 16, y + 13); |
383 |
|
|
384 |
|
// fill files |
385 |
|
g.setColor(MetalLookAndFeel.getPrimaryControl()); |
386 |
|
g.fillRect(x + 3, y + 3, 3, 4); |
387 |
|
g.fillRect(x + 3, y + 11, 3, 4); |
388 |
|
g.fillRect(x + 11, y + 3, 3, 4); |
389 |
|
g.fillRect(x + 11, y + 11, 3, 4); |
390 |
|
|
391 |
|
// highlight files |
392 |
|
g.setColor(MetalLookAndFeel.getPrimaryControlHighlight()); |
393 |
|
g.drawLine(x + 4, y + 4, x + 4, y + 5); |
394 |
|
g.drawLine(x + 4, y + 12, x + 4, y + 13); |
395 |
|
g.drawLine(x + 12, y + 4, x + 12, y + 5); |
396 |
|
g.drawLine(x + 12, y + 12, x + 12, y + 13); |
397 |
|
|
398 |
|
g.setColor(savedColor); |
399 |
|
} |
400 |
|
} |
401 |
|
|
402 |
|
/** |
403 |
|
* An icon used for the "new folder" button on a {@link JFileChooser} under |
404 |
|
* the {@link MetalLookAndFeel}. |
405 |
|
* |
406 |
|
* @see MetalIconFactory#getFileChooserNewFolderIcon() |
407 |
|
*/ |
408 |
|
private static class FileChooserNewFolderIcon |
409 |
|
implements Icon, Serializable |
410 |
|
{ |
411 |
|
/** |
412 |
|
* Creates a new icon. |
413 |
|
*/ |
414 |
|
public FileChooserNewFolderIcon() |
415 |
|
{ |
416 |
|
} |
417 |
|
|
418 |
|
/** |
419 |
|
* Returns the width of the icon, in pixels. |
420 |
|
* |
421 |
|
* @return The width of the icon. |
422 |
|
*/ |
423 |
|
public int getIconWidth() |
424 |
|
{ |
425 |
|
return 18; |
426 |
|
} |
427 |
|
|
428 |
|
/** |
429 |
|
* Returns the height of the icon, in pixels. |
430 |
|
* |
431 |
|
* @return The height of the icon. |
432 |
|
*/ |
433 |
|
public int getIconHeight() |
434 |
|
{ |
435 |
|
return 18; |
436 |
|
} |
437 |
|
|
438 |
|
/** |
439 |
|
* Paints the icon using colors from the {@link MetalLookAndFeel}. |
440 |
|
* |
441 |
|
* @param c the component (ignored). |
442 |
|
* @param g the graphics device. |
443 |
|
* @param x the x-coordinate for the top-left of the icon. |
444 |
|
* @param y the y-coordinate for the top-left of the icon. |
445 |
|
*/ |
446 |
|
public void paintIcon(Component c, Graphics g, int x, int y) |
447 |
|
{ |
448 |
|
Color savedColor = g.getColor(); |
449 |
|
g.setColor(MetalLookAndFeel.getBlack()); |
450 |
|
|
451 |
|
g.drawLine(x + 2, y + 5, x + 9, y + 5); |
452 |
|
g.drawLine(x + 10, y + 6, x + 15, y + 6); |
453 |
|
g.drawLine(x + 15, y + 5, x + 15, y + 14); |
454 |
|
g.drawLine(x + 2, y + 14, x + 15, y + 14); |
455 |
|
g.drawLine(x + 1, y + 6, x + 1, y + 14); |
456 |
|
|
457 |
|
g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); |
458 |
|
g.drawLine(x + 11, y + 3, x + 15, y + 3); |
459 |
|
g.drawLine(x + 10, y + 4, x + 15, y + 4); |
460 |
|
|
461 |
|
g.setColor(MetalLookAndFeel.getPrimaryControl()); |
462 |
|
g.fillRect(x + 3, y + 7, 7, 7); |
463 |
|
g.fillRect(x + 10, y + 8, 5, 6); |
464 |
|
g.drawLine(x + 10, y + 5, x + 14, y + 5); |
465 |
|
|
466 |
|
g.setColor(MetalLookAndFeel.getPrimaryControlHighlight()); |
467 |
|
g.drawLine(x + 10, y + 7, x + 14, y + 7); |
468 |
|
g.drawLine(x + 2, y + 6, x + 9, y + 6); |
469 |
|
g.drawLine(x + 2, y + 6, x + 2, y + 13); |
470 |
|
g.setColor(savedColor); |
471 |
|
} |
472 |
|
} |
473 |
|
|
474 |
|
/** |
475 |
|
* An icon used for the "up folder" button on a {@link JFileChooser} under |
476 |
|
* the {@link MetalLookAndFeel}. |
477 |
|
* |
478 |
|
* @see MetalIconFactory#getFileChooserNewFolderIcon() |
479 |
|
*/ |
480 |
|
private static class FileChooserUpFolderIcon |
481 |
|
extends FileChooserNewFolderIcon |
482 |
|
implements Icon, Serializable |
483 |
|
{ |
484 |
|
/** |
485 |
|
* Creates a new icon. |
486 |
|
*/ |
487 |
|
public FileChooserUpFolderIcon() |
488 |
|
{ |
489 |
|
} |
490 |
|
|
491 |
|
/** |
492 |
|
* Paints the icon using colors from the {@link MetalLookAndFeel}. |
493 |
|
* |
494 |
|
* @param c the component (ignored). |
495 |
|
* @param g the graphics device. |
496 |
|
* @param x the x-coordinate for the top-left of the icon. |
497 |
|
* @param y the y-coordinate for the top-left of the icon. |
498 |
|
*/ |
499 |
|
public void paintIcon(Component c, Graphics g, int x, int y) |
500 |
|
{ |
501 |
|
Color savedColor = g.getColor(); |
502 |
|
|
503 |
|
// draw the folder |
504 |
|
super.paintIcon(c, g, x, y); |
505 |
|
|
506 |
|
// now draw the up arrow |
507 |
|
g.setColor(MetalLookAndFeel.getBlack()); |
508 |
|
g.drawLine(x + 8, y + 9, x + 8, y + 16); |
509 |
|
int xx = x + 8; |
510 |
|
for (int i = 0; i < 4; i++) |
511 |
|
g.drawLine(xx - i, y + 9 + i, xx + i, y + 9 + i); |
512 |
|
g.setColor(savedColor); |
513 |
|
} |
514 |
|
} |
515 |
|
|
516 |
|
/** |
517 |
* An icon representing a file (drawn as a piece of paper with the top-right |
* An icon representing a file (drawn as a piece of paper with the top-right |
518 |
* corner turned down). |
* corner turned down). |
519 |
*/ |
*/ |
1765 |
} |
} |
1766 |
|
|
1767 |
/** |
/** |
1768 |
|
* Returns an icon for use by the {@link JFileChooser} component. |
1769 |
|
* |
1770 |
|
* @return An icon. |
1771 |
|
*/ |
1772 |
|
public static Icon getFileChooserDetailViewIcon() |
1773 |
|
{ |
1774 |
|
return new FileChooserDetailViewIcon(); |
1775 |
|
} |
1776 |
|
|
1777 |
|
/** |
1778 |
|
* Returns an icon for use by the {@link JFileChooser} component. |
1779 |
|
* |
1780 |
|
* @return An icon. |
1781 |
|
*/ |
1782 |
|
public static Icon getFileChooserHomeFolderIcon() |
1783 |
|
{ |
1784 |
|
return new FileChooserHomeFolderIcon(); |
1785 |
|
} |
1786 |
|
|
1787 |
|
/** |
1788 |
|
* Returns an icon for use by the {@link JFileChooser} component. |
1789 |
|
* |
1790 |
|
* @return An icon. |
1791 |
|
*/ |
1792 |
|
public static Icon getFileChooserListViewIcon() |
1793 |
|
{ |
1794 |
|
return new FileChooserListViewIcon(); |
1795 |
|
} |
1796 |
|
|
1797 |
|
/** |
1798 |
|
* Returns an icon for use by the {@link JFileChooser} component. |
1799 |
|
* |
1800 |
|
* @return An icon. |
1801 |
|
*/ |
1802 |
|
public static Icon getFileChooserNewFolderIcon() |
1803 |
|
{ |
1804 |
|
return new FileChooserNewFolderIcon(); |
1805 |
|
} |
1806 |
|
|
1807 |
|
/** |
1808 |
|
* Returns an icon for use by the {@link JFileChooser} component. |
1809 |
|
* |
1810 |
|
* @return An icon. |
1811 |
|
*/ |
1812 |
|
public static Icon getFileChooserUpFolderIcon() |
1813 |
|
{ |
1814 |
|
return new FileChooserUpFolderIcon(); |
1815 |
|
} |
1816 |
|
/** |
1817 |
* Returns an icon for RadioButtons in the Metal L&F. |
* Returns an icon for RadioButtons in the Metal L&F. |
1818 |
* |
* |
1819 |
* @return an icon for RadioButtons in the Metal L&F |
* @return an icon for RadioButtons in the Metal L&F |