v
Contents
Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Chapter 1. Basic JComponents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1. Create Image-Themed Components 1
2. Don’t Settle for Boring Text Labels 8
3. Fill Your Borders with Pretty Pictures 14
4. Display Dates in a Custom Calendar 19
5. Add a Watermark to a Text Component 23
6. Watermark Your Scroll Panes 26
7. Put a NASA Photo into the Background of a Text Area 29
8. Animate Transitions Between Tabs 32
9. Blur Disabled Components 39
10. Building a Drop-Down Menu Button 43
11. Create Menus with Drop Shadows 49
12. Add Translucence to Menus 52
Chapter 2. Lists and Combos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
13. Filter JLists 58
14. Add a Filter History 63
15. Make JLists Checkable 66
16. Make Different List Items Look Different 70
17. Reorder a JList with Drag-and-Drop 80
18. Animate Your JList Selections 87
vi
|
Contents
19. Turn Methods into List Renderers 92
20. Create a Collections-Aware JComboBox 95
Chapter 3. Tables and Trees
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
21. Size Your Columns to Suit Your JTable’s Contents 102
22. Add Column Selection to JTables 107
23. Let Your JTables Do the Sorting 110
24. Create a JDBC Table Model 122
25. Export Table Data to an Excel Spreadsheet 130
26. Search Through JTables Easily 133
27. Animate JTree Drops 139
Chapter 4. File Choosers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
28. Add a Right-Click Context Menu to the JFileChooser 149
29. Display Shortcuts in the JFileChooser 154
30. Real Windows Shortcut Support 158
31. Add Image Preview to File Choosers 164
32. Preview ZIP and JAR Files 167
Chapter 5. Windows, Dialogs, and Frames . . . . . . . . . . . . . . . . . . . . . . . . . . 175
33. Window Snapping 175
34. Make a Draggable Window 178
35. Add Windows Resize Icons 181
36. Add Status Bars to Windows 187
37. Save Window Settings 193
38. Earthquake Dialog 197
39. Spin Open a Detail Pane 202
40. Minimize to a Mini-Frame 207
Chapter 6. Transparent and Animated Windows . . . . . . . . . . . . . . . . . . . . . 213
41. Transparent Windows 213
42. Make Your Frame Dissolve 219
43. Create Custom Tool Tips 225
44. Turn Dialogs into Frame-Anchored Sheets 228
45. Animating a Sheet Dialog 233
46. Slide Notes Out from the Taskbar 240
47. Indefinite Progress Indicator 247

Get Swing Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.