Package com.shaiksphere.mindsmine.jems
Class SwingHelper
java.lang.Object
com.shaiksphere.mindsmine.jems.SwingHelper
A collection of useful static methods to deal with Java Swing Framework.
- Since:
- 4.0.0
- Author:
- Mohammed Shaik Hussain Ali
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final FileNameExtensionFilter
Convenient file extension filter for binary files.static final FileNameExtensionFilter
Convenient file extension filter for text files. -
Method Summary
Modifier and TypeMethodDescriptionpickFile()
Displays a File Chooser to pick a single file usingJFileChooser.showOpenDialog(java.awt.Component)
window.pickFile
(Component component, String dialogTitle, FileNameExtensionFilter... fileNameExtensionFilter) Displays a File Chooser to pick a single file usingJFileChooser.showOpenDialog(java.awt.Component)
window.Displays a File Chooser to pick a single file usingJFileChooser.showOpenDialog(java.awt.Component)
window.pickFile
(String dialogTitle, FileNameExtensionFilter... fileNameExtensionFilter) Displays a File Chooser to pick a single file usingJFileChooser.showOpenDialog(java.awt.Component)
window.Displays a File Chooser to pick a single folder usingJFileChooser.showOpenDialog(java.awt.Component)
window.pickFolder
(Component component, String dialogTitle) Displays a File Chooser to pick a single folder usingJFileChooser.showOpenDialog(java.awt.Component)
window.pickFolder
(String dialogTitle) Displays a File Chooser to pick a single folder usingJFileChooser.showOpenDialog(java.awt.Component)
window.static void
showErrorDialog
(Component component, String title, String message) Displays a error message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.static void
showErrorDialog
(String title, String message) Displays a error message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.static void
showInformationDialog
(Component component, String title, String message) Displays a information message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.static void
showInformationDialog
(String title, String message) Displays a information message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.static void
showPlainDialog
(Component component, String title, String message) Displays a plain message without an icon using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.static void
showPlainDialog
(String title, String message) Displays a plain message without an icon using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.static void
showQuestionDialog
(Component component, String title, String message) Displays a question using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.static void
showQuestionDialog
(String title, String message) Displays a question using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.static void
showWarningDialog
(Component component, String title, String message) Displays a warning message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.static void
showWarningDialog
(String title, String message) Displays a warning message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.
-
Field Details
-
BIN_EXTENSION_FILTER
Convenient file extension filter for binary files.- Since:
- 4.0.0
-
TXT_EXTENSION_FILTER
Convenient file extension filter for text files.
-
-
Method Details
-
pickFile
Displays a File Chooser to pick a single file usingJFileChooser.showOpenDialog(java.awt.Component)
window. Convenient method equivalent toSwingHelper.pickFile(null, null, null)
- Returns:
- the
Optional
object containing the selected file - Since:
- 4.0.0
- See Also:
-
pickFile
Displays a File Chooser to pick a single file usingJFileChooser.showOpenDialog(java.awt.Component)
window. Convenient method equivalent toSwingHelper.pickFile(null, title, null)
- Parameters:
dialogTitle
- for the file picker window- Returns:
- the
Optional
object containing the selected file - Since:
- 4.0.0
- See Also:
-
pickFile
public static Optional<File> pickFile(String dialogTitle, FileNameExtensionFilter... fileNameExtensionFilter) Displays a File Chooser to pick a single file usingJFileChooser.showOpenDialog(java.awt.Component)
window. Convenient method equivalent toSwingHelper.pickFile(null, title, filter)
- Parameters:
dialogTitle
- for the file picker windowfileNameExtensionFilter
- to limit the types of acceptable files- Returns:
- the
Optional
object containing the selected file - Since:
- 4.0.0
- See Also:
-
pickFile
public static Optional<File> pickFile(Component component, String dialogTitle, FileNameExtensionFilter... fileNameExtensionFilter) Displays a File Chooser to pick a single file usingJFileChooser.showOpenDialog(java.awt.Component)
window.- Parameters:
component
- the parent component of the dialog, can benull
dialogTitle
- for the file picker windowfileNameExtensionFilter
- to limit the types of acceptable files- Returns:
- the
Optional
object containing the selected file - Since:
- 4.0.0
-
pickFolder
Displays a File Chooser to pick a single folder usingJFileChooser.showOpenDialog(java.awt.Component)
window. Convenient method equivalent toSwingHelper.pickFolder(null, null)
- Returns:
- the
Optional
object containing the selected file - Since:
- 4.0.0
- See Also:
-
pickFolder
Displays a File Chooser to pick a single folder usingJFileChooser.showOpenDialog(java.awt.Component)
window. Convenient method equivalent toSwingHelper.pickFolder(null, title)
- Parameters:
dialogTitle
- for the folder picker window- Returns:
- the
Optional
object containing the selected file - Since:
- 4.0.0
- See Also:
-
pickFolder
Displays a File Chooser to pick a single folder usingJFileChooser.showOpenDialog(java.awt.Component)
window.- Parameters:
component
- the parent component of the dialog, can benull
dialogTitle
- for the folder picker window- Returns:
- the
Optional
object containing the selected file - Since:
- 4.0.0
- See Also:
-
showErrorDialog
Displays a error message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window. Convenient method equivalent toSwingHelper.showErrorDialog(null, title, message)
- Parameters:
title
- the title string for the dialogmessage
- the message to display in the dialog- Since:
- 4.0.0
-
showErrorDialog
Displays a error message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.- Parameters:
component
- the parent component of the dialog, can benull
title
- the title string for the dialogmessage
- the message to display in the dialog- Since:
- 4.0.0
-
showInformationDialog
Displays a information message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window. Convenient method equivalent toSwingHelper.showInformationDialog(null, title, message)
- Parameters:
title
- the title string for the dialogmessage
- the message to display in the dialog- Since:
- 4.0.0
-
showInformationDialog
Displays a information message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.- Parameters:
component
- the parent component of the dialog, can benull
title
- the title string for the dialogmessage
- the message to display in the dialog- Since:
- 4.0.0
-
showWarningDialog
Displays a warning message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window. Convenient method equivalent toSwingHelper.showWarningDialog(null, title, message)
- Parameters:
title
- the title string for the dialogmessage
- the message to display in the dialog- Since:
- 4.0.0
-
showWarningDialog
Displays a warning message using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.- Parameters:
component
- the parent component of the dialog, can benull
title
- the title string for the dialogmessage
- the message to display in the dialog- Since:
- 4.0.0
-
showQuestionDialog
Displays a question using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window. Convenient method equivalent toSwingHelper.showQuestionDialog(null, title, message)
- Parameters:
title
- the title string for the dialogmessage
- the message to display in the dialog- Since:
- 4.0.0
-
showQuestionDialog
Displays a question using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.- Parameters:
component
- the parent component of the dialog, can benull
title
- the title string for the dialogmessage
- the message to display in the dialog- Since:
- 4.0.0
-
showPlainDialog
Displays a plain message without an icon using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window. Convenient method equivalent toSwingHelper.showPlainDialog(null, title, message)
- Parameters:
title
- the title string for the dialogmessage
- the message to display in the dialog- Since:
- 4.0.0
-
showPlainDialog
Displays a plain message without an icon using theJOptionPane.showMessageDialog(java.awt.Component, java.lang.Object)
window.- Parameters:
component
- the parent component of the dialog, can benull
title
- the title string for the dialogmessage
- the message to display in the dialog- Since:
- 4.0.0
-