0% found this document useful (0 votes)
168 views

Swing

Uploaded by

GEEK 403
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
168 views

Swing

Uploaded by

GEEK 403
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

3/25/2020 Advanced Swing e-book

Home

Advanced Java Swing e-book

The e-book has 621 pages and 206 code examples. The e-book goes quickly to the point and is loaded
with practical examples which focus on one important aspect. Heavy emphasis is placed on clarity and
conciseness. No time is wasted with unimportant digressions. It is an ideal material for those who
already know some basics of Java Swing. The e-book is written in plain English.

The code examples were tested on Linux and Windows. They can be run on JDK 7 and JDK 8. After
purchasing the e-book, you will obtain a ZIP file. In the ZIP file, you will find a PDF file and all code
examples. The code examples are in the form of NetBeans projects.

Once you make a payment, you will also get a confirmation email from Paypal. If something goes wrong
with the payment process, drop me an email at vronskij(at)gmail.com.

Price

The e-book costs 21 €.

About this e-book

This is Advanced Java Swing e-book. This e-book covers advanced parts of the Swing in a great detail.
The complete table of contents is listed at the end of the page.

This e-book is divided into three parts, which contain 12 chapters:

1. Foundations
1.1 Toplevel containers
1.2 Events
1.3 SwingWorker
1.4 Painting
1.5 BufferedImage
1.6 Miscellaneous

2. Layout management
2.1 GroupLayout
2.2 MigLayout

3. Advanced components
3.1 JList
3.2 JTable

zetcode.com/ebooks/advancedjavaswing/ 1/12
3/25/2020 Advanced Swing e-book

3.3 JTree
3.4 Text components

The Foundations part explains six different areas of Swing. The first chapter of the e-book covers Swing
toplevel containers—fundamental components which contain other Swing components. The Events
chapter is an in-depth coverage of the event handling system of Swing. It has 25 examples. The
SwingWorker chapter explains the very important SwingWorker class and provides three detailed
examples. The Painting chapter explains the basics of the painting mechanism. In the BufferedImage
chapter, we show how to work with images in Swing. In the Miscellaneous chapter, we cover various
aspects of Swing, including keyboard handling, compound border, and making a screenshot.

The Layout management part explains the layout management of Swing components. This area is
considered to be one of the most difficult areas of GUI programming. Therefore, the e-book gives
particular emphasis on the layout management process. There are two chapters: GroupLayout manager
and MigLayout manager. These are the most flexible layout managers available for Swing. The chapters
contain many easy to understand practical examples. (GroupLayout 18 examples, MigLayout 41 examples.)

The Advanced components part covers advanced Swing components in a great detail. Plenty of practica
examples explain the JList (14 examples), the JTree (22 examples), the JTable (29 examples), and severa
text components (28 examples).

Screenshots
Here you can see some of the screenshots from the e-book.

Figure: Simple syntax highlighting implemented with a document filter.

Figure: Bracket matching implemented with a caret listener and a highlighter.

zetcode.com/ebooks/advancedjavaswing/ 2/12
3/25/2020 Advanced Swing e-book

Figure: Explaining horizontal and vertical alignments with the MigLayout manager.

Figure: Reading a web page with an ExecutorService.

Figure: Using a SwingWorker to search for files.

zetcode.com/ebooks/advancedjavaswing/ 3/12
3/25/2020 Advanced Swing e-book

Figure: Using a BufferedImage to create a nice spotlight effect.

Figure: Demonstrating the colour palette of the Metal look and feel with the UIManager.

zetcode.com/ebooks/advancedjavaswing/ 4/12
3/25/2020 Advanced Swing e-book

Figure: Sorting items of a JList component.

Figure: Modifying items of a table with the AbstractTableModel.

zetcode.com/ebooks/advancedjavaswing/ 5/12
3/25/2020 Advanced Swing e-book

Figure: Searching for items in a JTree component.

Table of Contents
1. Preface

2. About the author

3. Foundations
3.1 Toplevel containers
3.1.1 JFrame
3.1.2 JLayeredPane
3.1.3 Glass pane
3.1.4 JDialog
3.1.5 JWindow
3.2 Events
3.2.1 Multiple listeners
3.2.2 Multiple sources
3.2.3 EventHandler
3.2.4 Custom event
3.2.5 Observer pattern
3.2.6 Actions
3.2.6.1 Action example
3.2.6.2 Toggle buttons
3.2.7 ActionListener vs ItemListener
3.2.8 Application closing
3.2.9 EventQueue
3.2.10 AWTEventListener
3.2.11 MouseEvent
zetcode.com/ebooks/advancedjavaswing/ 6/12
3/25/2020 Advanced Swing e-book

3.2.11.1 MouseListener
3.2.11.2 Mouse event types
3.2.11.3 MouseAdapter
3.2.12 ItemEvent
3.2.13 PaintEvent
3.2.14 FocusEvent
3.2.14.1 Selecting all text on gaining focus
3.2.14.2 Initial focus
3.2.15 Scheduling tasks
3.2.15.1 Swing timer
3.2.15.2 Utility timer
3.2.15.3 Executor service
3.3 SwingWorker
3.3.1 SplashScreen
3.3.2 Searching images
3.3.3 Supervisor worker
3.4 Painting
3.4.1 The paintComponent() method
3.4.2 Custom icon
3.4.3 Painting into image
3.4.3.1 Grayscale image
3.4.3.2 Component capture
3.4.4 The repaint() method
3.4.4.1 Points
3.4.4.2 Moving circle
3.5 BufferedImage
3.5.1 Grayscale image
3.5.2 Scaling an image
3.5.3 Spotlight
3.5.4 Sun and cloud
3.5.5 Subimage
3.6 Miscellaneous
3.6.1 Keyboard
3.6.1.1 KeyListener
3.6.1.2 Key bindings
3.6.1.3 Mnemonics and accelerators
3.6.2 UIManager
3.6.2.1 Selecting laf
3.6.2.2 Colour palette
3.6.3 Compound border
3.6.4 Custom border
3.6.5 Screen capture
3.6.6 Opaque
3.6.6.1 Difference in meaning
zetcode.com/ebooks/advancedjavaswing/ 7/12
3/25/2020 Advanced Swing e-book

3.6.6.2 Three labels

4. Layout management
4.1 GroupLayout manager
4.1.1 First examples
4.1.1.1 Simple example
4.1.1.2 Simple example 2
4.1.2 Independent dimensions
4.1.2.1 Grid of buttons
4.1.2.2 Grid of buttons 2
4.1.3 Gaps
4.1.3.1 Fixed gaps
4.1.3.2 Automatic gaps
4.1.3.3 Resizable gaps
4.1.4 Indent
4.1.5 Alignments
4.1.5.1 Horizontal alignment
4.1.5.2 Vertical alignment
4.1.5.3 Baseline alignment
4.1.6 Parallel group's size
4.1.7 Practical examples
4.1.7.1 Corner buttons
4.1.7.2 Password
4.1.7.3 Windows
4.1.7.4 Review
4.1.7.5 Go To Class
4.1.7.6 Tags
4.2 MigLayout manager
4.2.1 Grid
4.2.1.1 Cells
4.2.1.2 Horizontal flow mode
4.2.1.3 Vertical flow mode
4.2.1.4 Flow mode in a cell
4.2.1.5 Orientation
4.2.1.6 No grid
4.2.2 Bound size
4.2.2.1 Component size
4.2.2.2 Component size 2
4.2.2.3 Gap size
4.2.3 Constraints
4.2.3.1 Units
4.2.3.2 Insets
4.2.3.3 Absolute positioning
4.2.3.4 Relative positioning

zetcode.com/ebooks/advancedjavaswing/ 8/12
3/25/2020 Advanced Swing e-book

4.2.3.5 Placing components


4.2.3.6 Fill
4.2.3.7 Push
4.2.3.8 Gaps
4.2.3.9 Column gaps
4.2.3.10 Size groups
4.2.3.11 Dock
4.2.3.12 Vertical alignment
4.2.3.13 Horizontal alignment
4.2.3.14 Indent
4.2.3.15 Pad
4.2.3.16 Span
4.2.3.17 Skip
4.2.3.18 Split
4.2.3.19 Shrink
4.2.3.20 Grow
4.2.3.21 Hidemode
4.2.3.22 Debug
4.2.4 Practical examples
4.2.4.1 Simple example
4.2.4.2 Corner buttons
4.2.4.3 Windows
4.2.4.4 Windows 2
4.2.4.5 New folder
4.2.4.6 New folder 2
4.2.4.7 New folder 3
4.2.4.8 External tools
4.2.4.9 Replace text
4.2.4.10 Monopoly

5. Advanced components
5.1 JList component
5.1.1 Simple examples
5.1.2 List orientation
5.1.3 DefaultListModel
5.1.3.1 Read-only data
5.1.3.2 Modifying data
5.1.4 AbstractListModel
5.1.4.1 Read-only data
5.1.4.2 Modifying data
5.1.5 ListDataListener
5.1.6 Selections
5.1.7 Renderers
5.1.7.1 Rendering stripped background

zetcode.com/ebooks/advancedjavaswing/ 9/12
3/25/2020 Advanced Swing e-book

5.1.7.2 Rendering icons


5.1.7.3 Rendering check boxes
5.1.8 Sorting
5.1.9 Filtering
5.2 JTable component
5.2.1 Simple table
5.2.2 Grid lines
5.2.3 DefaultTableModel
5.2.3.1 Simple example
5.2.3.2 Read-only table
5.2.4 AbstractTableModel
5.2.4.1 Simple example
5.2.4.2 Firing data changes
5.2.5 TableModelListener
5.2.6 Selection model
5.2.7 Table cell renderers
5.2.7.1 Cell alignments
5.2.7.2 The getColumnClass() method
5.2.7.3 The prepareRenderer() method
5.2.8 Custom cell renderer
5.2.8.1 Number cell renderer
5.2.8.2 Drawing icons
5.2.9 Table cell editors
5.2.9.1 ComboBoxEditor
5.2.9.2 Custom cell age editor
5.2.9.3 Currency editor
5.2.10 Table columns
5.2.10.1 Multi-line column headers
5.2.10.2 TableColumnModelListener
5.2.10.3 Adding and removing columns
5.2.10.4 Column highlighting
5.2.11 Table header renderer
5.2.12 Sorting
5.2.12.1 Automatic sorting
5.2.12.2 Sorting months
5.2.12.3 Sorting order
5.2.13 Filtering
5.2.13.1 Numeric filter
5.2.13.2 Converting row indexes
5.2.14 Row headers
5.2.15 Final example
5.3 JTree component
5.3.1 Simple tree
5.3.2 DefaultMutableTreeNode
zetcode.com/ebooks/advancedjavaswing/ 10/12
3/25/2020 Advanced Swing e-book

5.3.2.1 Tree creation


5.3.2.2 Sorted tree
5.3.3 DefaultTreeModel
5.3.4 TreePath
5.3.5 Tree rows
5.3.6 Selections
5.3.6.1 TreeSelectionListener
5.3.6.2 Programmatically selecting nodes
5.3.6.3 Adding and removing selections
5.3.7 User object
5.3.8 Tree enumerations
5.3.9 Expanding and collapsing nodes
5.3.9.1 Programmatically expanding and collapsing nodes
5.3.9.2 TreeExpansionListener
5.3.10 Tree cell renderers
5.3.11 Tree cell editors
5.3.11.1 DefaultCellEditor
5.3.11.2 DefaultTreeCellEditor
5.3.11.3 Editing phases
5.3.11.4 Click, pause, click, delay
5.3.11.5 Programmatically editing nodes
5.3.12 Lazy loading
5.3.12.1 Lazy loading with a TreeModel
5.3.12.2 Lazy loading with a TreeWillExpandListener
5.3.13 Searching tree
5.4 Text components
5.4.1 Appending text
5.4.2 JPasswordField
5.4.3 Text selection
5.4.4 Line & column numbers
5.4.5 Verifying input
5.4.5.1 JFormattedTextField
5.4.5.2 Inputverifier
5.4.6 DocumentListener
5.4.7 DocumentEvent
5.4.8 PlainDocument
5.4.8.1 Inserting text
5.4.8.2 Character limit
5.4.8.3 Element walker
5.4.9 EditorKit
5.4.10 View
5.4.10.1 Simple view
5.4.10.2 Coordinate system
5.4.11 Word count
zetcode.com/ebooks/advancedjavaswing/ 11/12
3/25/2020 Advanced Swing e-book

5.4.12 Highlighting text


5.4.12.1 Simple highlight
5.4.12.2 Searching text
5.4.13 Bracket matching
5.4.14 NavigationFilter
5.4.15 DocumentFilter
5.4.15.1 Size filter
5.4.15.2 Auto-indent
5.4.15.3 Overwrite filter
5.4.16 Text undo & redo
5.4.17 Styles
5.4.18 StyledEditorKit
5.4.19 Syntax highlighting

6. Bibliography

Home Top of Page


ZetCode last modified May 22, 2015 © 2007 - 2020 Jan Bodnar

zetcode.com/ebooks/advancedjavaswing/ 12/12

You might also like