|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsears.tools.DialogUtils
public class DialogUtils
This class gives methods for display an "open" dialog and a "save as" dialog.
An instance of this class will display (if the good method is called),
after test conditions a FileDialog or JFileChooser.
Example of use:
DialogUtils du = new DialogUtils();
// set options:
du.setConditions( true, true );
du.setApproveButtonText( "Save as" );
du.setOverwriteText(SearsResourceBundle.getResource( "Do you really want to overwrite this file ?" ));
du.setFileFilter(new FileFilter() { ... });
// we get back the file choosen
File file = du.showSaveAsDialog(instance, "Save As", subtitleFile.getFile());
// if user cancel action, file is null:
if (file != null){// action you want}
Constructor Summary | |
---|---|
DialogUtils()
|
Method Summary | |
---|---|
void |
setApproveButtonText(java.lang.String approveButtonText)
this method set the approveButtonText needed by JFileChooser |
void |
setConditions(boolean OSCondition,
boolean lookAndFeelCondition)
This method set conditions for display the FileDialog instead of the JFileChooser. |
void |
setFileFilter(javax.swing.filechooser.FileFilter filter)
this method defines the file filer needed by the dialog... |
void |
setLocale(java.util.Locale locale)
|
void |
setOverwriteText(java.lang.String overwriteText)
this method defines the overwrite text needed if instance choose a JFileChooser for display the "save as" dialog |
java.io.File |
showOpenDialog(java.awt.Frame parent,
java.lang.String title,
java.io.File openedFile)
|
java.io.File |
showSaveAsDialog(java.awt.Frame parent,
java.lang.String title,
java.io.File openedFile)
Method saveAsDialog this method display a dialog for save as a file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DialogUtils()
Method Detail |
---|
public void setConditions(boolean OSCondition, boolean lookAndFeelCondition)
OSCondition
- if true, the class instance will test if app is running on a Mac platformlookAndFeelCondition
- if true, the class instance will test if app's look and feel is the same of the system default onepublic void setApproveButtonText(java.lang.String approveButtonText)
approveButtonText
- the text display in the approve buttonpublic void setFileFilter(javax.swing.filechooser.FileFilter filter)
filter
- the file filterpublic void setOverwriteText(java.lang.String overwriteText)
overwriteText
- the overwrite text you want to display if user try to overwrite a filepublic void setLocale(java.util.Locale locale)
public java.io.File showSaveAsDialog(java.awt.Frame parent, java.lang.String title, java.io.File openedFile)
parent
- the parent Frametitle
- the title of the dialogopenedFile
- the file which want to save
public java.io.File showOpenDialog(java.awt.Frame parent, java.lang.String title, java.io.File openedFile)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |