CHANGES SINCE THE PREVIOUS RELEASE This file summarizes changes made since Swing 1.0.3. Documentation improvements and look-and-feel cosmetic changes are not listed here. For the latest, detailed information about Swing, be sure to check our Web site, The Swing Connection: http://java.sun.com/products/jfc/tsc/ This file has the following sections: - Known Bugs - Performance - Applets - JFileChooser - JColorChooser - JTree - JTable - BasicListCellRenderer -> DefaultListCellRenderer BasicTreeCellRenderer -> DefaultTreeCellRenderer - DefaultListSelectionModel - JToolBar - JPopupMenu - JSeparator - AbstractButton - JProgressBar - JViewport, JScrollPane, Scrollable - New Interface: MouseInputListener - SwingSet - System Colors - PLAF - Serialization - Bug Fixes ========== Known Bugs (fixed in the next release) ========== This section lists a few new bugs that are likely to affect developers: - HTML support in this release isn't as stable as we'd like. Developers with applications that depend on HTML support should be very cautious about relying on Swing 1.1 beta. We hope to release a second Swing beta for JDK 1.1.6 with robust HTML support and many additional bug fixes. - In JTree, if you remove a node from a tree, the parent of the node that was removed becomes expanded, even if it previously was not visible or expanded. Also, JTree repaints when it receives a TreeModelEvent, even if the affected nodes are not visible. Finally, please avoid using the JTree isCollapsed method, since it results in a StackOverflowError; use !isExpanded instead. =========== Performance =========== Swing 1.1 beta includes many performance enhancements. The Swing team has been working hard to find and eliminate performance bottlenecks. We've concentrated on removing allocation of temporary objects during repetitive operations. This includes drastic reductions in the number of Rectangle, Dimension, and String objects created during layout and painting. We've also made key improvements to Swing's core repainting engine to improve efficiency. Overall, many operations have been sped up by around two times (some more, some less). However, this isn't the end of our performance-tuning efforts. We're already working on more performance enhancements (such as faster InternalFrame dragging) that will appear in future releases of Swing. Although running Swing on JDK 1.2beta4 is still slower than running it on JDK 1.1.X, you should see MAJOR speedups in comparison to 1.2beta3. We've been working to improve how Swing and Java2D work together, and will continue to improve these numbers for the final release of JDK 1.2. ======= Applets ======= - Timers will continue to work in Netscape after first visited applet is closed . ============ JFileChooser ============ - Cleaned up JFileChooser constructors, added a constructor with FileSystemView as the argument. - Added getHomeDirectory() method to FileSystemView. - Moved JFileChooser and the filechooser package out of preview package. ============= JColorChooser ============= JColorChooser has moved out of the preview package and into the main Swing package. We've also added a colorchooser package for JColorChooser-related API. The JColorChooser now features a "pluggable" architecture which allows app developers to insert new choosers and new previewers. To create a new type of chooser you should subclass AbstractColorChooserPanel and then insert an instance of your class into an instance of JColorChooser. Also, any JComponent can now be used to preview the color selection. Just call setPreviewPanel() and the color chooser will automatically update your component's foreground color with the new selection. ===== JTree ===== - New classes: DefaultTreeCellRenderer and DefaultTreeCellEditor. BasicTreeCellRenderer was moved into the tree package and is now called DefaultTreeCellRenderer. BasicTreeCellEditor and BasicTreeCellEditorContainer were merged and moved into the tree package, and are now named DefaultTreeCellEditor. - JTree maintains expanded state of nodes between look and feel changes. - New listener type: TreeWillExpandListener. - The TreePath implementation has changed. It no longer has an array of path components, just a reference to a parent TreePath and last path component. - BasicTreeUI has changed drastically. AbstractTreeUI, VisibleTreeNode, LargeTreeNode, BasicVisibleTreeNode and BasicLargeTreeNode no longer exist. The functionality of determining layout has been moved into AbstractLayoutCache, VariableHeightLayoutCache and FixedHeightLayoutCache, all of which are in the tree package. - JTree has a property as to whether scrolling should happen on expanding. If true, scrolling happens only in the Y direction. - Also see the tree-related bugs in the "Bug Fixes" section. ====== JTable ====== Faster rendering ---------------- Most apps should see a big performance win for the JTable in this release, due mostly to changes in the way that swing's use of Graphics contexts has been optimised. Many of our internal JTable benchmarks are showing rendering speeds about twice as fast as 1.0.2. New resize modes for JTable! ---------------------------- The resizing algorithm has been completely rewritten and the JTable now sports two new autoresize modes: NEW: public static final int AUTO_RESIZE_NEXT_COLUMN public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS The old default, the almost-unusable AUTO_RESIZE_ALL_COLUMNS has been replaced with AUTO_RESIZE_SUBSEQUENT_COLUMNS. NEW: public TableCellRenderer getCellRenderer(int row, int column) public TableCellEditor getCellEditor (int row, int column) public Component prepareRenderer(TableCellRenderer renderer, int row, int column) public Component prepareEditor (TableCellEditor editor, int row, int column) These are the single entry points for all the JTable code that gets and prepares renderers and editors. They can be overridden to supply non-column centric behavior. The selection models used by the table are now regular DefaultListSelectionModels. This also fixes the 'ghost anchor cells' problem. BasicTableUI ------------ As well as the standardisation of the UI classes which is discussed above, the methods, paintCell() and paintRow() have been left private. It may be faster to render the table in columns rather than rows. Leaving these private for now, will allow us to look into this. Eventually, all these methods will bw exposed, at least as protected. Render the editing cell with the editor, not the renderer, fixing a bug where the editor was left dangling during resizing. AbstractTableModel ------------------ All the fireTableXXX methods in AbstractTableModel are now all public. We saw a number of cases where developers had to augment their AbstractTableModel derivative with public wrappers so that methods could be called from anywhere. ================================================ BasicListCellRenderer -> DefaultListCellRenderer BasicTreeCellRenderer -> DefaultTreeCellRenderer ================================================ Although the plaf packages were widely advertised as in flux we recognise that this change will be the biggest backward compatibility issue for code being moved to the new release. We have moved all the renderers from the plaf packages into the main swing package, with appropriate changes in the names of the classes. OLD --- General: swing.DefaultCellRenderer swing.DefaultCellEditor JList: swing.plaf.basic.BasicListCellRenderer JTable: swing.table.DefaultTableCellRenderer swing.table.DefaultTableCellEditor JTree: swing.plaf.basic.BasicTreeCellRenderer swing.plaf.basic.BasicTreeCellEditor So, some renderers/editors were part of the UI packages and some were not. NEW --- General: swing.DefaultCellEditor JList: swing.DefaultListCellRenderer JTable: swing.table.DefaultTableCellRenderer swing.table.DefaultTableCellEditor JTree: swing.tree.DefaultTreeCellRenderer swing.tree.DefaultTreeCellEditor Now the rendering and editing story is a little more consistent - there are no default editors or renderers in the plaf packages. Most of the feedback we had on renderers was not from people writing their own look and feels, but from people trying to implement a coloring strategy for a particular usability requirement in their application. It is better to do this without introducing a dependency on a particular look and feel and having all the renderers availible in swing's core packages makes this easier. Note: It is still possible for the JComponents above to set different properties in these renderers depending on their LookAndFeel. So MyListUI could choose to set a up renderer which used a red background to highlight the selected cell. We have simply noted that new classes are rarely required to achieve these effects. ========================= DefaultListSelectionModel ========================= Rewritten, making it simpler and fixing all outstanding bugs. Also allows selection models to easily be mapped in a pipe in the same way that data models (like JTable's TableSorter) can map a TableModel. DELETED (made private) private BitSet value; Make the BitSet vector in DefaultListSelectionModel private to allow the its replacement with a sparse implementation. ======== JToolBar ======== - Improved floating/docking behavior. - Improved support for changing orientation. - Added tool bar specific separator, including support for variable width separators. - Improved L&F switching support for floating tool bars. Floating tool bars now change their L&F, although they automatically re-dock when a L&F switch occurs. This was necessary because the floating behavior is handled by and specific to the current L&F. ========== JPopupMenu ========== - Added popup menu specific separator. ========== JSeparator ========== - Added support for vertical separators. ============== AbstractButton ============== Added "contentAreaFilled" property to AbstractButton and added support in various L&F classes. This property will help programmers separate "repaint manager opacity" from the concept of buttons that fill their bounds. Added support for this to various L&F classes and added a simple demo of this to the SwingSet. This provides more consistent behavior for button background color and for "icon only" buttons. ============ JProgressBar ============ JProgressBar has had two main additions since the last release. First, we added some constructors. Second, we added the ability to draw a "progress string" inside the progress bar. Naturally, we've also fixed a number of bugs. New Constructors ---------------- Previously, JProgressBar had one constructor: JProgressBar(). This was rather limiting. Now, there are 5 constructors: JProgressBar(BoundedRangeModel newModel) JProgressBar(int orient, int min, int max) JProgressBar(int min, int max) JProgressBar(int orient) JProgressBar() These additions should reduce the number of lines of code needed to create and modify a progress bar. Progress String --------------- Another addition to the progress bar is the "progress string". By default, when you turn the progress string on (via setStringPainted(true)) a percentage is rendered inside of the progress bar. For example, instead of just using a bar that is one-third full to denote progress, you can use the default progress string, which adds the text "33%" inside the progress bar. You can customize the progress string using the setString method. ================================== JViewport, JScrollPane, Scrollable ================================== In previous releases, views would always be forced to be at least as large as their viewports - even if their getScrollableTracksViewportWidth,Height methods returned false. This has been corrected; however, some of our components relied on the old behavior. Their Scrollable methods to make the old behavior explicit, i.e. if the component is smaller than the viewport than the appropriate "tracksViewportWidth,Height" method returns true. This means that components do have to reach up and check the bounds on their JViewport parent, e.g.: public boolean getScrollableTracksViewportWidth() { if (getParent() instanceof JViewport) { return (((JViewport)getParent()).getWidth() > getPreferredSize().width); } return false; } ================================= New Interface: MouseInputListener ================================= MouseInputListener is a new interface implementing both the MouseListener and MouseMotionListener interfaces. A new adapter class MouseInputAdapter has empty implementations of all of the methods. This was done to tidy up the naming conventions for the UI classes that had to implement both interfaces with a single inner class. ======== SwingSet ======== - Removed hardcoded insets in ToggleButton demo - Changed the size of small duke images to by 64x64 (demo looks better) - Changed use of Dialog to JDialog - Moved the list of contributors from the Contributors menu item into a new html page (accessed by going to the HTML demo tab, which used to have the swing javadoc) ============= System Colors ============= The Windows look and feel now uses AWT's SystemColors so that Swing programs running with the Windows look and feel on Windows 95 or WinNT come up with the desktop colors configured by the user. ==== PLAF ==== - Removed the getDefaultMargin method from both the button and menu's PLAF definitions. - Added a convenience method (makeKeyBindings) to LookAndFeel for building key-binding lists. General PLAF API Changes ------------------------ The APIs in the pluggable look-and-feel (PLAF) packages have changed substantially in this release. We made these changes in order to improve the consistency and extensibility of the pluggable look-and-feels for the subset of developers who have a need to either extend or create new look-and-feel implementations. In prior releases, we carefully documented that these changes were forthcoming as a warning to developers who wished to program with the PLAF layer. With this release, these APIs can be considered frozen. MOST SWING PROGRAMS SHOULD NOT BE AFFECTED BY THESE CHANGES because the PLAF APIs are used internally by Swing components, and standard programs should generally not make method calls into these APIs. Programs that extended classes contained in the PLAF packages will be extremely affected by these changes and will require substantial code changes in order to compile and run with this release. If you need to understand more details on these PLAF changes, send email to swing-feedback@java.sun.com, and we will send you more information. ============= Serialization ============= The way Swing components are serialized has been substantially changed. The JComponent UI property is now transient, i.e. the component's look and feel is no longer serialized. When a component is deserialized it will pick up the current default look and feel (see the UIManager setLookAndFeel method). If you're interested in the gory details, look at the javadoc for the serialiation methods in JComponent. Removed "implements Serializable" from DefaultCaret. DefaultCaret also implements some AWT event listener interfaces like MouseListener. This causes trouble because Component.writeObject(), which unconditionally runs before we get a shot at things, serializes the Caret when it writes out the Component listeners. And Swing L&Fs define their own inner DefaultCaret subclasses so Component.writeObject() ends up trying to serialize our UI objects. This change implies that developers who set the JComponent "caret" property will have to make their DefaultCaret subclasses serializable. ========= Bug Fixes ========= This section lists many of the bugs fixed in Swing 1.1 Beta. 4113876 - Button mnemonics broken in Swing1.0.2 4117579 - AbstractButton.getSelectedObjects() returning null 4150666 - AbstractButton fireActionPerformed using incorrect actionCommand 4130768 - Motif ToggleButtonBorder focus painting incorrect 4135159 - JFileChooser crashes under Microsoft VM 4137651 - JFileChooser Dialog Return Values not unique 4141375 - BasicDirectoryModel not a public class 4145908 - JFileChooser not a bean 4144644 (partial) - JFileChooser components need mnemonics 4129703 - Deleting filename in JFileChooser and clicking "Open" returns filename 4136103, 4138881 - repainting broken when multiple applets loaded in a browser 4141183 - JFileChooser constructor ignoring FileSystemView argument 4142900 - JFileChooser(String) constructor does not work with null parameter 4144847 - Can't keyboard navigate to File chooser graphics fronted buttons 4150703 - Cleaned up unneeded import statements from many source files 4136587 - onetouchexpandable arrows not visible in metal l&f 4133493 - Timers in applets work better 4132198 - Expanding collapsed tree node generates extra selection event 4134518 - Default tree cell editor needs minimum size 4140840 - Tree should notice different collapsed/expanded sizes 4126040 - Need setRoot in DefaultTreeModel 4129400 - JTree node expanding causes incorrect scrolling 4129661 - JTree rowHeight from renderer chops off editor 4138762 - Escape should cancel tree node editing 4137468 - Need treeWillExpand/Collapse events so listener can veto change 4138754 - Clicking on tree node icon shouldn't start editing 4138611 - MetalWorks doesn't run with 1.2b4 4140153 - Custom combo boxes in SwingSet don't highlight 4130446 - BasicGraphicsUtils.drawString is inefficient 4133767 - Setting button text to null (Metal) causes exception painting focus 4144840 - MetalTextFieldUI$TextFieldBorder throws ClassCastException 4146836 - MetalBumps init code does too many setColors 4150208 - SwingSet HTML demo doesn't work on 1.1 4140193 - The ViewportLayout classes no longer handles small views correctly 4120021 - UIDefaults.getUI() always uses the system class loader. 4125386 - JList: Horizontal scrolling unit increment is 1 4139343 - JViewport.setViewPosition(Point p) changes parameter p 4141867 - Swing Scrollpane getCorner() and/or setCorner methods fail with JDK-1.2beta4-G 4139746 - SwingSet as Applet dialogs don't work in Window L&F with JDK-1.2beta4-F 4140591 - JScrollBar doesn't allow model swapping 4143323 - JTextArea.getScrollableTracksViewportWidth() fails 4136103 - JApplet repaint/deadlock problems 4140659 - SwingUtilities.getWindowAncestor(...) algorithm 4139930 - No intervalRemoved-Event fired when first element of DefaultListModel is removed 4136080 JList with ListSelectionListener is not serializable 4145048 - Exception when adding 2 elements in a row to DefaultListModel 4125386 - JList: Horizontal scrolling unit increment is 1 4139343 - JViewport.setViewPosition(Point p) changes parameter p 4141867 - Swing Scrollpane getCorner() and/or setCorner methods fail with JDK-1.2beta4-G 4147180 - DefaultListSelectionModel: removeIndexInternal may fail 4145147 - DefaultListSelectionModel.insertIndexInterval always inserts unselected items 4145148 - DefaultListSelectionModel.removeIndexInterval(..) works incorrectly 4128512 - Empty JTable selects non-existent row 1 when it gains focus 4133318 - Adjustment of Tooltip location if it doesn't fit in the frame 4141532 - NPE: Swing JInternalFrame.JDesktopIcon(JInternalFrame) fails 4138539 - Window L&F InternalFrame not closing