Package com.compomics.util.gui
Class GuiUtilities
java.lang.Object
com.compomics.util.gui.GuiUtilities
public class GuiUtilities extends Object
A class containing simple GUI helper methods.
- Author:
- Harald Barsnes
-
Constructor Summary
Constructors Constructor Description GuiUtilities()
-
Method Summary
Modifier and Type Method Description static int
getPreferredWidthOfCell(JTable table, int rowIndex, int colIndex)
Returns the preferred width of a given cell in a table.static void
installEscapeCloseOperation(JDialog dialog)
Close a dialog using the escape key.static boolean
validateDoubleInput(Component parentComponent, JLabel label, JTextField textField, String valueDescription, String errorTitle, boolean positiveValue, boolean showMessage, boolean valid)
Validate double input.static boolean
validateIntegerInput(Component parentComponent, JLabel label, JTextField textField, String valueDescription, String errorTitle, boolean positiveValue, boolean showMessage, boolean valid)
Validate integer input.
-
Constructor Details
-
GuiUtilities
public GuiUtilities()
-
-
Method Details
-
getPreferredWidthOfCell
Returns the preferred width of a given cell in a table.- Parameters:
table
- the tablecolIndex
- the colum indexrowIndex
- the row index- Returns:
- the preferred width of the cell
-
validateIntegerInput
public static boolean validateIntegerInput(Component parentComponent, JLabel label, JTextField textField, String valueDescription, String errorTitle, boolean positiveValue, boolean showMessage, boolean valid)Validate integer input.- Parameters:
parentComponent
- the parent componentlabel
- the label of the inputtextField
- the text field containing the inputvalueDescription
- the description of the inputerrorTitle
- the error titlepositiveValue
- if true, only positive values will pass the filtershowMessage
- if true, a message will be shown if the validation failsvalid
- the status of previous validations- Returns:
- true of the field is validated, false if not (or if valid is false)
-
validateDoubleInput
public static boolean validateDoubleInput(Component parentComponent, JLabel label, JTextField textField, String valueDescription, String errorTitle, boolean positiveValue, boolean showMessage, boolean valid)Validate double input.- Parameters:
parentComponent
- the parent componentlabel
- the label of the inputtextField
- the text field containing the inputvalueDescription
- the description of the inputerrorTitle
- the error titlepositiveValue
- if true, only positive values will pass the filtershowMessage
- if true, a message will be shown if the validation failsvalid
- the status of previous validations- Returns:
- true of the field is validated, false if not (or if valid is false)
-
installEscapeCloseOperation
Close a dialog using the escape key.- Parameters:
dialog
- the dialog to install the escape close on
-