Synopses & Reviews
Swing Hacks helps Java developers move beyond the basics of Swing, the graphical user interface (GUI) standard since Java 2. If you're a Java developer looking to build enterprise applications with a first-class look and feel, Swing is definitely one skill you need to master. This latest title from O'Reilly is a reference to the cool stuff in Swing. It's about the interesting things you learn over the years--creative, original, even weird hacks--the things that make you say, "I didn't know you could even do that with Swing!"Swing Hacks will show you how to extend Swing's rich component set in advanced and sometimes non-obvious ways. The book touches upon the entire Swing gamut-tables, trees, sliders, spinners, progress bars, internal frames, and text components. Detail is also provided on JTable/JTree, threaded component models, and translucent windows. You'll learn how to filter lists, power-up trees and tables, and add drag-and-drop support.Swing Hacks will show you how to do fun things that will directly enhance your own applications. Some are visual enhancements to make your software look better. Some are functional improvements to make your software do something it couldn't do before. Some are even just plain silly, in print only to prove it could be done. The book will also give you give you a small glimpse of the applications coming in the future. New technology is streaming into the Java community at a blistering rate, and it gives application developers a whole new set of blocks to play with.With its profusion of tips and tricks, Swing Hacks isn't just for the developer who wants to build a better user interface. It's also ideally suited for client-side Java developers who want to deliver polished applications, enthusiasts who want to push Java client application boundaries, and coders who want to bring powerful techniques to their own applications.Whatever your programming needs, Swing Hacks is packed with programming lessons that increase your competency with interface-building tools.
About the Author
Joshua Marinacci first tried Java in 1995 at the request of his favorite TA and never looked back. He has spent the last fifteen years writing Java user interfaces for wireless, web, and desktop platforms. After co-writing Swing Hacks with Chris Adamson, Joshua spent five years at Sun working on Java user interfaces full-time; contributing to Swing, NetBeans, JavaFX, and the Java Store. Then he explored the mobile web for two years as a developer advocate for webOS and has recently joined Nokia as a researcher. Joshua holds a BS in Computer Science from Georgia Tech and lives in Eugene, Oregon with his wife and baby son.
Chris Adamson is the Associate Online Editor for the O'Reilly web sites ONJava.com and java.net, and is the author of O'Reilly's QuickTime for Java: A Developer's Notebook. His consulting company, Subsequently & Furthermore, Inc., specializes in Java media development. Chris has a BA and BS from Stanford University and an MA from Michigan State University.
Table of Contents
Copyright; Credits; About the Authors; Contributors; Acknowledgments; Preface; Why Swing Hacks?; How to Use This Book; How This Book Is Organized; Conventions Used in This Book; Using Code Examples; How to Contact Us; Got a Hack?; Safari Enabled; Chapter 1: Basic JComponents; 1.1 Hacks 1-12: Introduction; 1 Create Image-Themed Components; 2 Don't Settle for Boring Text Labels; 3 Fill Your Borders with Pretty Pictures; 4 Display Dates in a Custom Calendar; 5 Add a Watermark to a Text Component; 6 Watermark Your Scroll Panes; 7 Put a NASA Photo into the Background of a Text Area; 8 Animate Transitions Between Tabs; 9 Blur Disabled Components; 10 Building a Drop-Down Menu Button; 11 Create Menus with Drop Shadows; 12 Add Translucence to Menus; Chapter 2: Lists and Combos; 2.1 Hacks 13-20: Introduction; 13 Filter JLists; 14 Add a Filter History; 15 Make JLists Checkable; 16 Make Different List Items Look Different; 17 Reorder a JList with Drag-and-Drop; 18 Animate Your JList Selections; 19 Turn Methods into List Renderers; 20 Create a Collections-Aware JComboBox; Chapter 3: Tables and Trees; 3.1 Hacks 21-27: Introduction; 21 Size Your Columns to Suit Your JTable's Contents; 22 Add Column Selection to JTables; 23 Let Your JTables Do the Sorting; 24 Create a JDBC Table Model; 25 Export Table Data to an Excel Spreadsheet; 26 Search Through JTables Easily; 27 Animate JTree Drops; Chapter 4: File Choosers; 4.1 Hacks 28-32: Introduction; 28 Add a Right-Click Context Menu to the JFileChooser; 29 Display Shortcuts in the JFileChooser; 30 Real Windows Shortcut Support; 31 Add Image Preview to File Choosers; 32 Preview ZIP and JAR Files; Chapter 5: Windows, Dialogs, and Frames; 5.1 Hacks 33-40: Introduction; 33 Window Snapping; 34 Make a Draggable Window; 35 Add Windows Resize Icons; 36 Add Status Bars to Windows; 37 Save Window Settings; 38 Earthquake Dialog; 39 Spin Open a Detail Pane; 40 Minimize to a Mini-Frame; Chapter 6: Transparent and Animated Windows; 6.1 Hacks 41-47: Introduction; 41 Transparent Windows; 42 Make Your Frame Dissolve; 43 Create Custom Tool Tips; 44 Turn Dialogs into Frame-Anchored Sheets; 45 Animating a Sheet Dialog; 46 Slide Notes Out from the Taskbar; 47 Indefinite Progress Indicator; Chapter 7: Text; 7.1 Hacks 48-55: Introduction; 48 Make Text Components Searchable; 49 Force Text Input into Specific Formats; 50 Auto-Completing Text Fields; 51 Write Backward Text; 52 Use HTML and CSS in Text Components; 53 Use Global Anti-Aliased Fonts; 54 Anti-Aliased Text Without Code; 55 Anti-Aliased Text with a Custom Look and Feel; Chapter 8: Rendering; 8.1 Hacks 56-64: Introduction; 56 Create a Magnifying Glass Component; 57 Create a Global Right-Click; 58 Block a Window Without a Modal Dialog; 59 Create a Color Eyedropper; 60 Changing Fonts Throughout Your Application; 61 Load New Fonts at Runtime; 62 Build a Colorful Vector-Based Button; 63 Add a Third Dimension to Swing; 64 Turn the Spotlight on Swing; Chapter 9: Drag-and-Drop; 9.1 Hacks 65-69: Introduction; 65 Drag-and-Drop with Files; 66 Handle Dropped URLs; 67 Handle Dropped Images; 68 Handling Dropped Picts on Mac OS X; 69 Translucent Drag-and-Drop; Chapter 10: Audio; 10.1 Hacks 70-78: Introduction; 70 Play a Sound in an Applet; 71 Play a Sound with JavaSound; 72 Play a Sound with Java Media Framework; 73 Play a Sound with QuickTime for Java; 74 Add MP3 Support to JMF; 75 Build an Audio Waveform Display; 76 Play Non-Trivial Audio; 77 Show Audio Information While Playing SoundHack; 78 Provide Audio Controls During Playback; Chapter 11: Native Integration and Packaging; 11.1 Hacks 79-87: Introduction; 79 Launch External Programs on Windows; 80 Open Files, Directories, and URLs on Mac OS X; 81 Make Mac Applications Behave Normally; 82 Control iTunes on Mac OS X; 83 Control iTunes Under Windows; 84 Construct Single-Launch Applications; 85 Stuff Stuff in JARs; 86 Make Quick Look and Feel Changes; 87 Create an Inverse Black-and-White Theme; Chapter 12: Miscellany; 12.1 Hacks 88-100: Introduction; 88 Display a Busy Cursor; 89 Fun with Keyboard Lights; 90 Create Demonstrations with the Robot Class; 91 Check Your Mail with Swing; 92 Don't Block the GUI; 93 Code Models That Don't Block; 94 Fire Events and Stay Bug Free; 95 Debug Your GUI; 96 Debug Components with a Custom Glass Pane; 97 Mirror an Application; 98 Add Velocity for Dynamic HTML; 99 Get Large File Icons; 100 Make Frames Resize Dynamically; Colophon;