The Eclipse platform continues to gain tremendous popularity as both a Java IDE and a Java platform for application programming. One of the core underpinnings of Eclipse is SWT, the Standard Widget Toolkit. This set of components can be used to develop graphical user interfaces in Java,and offer a native-code alternative to Java's Swing and AWT components. Incorporating the look and feel of whatever platform the code is run on, SWT offers a lightning-fast approach to building GUIs, all of which actually look like they belong on the platform on which they are run.
But you already know what you want to do--so wading through the basics of user interface design, graphical components, and what a button does is simply a waste of time. Enter SWT: A Developer's Notebook. In typical Developer's Notebook style, you'll learn how to take SWT out for a spin, make it work for you, and turn it upside down, all without wasted words or space. Each lab in this notebook details a specific task; you can read from the first page to the last, look up just what you need to know, and even squeeze this book into your laptop bag as a quick reference when you forget how to create a multi-tabbed view.
This book covers:
Downloading and configuring Eclipse and SWT
Menus, toolbars, and buttons
Building tabbed layouts and folders
SWT's unique coolbar control
Adding listeners and responding to events
Building a complete SWT-based application
Chapter 1 Getting Started
Downloading the SWT Library
Configuring Eclipse for SWT Development
Supplying the SWT Package to the Java Compiler
Specifying the Location of the Native Library
Using swt.jar in Multiple Projects
Chapter 2 SWT Shells
Creating a Simple Shell
Executing the Example
Working with Shell Styles
Creating a Shell Styles Example
Creating Child Shells
Creating Multiple Child Windows
Opening True Dialogs
Setting the Shell Title Text
Setting the Shell Icon
Chapter 3 SWT Menus
Creating the Menu Bar
Adding Drop-Down Menus
Adding Separator Bars
Creating a Complete Menu System
Adding Cascading Submenus
Making Menus Perform the Intended Action
Working with Other Menu Item Styles
Determining the State of CHECK and RADIO Menu Items
Adding Keyboard Shortcuts
Creating Pop-Up Menus
Chapter 4 SWT Toolbars
Creating the Toolbar
Creating Toolbar Buttons
Creating a Complete Toolbar Example
Making the Buttons Work—Adding Listeners
Adding Separators to Your Toolbar
Adding Check and Radio ToolItems
Determining Whether a Check or Radio Button Is Selected
Using Tool Tips
Chapter 5 SWT Text Fields
Adding Text Fields to a Shell
Adding a Border to a Text Field
Positioning the Text Field
Setting the Tab Order
Setting the Text Size Limit
Interacting with the Text in the Text Widget
Populating Text Fields from a Database
Appending Text to a Text Field’s Contents
Creating Multiline Text Fields
Wrapping Text
Adding Scrollbars
Reacting to Text Events
Performing Field Validation
Creating Display-Only Text Fields
Creating Password Fields
Chapter 6 SWT Buttons
Creating Push-Style Buttons
Responding to Button Clicks
Creating Check Buttons
Determining CHECK Button Status
Adding Listeners to CHECK Buttons
Using Radio-Style Buttons
Causing No Radio Button to be Selected
Creating Toggle Buttons
Determining the State of a Toggle Button
Creating Arrow Buttons
Using Images with Buttons
Setting Tool-Tip Text
Enabling and Disabling Buttons
Chapter 7 SWT Lists
Creating a List
Adding Items to a List
Inserting Items in the Middle of a List
Populating a List from a Database
Removing Items from a List
Determining the Selected Items
Determining the Selected Item with Multiple Selections
Causing an Item to Appear Selected
Changing an Item’s Text Value
Adding Scrollbars to a List
Chapter 8 The SWT Combo
Creating a Combo List
Adding Items to a Combo List
Creating a Working Combo List
Getting the Value of the Selected Item
Programmatically Selecting an Item
Removing Items from a Combo List
Adding Events to Combo Widgets
Allowing Additions to the Combo List
Getting and Setting Text in the Text Portion of the Combo
Setting the Maximum Length for Entries
Deselecting Text
Responding to Item Changes in the Combo
Using the SIMPLE Style
Chapter 9 SWT Layouts
What Are the SWT Layouts?
Attaching a Layout to a Container
Filling the Entire Container with Widgets
Changing Widget Placement in FillLayouts
Lining Up Widgets Using RowLayout
Controlling Wrapping of Widgets with RowLayout
Controlling Sizing of Widgets with RowLayout
Creating Vertical Rows
Creating a GridLayout
Creating Column Headings
Controlling Widget Sizing and Alignment
Forcing Widgets to Span Multiple Cells
The SWT FormLayout
Creating a Simple Password Entry Form
Chapter 10 SWT Composites and Groups
Subclassing the Composite Class
Using the TextPaneComposite Class on a Shell
Using Composite Class Styles
Using the Group Class
Creating Multiple Instances of a Composite Subclass
Tim Hatton is the President of Millennium Learning Technologies, a company specializing in the custom design of IT courseware and learning methodologies. He has taught courses to developers at IBM, Lockheed-Martin, LexisNexis and other Fortune 500 technology companies. Additionally, he has developed applications for these, and other companies, using a wide variety of tools from PowerBuilder to Java. Tim has a BA in Political Science from Wright State University and a JD from the University of Dayton School of Law and was a practicing attorney in a prior life.
Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The Developer's Notebook series is modeled on the tradition of laboratory notebooks. Laboratory notebooks are an invaluable tool for researchers and their successors.
The purpose of a laboratory notebook is to facilitate the recording of data and conclusions as the work is being conducted, creating a faithful and immediate history. The notebook begins with a title page that includes the owner's name and the subject of research. The pages of the notebook should be numbered and prefaced with a table of contents. Entries must be clear, easy to read, and accurately dated; they should use simple, direct language to indicate the name of the experiment and the steps taken. Calculations are written out carefully and relevant thoughts and ideas recorded. Each experiment is introduced and summarized as it is added to the notebook. The goal is to produce comprehensive, clearly organized notes that can be used as a reference. Careful documentation creates a valuable record and provides a practical guide for future developers. Jamie Peppard was the production editor and the proofreader for SWT: A Developer's Notebook. Audrey Doyle was the copyeditor. Mary Agner provided production assistance. Sarah Sherman and Claire Cloutier provided quality control. Ellen Troutman wrote the index.
Edie Freedman designed the cover of this book. Clay Fernald produced the cover layout with QuarkXPress 4.1 using the Officina Sans and JuniorHandwriting fonts.
David Futato designed the interior layout, with contributions from Edie Freedman. This book was converted by Julie Hawks to FrameMaker 5.5.6 with a format conversion tool created by Erik Ray, Jason McIntosh, Neil Walls, and Mike Sierra that uses Perl and XML technologies.
The text font is Adobe Boton; the heading font is ITC Officina Sans; the code font is LucasFont's TheSans Mono Condensed, and the handwriting font is a modified version of JuniorHandwriting made by Tepid Monkey Foundry and modified by O'Reilly. The illustrations that appear in the book were produced by Robert Romano and Jessamyn Read using Macromedia FreeHand 9 and Adobe Photoshop 6. This colophon was written by Colleen Gorman.
Comments about oreilly SWT: A Developer's Notebook:
I have just learned SWT in an afternoon from this book, but did have the advantage of being reasonably proficient with Swing. I was provoked to write a review as I thought that one of th existing reviews was unfair in saying that the code examples did not work. I was happy to provide my own ico files etc. and would not have expected these to be provided by the author, and the examples worked for me. I typed them into an Eclipse IDE rather than downloading them from the O'Reilly site.
I then checked out where SWT is today and there are now quite a few more widgets than described in the book, but at least I came away with a new skill set in a remarkably short time and I am grateful to Tim Hatton for that.
8/24/2006
4.0
Great
By Anonymous
from Undisclosed
Comments about oreilly SWT: A Developer's Notebook:
I tried this book while being a novice on both Java and SWT. I found it great to design quicly IHM. I understand that Java expert may be disapointed by this book, but if you are a novice and want to go quicly on designing SWT... this is the book
10/10/2005
2.0
Disappointing
By JavaCoder
from Undisclosed
Comments about oreilly SWT: A Developer's Notebook:
Very disappointed.
The included code doesn't all work for two reasons
1) basic code flaws that the compiler flags, and once you fix these, 2) none of the graphics (ico) files needed to run many of the examples are included in the companion files on the web site.
Hard for a relative newbie to Eclipse and the SWT to learn when these obstacles are encountered.
All in all, as it stands, this book is extremely frustrating and a waste of money.
If the code and graphics problems were fixed, it could be a great book.
3/8/2005
(0 of 1 customers found this review helpful)
1.0
Author is incredible blithering
By Pico
from Undisclosed
Comments about oreilly SWT: A Developer's Notebook:
Series creator promising reader is learning something from a master, but all I can see is he repeat telling you how to create a widget with almost same sentance.
Author is repeat same task using same clause over and over again.
He using boring words with no insignt to reapeat same thing over and over again.
You can find author is bang on same topic (how to create widget instance to add to the shell) over and over again.
Reader will see author is repeat...do you see some pattern here? I see the same thing happen on this poor written book too.
I'm very disappoint about this book and feel sorry to the author-you spent 300 pages to discuss only one thing: how to create widget instance and add to the shell, aren't you?
10/31/2004
3.0
It's a notebook alright, where's the rest of it ?
By marcelol
from Undisclosed
Comments about oreilly SWT: A Developer's Notebook:
It's a little difficult to place this book. I came away with the sense that while the goals were well intentioned, and the coverage of SWT itself left me feeling a little...wanting.
The ordering of the chapters were a little hop-scotched. While "Shells" are a good place to start, and menu's are a logical follow-on, jumping to toolbars as the third chapter does, leaves you with a feeling of "Huh?". I think the layout chapter should've come much earlier in the book, perhaps after introducing a couple of the more basic controls.
Before even discussing shells, I think a bit more introduction on a couple of topics was warranted. Since these topics have more to do with Eclipse than SWT, I ask your indulgence. While you CAN develop for SWT without Eclipse, frankly how many of us don't take maximum advantage of the facilities of the IDE's to do much of the tedium in creating the infrastrcture of our projects. This is where the SWT Developer's Notebook falls a little short.
Yes, to the purist, thinking of the "Notebook" series as being a sequence of notes and clear cut examples for how to do things, this might sound like a departure from the intended form. But, it's one that I think would've been well suited here. As an example, I point out the Eclipse Cookbook ( also from O'Reilly press, released just a few months ago ), which does go into this topic, if not in depth, just enough to help the novice get going. It's not like there was NO information, but rather that what little there was ; was just plain disjointed. Sure, it's nice to be shown how you can have the path to the SWT jar's to the libraries added to your build libraries ( and the where the SWT DLL's are for the classpath ), but there's no mention of how to kickstart your first SWT project.
There was also simply NO mention of any of the available visual editors: Jigloo by CloudGarden, SWT Designer by Instantiations, SWT Workbench, and the Eclipse Project's own Visual Editor, most of which have been around for quite a while. Some Java purists will surely decry, "I do my UI in code, by hand". Apparently those dinosaurs haven't
been exposed to other RAD-based development environments ( or they're simply not doing that much UI-based work ). However, for those who are, and have been, having a UI design tool these days, is almost indispensible. Sure, this book isn't meant to be an ad for any of those products, but since this book is about the UI library provided by Eclipse, it bore mentioning.
I also felt strongly that anyone who wants to make use of the samples in this book, should've had a them available for download. As of writing of this review ( 10/31/2004 ), they're still not up on the O'Reilly site.
Now that I've thrashed about those points that I didn't like, let me tell you what I did like. I likes that the chapters, in and of themselves, were streamlined, and not full of fluff. The examples were succcinct and to the point.
This Developer's Notebook ( of the three that I own so far, the Mono Developers Notebook, and Tiger 1.5 Java Notebook being the other two ) is the only one that left me with the feeling of a spy novel that leaves you wanting. It's a good start for a series, and I think it's laid down reasonable ground to develop an "SWT Developer's Second Notebook". Topics as the custom controls library ( and a little JFACE wouldn't hurt ), such as the TableTree, CLabel, and CCombo controls, just to name a few, come to mind. Another area just waiting to be explored is the interopability layer built into SWT ( SWT_AWT ) which allows you to embed SWING/SWT controls, within an SWT composite ( also briefly discussed in the Eclipse Cookbook ). Perhaps the authors will consider this, and expand this series. In summary, it's a good primer despite it's rough edges, let's just hope there's a sequel.