My GUI is made by Netbeans Manager. Im trying to modify JComponents in my Frame that has a JTabbedPane:
When te user logged in. I need to set some Data in JTextFields with the UserData , and Enable some JTabbedPane tabs according its profile.
Im using ActionEvent
in my loginButton to do my app login:
private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {
//I have a DAO that Return a Object with the DB retrieved data
UserDAOConcrete userDAO = UserDAOFactory.getUserDAO("user");
Users userData = userDAO.login(Integer.parseInt(loginUserId.getText()), String.valueOf(userLoginPassword.getPassword()));
//And then passing JComponents/param to a method to "configure" my JFrame
int getItemsInCostCenter = InventoryDAO.getInventory(userData.getUserCencos());
//Class: GUI to deal with JComponents behaviour
GUI.configGUIByUser(tranferTabGroup, userData, getItemsInCostCenter);
}
Method:
public static void configGUIByUser(JTabbedPane tabs, Users userData, int itemsInCostCenter) throws NullPointerException {
if (itemsInCostCenter == 0) {
tabs.setEnabledAt(1, false);
tabs.setEnabledAt(0, true);
tabs.setSelectedIndex(0);
JOptionPane.showMessageDialog(null, "No se encontraron Elementos en Cencos: " + userData.getUserCencos(), cf.WINDOW_TITLE, JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "Bienvenido: " + userData.getUserName(), cf.WINDOW_TITLE, JOptionPane.INFORMATION_MESSAGE);
tabs.setEnabledAt(0, false);
JOptionPane.showMessageDialog(null, "Cargando Inventarios de Centro de Costo: " + userData.getUserCencos(), cf.WINDOW_TITLE, JOptionPane.INFORMATION_MESSAGE);
tabs.setSelectedIndex(0);
}
}
So my code is working as intended , but I dont know if Im doing fine. I have 2 questions: Im breaking some Programming practices?. And is there a way to access JComponents of my JFrame ? I tried some of the code here but , I still cant access JFrame Components from my GUI Class.
Thanks in advance for your help.