Swing for Jython: Graphical Jython UI and Scripts Development using Java Swing and WebSphere Application Server

Book description

This book shows you how to use Swing to add a GUI to your Jython scripts, with an emphasis on the WebSphere Application Server wsadmin utility. In fact, we're going to teach you Swing using Jython, and we're going to do it in a way that, hopefully, that makes your scripts easier for people to use, more robust, more understandable, and therefore easier to maintain.

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Author
  8. About the Technical Reviewers
  9. Introduction
  10. Chapter 1: Components and Containers
    1. Top-Level Containers
    2. Getting Help from Jython
    3. How and Why Are You Able to Do This?
    4. What’s Next?…Starting Simple
    5. Adding a Second Label
    6. Summary
  11. Chapter 2: Interactive Sessions vs. Scripts
    1. Running Your First Script from a File
    2. Depending “Too Much” on Limited Information
    3. Swing Threads
    4. Summary
  12. Chapter 3: Building a Simple Global Security Application
    1. Adding Text to the Application Using a JLabel
    2. No “Pane,” No Gain
      1. When You Live in a Glass House, Everything Is a Pane
      2. The Layered Look Can Also Be a Pane
      3. The Optional MenuBar
      4. The Content Pane Will Contain Most of the Visible Items
    3. Summary
  13. Chapter 4: Button Up! Using Buttons and Labels
    1. JButton Class Hierarchy
    2. The Layout of the Land
    3. Buttons! Labels! Action!
    4. Updating the Application
    5. Summary
  14. Chapter 5: Picking a Layout Manager Can Be a Pane
    1. The Absolute Layout Manager Does Not Corrupt Absolutely
    2. Going with the Flow: The FlowLayout Manager
    3. South of the Border: The BorderLayout Manager
    4. What’s in the Cards? Using the CardLayout Manager
    5. Splitting Up Is Easy to Do: Using Split Panes
      1. Vertical Splits: Not as Painful as They Sound
      2. Limited Resources: Setting Size Attributes
      3. Nested Split Panes
      4. Divider and Conquer
      5. Rules for Using Split Panes
    6. Can I Run a Tab? Using a TabbedPane
    7. Are You Boxed In? Using the BoxLayout Manager
      1. The Box Class
      2. Building a Box
      3. Invisible Box Components
      4. Boxes and Resizable Components
    8. Gridlock, Anyone? Using the GridLayout Manager
    9. Shaking Things Up: The GridBagLayout Manager
    10. Looking at Other Layout Managers
    11. Summary
  15. Chapter 6: Using Text Input Fields
    1. What Does It Take to Get Data Into an Application?
    2. JTextField: Getting Data Into the Application
    3. Your First, Almost Real, Application
    4. Help Me SwingWorker, You’re My Only Hope!
    5. Back to the JTextField
      1. Size Matters: Looking at Text Font Attributes
    6. The Elephant (Font) in the Room
    7. Using JTextArea for Input
    8. Summary
  16. Chapter 7: Other Input Components
    1. Password Fields
      1. Is There an Echo in Here? Using the Character-Obfuscation Property
      2. The getPassword() Method
      3. The event.getActionCommand() Method
      4. The JPasswordField Event Handler
      5. Converting jarray Values to Strings
    2. Choosing from a List
      1. Editing a ComboBox
    3. Using the DynamicComboBox
    4. Formatted Text Fields
    5. Using a JSpinner Text Field
      1. Some DateFormatSymbols Methods
      2. The JSpinner Class
      3. The SpinnerModel Class
      4. The JSpinner Editor
    6. Summary
  17. Chapter 8: Selectable Input Components
    1. Toggle Buttons
    2. Check Boxes
    3. Radio Buttons
    4. Toggle Buttons in a Button Group
    5. Summary
  18. Chapter 9: Providing Choices, Making Lists
    1. Making a List and Checking It Twice
    2. Optional Scroll Bars
      1. The ScrollPane Viewport
    3. Manipulating the List
      1. Counting List Items
      2. Limiting the Selectable Items
      3. Reacting to List-Selection Events
      4. Reacting to User (Text) Input
    4. Summary
  19. Chapter 10: Menus and MenuItems
    1. The JMenu Class Hierarchy
    2. Reacting to Menu-Related Events
    3. Using Radio Buttons on a Menu
    4. Using Check Boxes on a Menu
    5. Separating Menu Items
    6. Menu Mnemonics and Accelerators
    7. Pop-Up Menus
    8. Summary
  20. Chapter 11: Using JTree to Show the Forest:Hierarchical Relationships of Components
    1. Displaying the Servers in a WebSphere Application Server Cell
    2. JTree Attributes and Methods
      1. The TreeSelectionModel Class
      2. TreeSelectionListener
    3. JTree Manipulation
      1. The DefaultTreeModel Class
      2. The TreeModelListener Interface
    4. Summary
  21. Chapter 12: Motion to Take from the Table: Building Tables
    1. Tables Can Be Really Easy
    2. Defaults Can Be Harmful to your . . . Mental Health
      1. Picky, Picky, Picky. . . Selecting Parts of a Table
      2. Row, Row, Row Your . . . Table? Working with Rows
      3. Selecting Columns
      4. Selecting Individual Cells
    3. I Am the Very Model of a Modern Major General: Table Models9
      1. Types of Table Models
    4. Cell Renderers
      1. Custom Cell Renderers
    5. Using Cell Editors
      1. Boolean Cell Editors
      2. Numeric Cell Editors
      3. Custom Numeric Cell Editors
      4. JComboBox Cell Editors
      5. Warning: Ugliness Ahead
    6. Column Manipulation
      1. Column Widths
      2. Column Heading Width
      3. Determining Column Width
      4. Column Adjustments
    7. Summary
  22. Chapter 13: Keystrokes, Actions, and Bindings, Oh My!
    1. Getting in a Bind: Looking at Bindings
      1. What Is Meant by Binding?
      2. InputMaps and ActionMaps
    2. JTable Keystrokes
    3. Putting It All Together
      1. locationRelativeTo = None
      2. Centering the Application
      3. Defining the Table Properties
      4. Computing the Table Data
      5. The Fruits of Your Labor
    4. Binding Reuse
      1. Where to Begin: Finding the Appropriate Action Class
      2. What Do You Need to Worry About? Boundary Conditions
    5. Summary
  23. Chapter 14: It’s the Event of the Year: Events in Swing Applications
    1. If an Event Occurs and No One Hears It . . .
    2. Using Listener Methods
    3. Put Your Listener Where Your Component Is
    4. Adapt or Die: Using Adapter Classes
    5. Listening for Keyboard Events
    6. Most Objects Never Really Listen
    7. Looking for a Listener in a Haystack
    8. Using a ComponentAdapter to Monitor Changes
    9. Monitoring the Input Fields
    10. Using a PropertyChangeListener
    11. Using an InputVerifier
    12. Summary
  24. Chapter 15: Nuts to Soup: Using Jsoup to Enhance Applications
    1. Using Existing Classes: Creating an HTML Retrieval Application from Scratch
    2. Wouldn’t It Be Nice: Using Java Libraries
    3. Working with the Jsoup Library
    4. Jsoup Call May Appear to Hang
    5. From a Combo Box to a List Box
    6. Adding a TextArea to Show the HTML
    7. Rendering HTML
    8. Modifying the HTML Text
    9. Identifying the Sections
    10. Fixing the Great Divide
    11. Filtering the List
    12. Using Jsoup to Pick Up the Tab: Adding a JTabbedPane
    13. Adding Tabbed Editor Panes to the Javadoc Application
    14. What Improvements/Enhancements Remain?
    15. Summary
  25. Chapter 16: Conversing with a User with Dialog Boxes
    1. What Are Dialog Boxes?
    2. What’s a JDialog?
    3. What’s the GraphicsConfiguration Component Do?
    4. Using a GraphicsConfiguration Object
    5. Is a GraphicsConfiguration Object Really Necessary?
    6. What About an Owner?
    7. Where’s the Dialog?
    8. Multiple Modal Dialog Boxes Are Annoying
    9. Using JOptionPane Methods
      1. The JOptionPane.showMessageDialog() Method
      2. The JOptionPane.showOptionDialog() Method
      3. The JOptionPane.showConfirmDialog() Method
      4. The JOptionPane.showInputDialog() Method
    10. Summary
  26. Chapter 17: Specialized Dialog Boxes
    1. The JFileChooser Class
      1. JFileChooser Constructors
      2. Using a FileSystemView
      3. File Filtering
      4. Chooser Dialog Types
      5. Selection Types
    2. The JColorChooser Class
      1. The javax.swing.colorchooser Package
    3. What Else Do You Need to Know About These “Special” Dialog Boxes?
    4. Summary
  27. Chapter 18: Monitoring and Indicating Progress
    1. Changing the Cursor
    2. Showing a Progress Bar
      1. SwingWorker Progress
      2. Showing Progress Details
      3. Specifying a Progress Bar Range
      4. Indeterminate ProgressBar Range
    3. ProgressMonitor Objects
      1. ProgressMonitor Cancellation
      2. The ProgressMonitor Message
      3. The ProgressMonitor Note
      4. The ProgressMonitor parentComponent
      5. Other ProgressMonitor Properties
    4. ProgressMonitorInputStream Objects
    5. Summary
  28. Chapter 19: Internal Frames
    1. Looking at Inner Frames
    2. Layers
      1. Position Within the Layer
    3. The JDesktopPane Class
    4. JFrame or JInternalFrame?
    5. The JInternalFrame Class
      1. JFrame and JInternalFrame Methods
      2. More JFrame and JInternalFrame Differences
      3. JInternalFrame Events
      4. More JInternalFrame Topics
    6. Building an Application from Scratch
      1. Simple Non-GUI Jython Version of the consoleTimeout Script
      2. First GUI Jython Version of the consoleTimeout Script
      3. Adding Menu Items
      4. Changing from JFrame to JInternalFrame
    7. Summary
  29. Chapter 20: Building a Graphical Help Application
    1. Showing the Help Text
    2. Using a Tabbed Pane
    3. Adding Split Panes
    4. Text Highlighting
      1. Adding Text Highlighting to WSAShelp Application
      2. Tabbed Highlighting Complications
    5. Displaying Methods in a Table
      1. Highlighting Text Within the Table
      2. Using Tables in the Help Application
      3. Fixing the Table Appearance
    6. Selecting Table Cells
    7. Adding a Menu
    8. AdminTask.help( ‘-commands’ )
      1. How Do We Find and Identify Existing Commands?
      2. Showing the User that Something Is Happening
    9. AdminTask.help( ‘-commandGroups’ )
      1. Another ATgroupsTask Implementation
    10. Step It Up: Displaying the “Steps” Help Text
      1. How Should You Do It?
      2. Should You Add a Menu?
      3. Should You Add Another Split Pane?
      4. Can You Make Parts of the Text Pane Selectable?
      5. And Now for Something Completely Different...
    11. Summary
  30. Chapter 21: A Security Configuration Report Application
    1. Generating the Administration Console Report
    2. The Scripting Report Method
    3. First Attempt
    4. Second Attempt, Ignoring the Last Delimiter
    5. Adding a Table Model and Cell Renderer
      1. Using Color Instead of a Bold Font
    6. Adjusting Column Widths
      1. Column Widths and Row Heights
    7. Adding a Frame Resize Listener
      1. Fixing the Row Selection Colors
    8. Which Rows Are Visible?
    9. Table Alignment in the Viewport
    10. Table Row Filtering
    11. Finding Text
    12. Section Visibility
      1. Does It Work?
    13. Progress Indicator
    14. Summary
  31. Chapter 22: WASports: A WebSphere Port Application
    1. Using the Administration Console
    2. The AdminTask.listServerPorts() Method
    3. The AdminTask.reportConfiguredPorts() Method
    4. Using AdminConfig Methods
    5. Step 0: Creating a WASports Application
    6. Step 1: Adding an Empty Internal Frame
    7. Step 2: Adding an Empty JSplitPane to the Internal Frame
    8. Step 3: Adding a Cell Hierarchy Tree to the JSplitPane
    9. Step 4: Updating the Right Pane
    10. Step 5: Displaying Cell and Node Details
      1. Utility Routines
      2. New Classes for WASports_05
    11. Step 6: Displaying Server Port Number Information
    12. Step 7: Computing Table Column Widths
    13. Step 8: Adding Menu Items
    14. Step 9: Implementing Save and Discard
    15. Step 10: Implementing the Export Functionality
      1. Using the Document Object Model API
      2. Using the Simple API for XML (SAX)
      3. The Document Type Definition (DTD)
      4. Initial WASports DTD
      5. The ExportTask Class
    16. Step 11: Implementing the Import Functionality
      1. The ImportTask Class
    17. What’s Left?
      1. Text Highlighting
      2. Table Sorting
      3. Comparing Configurations
      4. Report Generation
    18. Summary
  32. Index

Product information

  • Title: Swing for Jython: Graphical Jython UI and Scripts Development using Java Swing and WebSphere Application Server
  • Author(s):
  • Release date: December 2014
  • Publisher(s): Apress
  • ISBN: 9781484208175