Class JFileChooserBugFix
- java.lang.Object
-
- ptolemy.gui.JFileChooserBugFix
-
public class JFileChooserBugFix extends java.lang.Object
A workaround for a JFileChooser bug.This class is necessary to work around a bug under Windows where the "common places" portion of the JFileChooser dialog is affected by the background color of a component. Sun has acknowledged the bug as #6817933. See also "open dialog, common places pane has white box instead of text."
Every time JFileChooser is instantiated, saveBackground() should be called so that the background is properly set. Then, in a finally clause, restoreBackground() should be called. For example:
// Swap backgrounds and avoid white boxes in "common places" dialog JFileChooserBugFix jFileChooserBugFix = new JFileChooserBugFix(); Color background = null; try { background = jFileChooserBugFix.saveBackground(); PtFileChooser ptFileChooser = new PtFileChooser(); // Do the usual JFileChooser song and dance . . . } finally { jFileChooserBugFix.restoreBackground(background); }
Note that Java under Mac OS X has a much better implementation of the file chooser that uses java.awt.FileDialog instead of javax.swing.JFileChooser. Thus, under Mac OS X, this class is typically not invoked. Under Mac OS X, to invoke this class, either
PtGUIUtilities.useFileDialog()
orPtGUIUtilities.macOSLookAndFeel()
should return false. To do this, set either the ptolemy.ptII.useFileDialog property to false or set the ptolemy.ptII.MacOS property to false. SeePtGUIUtilities
for how to set these properties.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Christopher Brooks
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Constructor Summary
Constructors Constructor Description JFileChooserBugFix()
Instantiate a JFileChooserBugFix object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
restoreBackground(java.awt.Color background)
Restore the background.java.awt.Color
saveBackground()
Set the background to the value of the ToolBar.shadow property and return the previous background.
-
-
-
Method Detail
-
restoreBackground
public void restoreBackground(java.awt.Color background)
Restore the background.This method is not typically called on the Mac, see the class comment.
- Parameters:
background
- The background to be restored.- See Also:
saveBackground()
-
saveBackground
public java.awt.Color saveBackground()
Set the background to the value of the ToolBar.shadow property and return the previous background.Avoid a problem under Windows where the common places pane on the left of the file browser dialog has white boxes because the background is set to white. http://bugzilla.ecoinformatics.org/show_bug.cgi?id=3801
Call this method before instantiating a JFileChooser.
This method is not typically called on the Mac, see the class comment.
- Returns:
- the value of the previous background.
-
-