Here you can find the source of buttonState(JButton button, boolean boolArrayOfErrors[])
Parameter | Description |
---|---|
button | a parameter |
boolArrayOfErrors | a parameter |
public static void buttonState(JButton button, boolean boolArrayOfErrors[])
//package com.java2s; //License from project: Open Source License import javax.swing.JButton; public class Main { /**//ww w . j ava2 s . co m * Takes a JButton and a boolean array of errors. * * It checks to see if errors are present, if not it enables the button If * true it disables the button. * * * @param button * @param boolArrayOfErrors */ public static void buttonState(JButton button, boolean boolArrayOfErrors[]) { if (!isErrorPresent(boolArrayOfErrors)) { button.setEnabled(true); } else { button.setEnabled(false); } } /** * Takes an array of booleans, if one true is found then this returns true * indicating that an error is present. * * Else it returns false meaning no errors are present. * * * @param values * @return true/false */ public static boolean isErrorPresent(boolean[] values) { for (boolean value : values) { if (value) return true; } return false; } }