Example usage for javax.swing JMenuItem setEnabled

List of usage examples for javax.swing JMenuItem setEnabled

Introduction

In this page you can find the example usage for javax.swing JMenuItem setEnabled.

Prototype

@BeanProperty(preferred = true, description = "The enabled state of the component.")
public void setEnabled(boolean b) 

Source Link

Document

Enables or disables the menu item.

Usage

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingClusterListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;//ww w. j  ava 2 s . c o  m
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetClusterObj selectedObj = getSwingFocusAsCluster();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddCluster != null) {
        actionAddCluster.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingHostNodeFinderJInternalFrame.java

public void adjustFinderMenuBar() {
    JMenuItem menuItem;
    Action act;/*www.ja  v a  2 s  .  co m*/
    String itemLabel;
    ICFInternetHostNodeObj selectedObj = getSwingFocusAsHostNode();
    boolean enableState;
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(enableState);
    }
    if (actionAddHostNode != null) {
        actionAddHostNode.setEnabled(true);
    }

    if (menuFile != null) {
        int itemCount = menuFile.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuFile.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionAddHostNode) {
                    menuItem.setEnabled(true);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingHostNodeListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from w  w w  .j av a  2  s  . c  o m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetHostNodeObj selectedObj = getSwingFocusAsHostNode();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddHostNode != null) {
        actionAddHostNode.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingISOCountryCurrencyListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*w  w w .ja va2  s . c  o m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetISOCountryCurrencyObj selectedObj = getSwingFocusAsISOCountryCurrency();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddISOCountryCurrency != null) {
        actionAddISOCountryCurrency.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingISOCountryFinderJInternalFrame.java

public void adjustFinderMenuBar() {
    JMenuItem menuItem;
    Action act;/*from www.ja  v  a  2s  .  com*/
    String itemLabel;
    ICFInternetISOCountryObj selectedObj = getSwingFocusAsISOCountry();
    boolean enableState;
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(enableState);
    }
    if (actionAddISOCountry != null) {
        actionAddISOCountry.setEnabled(true);
    }

    if (menuFile != null) {
        int itemCount = menuFile.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuFile.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionAddISOCountry) {
                    menuItem.setEnabled(true);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingISOCountryLanguageListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from w  w w .  jav  a2  s. co  m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetISOCountryLanguageObj selectedObj = getSwingFocusAsISOCountryLanguage();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddISOCountryLanguage != null) {
        actionAddISOCountryLanguage.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingISOCountryListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from   ww w .  ja v  a 2s  .  c  om*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetISOCountryObj selectedObj = getSwingFocusAsISOCountry();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddISOCountry != null) {
        actionAddISOCountry.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingISOCurrencyFinderJInternalFrame.java

public void adjustFinderMenuBar() {
    JMenuItem menuItem;
    Action act;/*from w  w  w .  ja v a  2 s .co  m*/
    String itemLabel;
    ICFInternetISOCurrencyObj selectedObj = getSwingFocusAsISOCurrency();
    boolean enableState;
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(enableState);
    }
    if (actionAddISOCurrency != null) {
        actionAddISOCurrency.setEnabled(true);
    }

    if (menuFile != null) {
        int itemCount = menuFile.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuFile.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionAddISOCurrency) {
                    menuItem.setEnabled(true);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingISOCurrencyListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;//from   w  w w  . j  a  v a 2s. c o m
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetISOCurrencyObj selectedObj = getSwingFocusAsISOCurrency();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddISOCurrency != null) {
        actionAddISOCurrency.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetSwing.CFInternetSwingISOLanguageListJPanel.java

public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;/*from w w  w .  j  a v a 2 s  . co m*/
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetISOLanguageObj selectedObj = getSwingFocusAsISOLanguage();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
        inEditState = true;
        if (getSwingContainer() != null) {
            allowAdds = true;
        } else {
            allowAdds = false;
        }
    } else {
        inEditState = false;
        allowAdds = false;
    }
    if (selectedObj == null) {
        enableState = false;
    } else {
        enableState = true;
    }

    if (actionViewSelected != null) {
        actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
        actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
        actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddISOLanguage != null) {
        actionAddISOLanguage.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
        menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
        menuSelected.setEnabled(enableState);
        int itemCount = menuSelected.getItemCount();
        for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
            menuItem = menuSelected.getItem(itemIdx);
            act = menuItem.getAction();
            if (act != null) {
                if (act == actionViewSelected) {
                    menuItem.setEnabled(enableState);
                } else if (act == actionEditSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                } else if (act == actionDeleteSelected) {
                    menuItem.setEnabled(inEditState && enableState);
                }
            }
        }
    }
}