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 19 €.

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. Toplevel containers
    2. Events
    3. SwingWorker
    4. Painting
    5. BufferedImage
    6. Miscellaneous
  2. Layout management
    1. GroupLayout
    2. MigLayout
  3. Advanced components
    1. JList
    2. JTable
    3. JTree
    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 practical examples explain the JList (14 examples), the JTree (22 examples), the JTable (29 examples), and several text components (28 examples).

Screenshots

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

Syntax highlighting
Figure: Simple syntax highlighting implemented with a document filter.
Bracket matching
Figure: Bracket matching implemented with a caret listener and a highlighter.
MigLayout horizontal alignment MigLayout vertical alignment
Figure: Explaining horizontal and vertical alignments with the MigLayout manager.
Reading web page
Figure: Reading a web page with an ExecutorService.
Searching for files
Figure: Using a SwingWorker to search for files.
Spotlight
Figure: Using a BufferedImage to create a nice spotlight effect.
Metal look and feel's palette
Figure: Demonstrating the colour palette of the Metal look and feel with the UIManager.
Sorting list
Figure: Sorting items of a JList component.
Abstract table model
Figure: Modifying items of a table with the AbstractTableModel.
Searching tree
Figure: Searching for items in a JTree component.

Table of Contents

  1. Preface
  2. About the author
  3. Foundations
    1. Toplevel containers
      1. JFrame
      2. JLayeredPane
      3. Glass pane
      4. JDialog
      5. JWindow
    2. Events
      1. Multiple listeners
      2. Multiple sources
      3. EventHandler
      4. Custom event
      5. Observer pattern
      6. Actions
        1. Action example
        2. Toggle buttons
      7. ActionListener vs ItemListener
      8. Application closing
      9. EventQueue
      10. AWTEventListener
      11. MouseEvent
        1. MouseListener
        2. Mouse event types
        3. MouseAdapter
      12. ItemEvent
      13. PaintEvent
      14. FocusEvent
        1. Selecting all text on gaining focus
        2. Initial focus
      15. Scheduling tasks
        1. Swing timer
        2. Utility timer
        3. Executor service
    3. SwingWorker
      1. SplashScreen
      2. Searching images
      3. Supervisor worker
    4. Painting
      1. The paintComponent() method
      2. Custom icon
      3. Painting into image
        1. Grayscale image
        2. Component capture
      4. The repaint() method
        1. Points
        2. Moving circle
    5. BufferedImage
      1. Grayscale image
      2. Scaling an image
      3. Spotlight
      4. Sun and cloud
      5. Subimage
    6. Miscellaneous
      1. Keyboard
        1. KeyListener
        2. Key bindings
        3. Mnemonics and accelerators
      2. UIManager
        1. Selecting laf
        2. Colour palette
      3. Compound border
      4. Custom border
      5. Screen capture
      6. Opaque
        1. Difference in meaning
        2. Three labels
  4. Layout management
    1. GroupLayout manager
      1. First examples
        1. Simple example
        2. Simple example 2
      2. Independent dimensions
        1. Grid of buttons
        2. Grid of buttons 2
      3. Gaps
        1. Fixed gaps
        2. Automatic gaps
        3. Resizable gaps
      4. Indent
      5. Alignments
        1. Horizontal alignment
        2. Vertical alignment
        3. Baseline alignment
      6. Parallel group's size
      7. Practical examples
        1. Corner buttons
        2. Password
        3. Windows
        4. Review
        5. Go To Class
        6. Tags
    2. MigLayout manager
      1. Grid
        1. Cells
        2. Horizontal flow mode
        3. Vertical flow mode
        4. Flow mode in a cell
        5. Orientation
        6. No grid
      2. Bound size
        1. Component size
        2. Component size 2
        3. Gap size
      3. Constraints
        1. Units
        2. Insets
        3. Absolute positioning
        4. Relative positioning
        5. Placing components
        6. Fill
        7. Push
        8. Gaps
        9. Column gaps
        10. Size groups
        11. Dock
        12. Vertical alignment
        13. Horizontal alignment
        14. Indent
        15. Pad
        16. Span
        17. Skip
        18. Split
        19. Shrink
        20. Grow
        21. Hidemode
        22. Debug
      4. Practical examples
        1. Simple example
        2. Corner buttons
        3. Windows
        4. Windows 2
        5. New folder
        6. New folder 2
        7. New folder 3
        8. External tools
        9. Replace text
        10. Monopoly
  5. Advanced components
    1. JList component
      1. Simple examples
      2. List orientation
      3. DefaultListModel
        1. Read-only data
        2. Modifying data
      4. AbstractListModel
        1. Read-only data
        2. Modifying data
      5. ListDataListener
      6. Selections
      7. Renderers
        1. Rendering stripped background
        2. Rendering icons
        3. Rendering check boxes
      8. Sorting
      9. Filtering
    2. JTable component
      1. Simple table
      2. Grid lines
      3. DefaultTableModel
        1. Simple example
        2. Read-only table
      4. AbstractTableModel
        1. Simple example
        2. Firing data changes
      5. TableModelListener
      6. Selection model
      7. Table cell renderers
        1. Cell alignments
        2. The getColumnClass() method
        3. The prepareRenderer() method
      8. Custom cell renderer
        1. Number cell renderer
        2. Drawing icons
      9. Table cell editors
        1. ComboBoxEditor
        2. Custom cell age editor
        3. Currency editor
      10. Table columns
        1. Multi-line column headers
        2. TableColumnModelListener
        3. Adding and removing columns
        4. Column highlighting
      11. Table header renderer
      12. Sorting
        1. Automatic sorting
        2. Sorting months
        3. Sorting order
      13. Filtering
        1. Numeric filter
        2. Converting row indexes
      14. Row headers
      15. Final example
    3. JTree component
      1. Simple tree
      2. DefaultMutableTreeNode
        1. Tree creation
        2. Sorted tree
      3. DefaultTreeModel
      4. TreePath
      5. Tree rows
      6. Selections
        1. TreeSelectionListener
        2. Programmatically selecting nodes
        3. Adding and removing selections
      7. User object
      8. Tree enumerations
      9. Expanding and collapsing nodes
        1. Programmatically expanding and collapsing nodes
        2. TreeExpansionListener
      10. Tree cell renderers
      11. Tree cell editors
        1. DefaultCellEditor
        2. DefaultTreeCellEditor
        3. Editing phases
        4. Click, pause, click, delay
        5. Programmatically editing nodes
      12. Lazy loading
        1. Lazy loading with a TreeModel
        2. Lazy loading with a TreeWillExpandListener
      13. Searching tree
    4. Text components
      1. Appending text
      2. JPasswordField
      3. Text selection
      4. Line & column numbers
      5. Verifying input
        1. JFormattedTextField
        2. Inputverifier
      6. DocumentListener
      7. DocumentEvent
      8. PlainDocument
        1. Inserting text
        2. Character limit
        3. Element walker
      9. EditorKit
      10. View
        1. Simple view
        2. Coordinate system
      11. Word count
      12. Highlighting text
        1. Simple highlight
        2. Searching text
      13. Bracket matching
      14. NavigationFilter
      15. DocumentFilter
        1. Size filter
        2. Auto-indent
        3. Overwrite filter
      16. Text undo & redo
      17. Styles
      18. StyledEditorKit
      19. Syntax highlighting
  6. Bibliography