Find a Method...
Someone can explain a Method to hide panels?, with a range included like this:
pnlPanel[0] = go Back, log off, Close
[1] = Login
[2] = Main Panel Admin
[3] = Mmaintenance (Container)
[4] = Opciones de Maintenance (Toggles left)
[5] = Acciones de Maintenance (Toggle ups)
[6] = Card entrance
[7] = Card consultation
[8] = Card Modification
[9] = Card Elimination
[10] = Listed of Cards
[11] = Entrance of Employees
[12] = Consulta de Empleados
[13] = Modification of Employees
[14] = Elimination of Employees
[15] = Listed of Employees
[16] = Reportes (Container)
[17] = Options of Reports
[18] = Sold Cards - Reports
[19] = Cards with Balance - Reports
[20] = Conducted Sales - Reports
[21] = Payment of Gains - Reports
[22] = Main Panel Employee
[23] = Box (Container)
[24] = Options of Box (Toggles)
[25] = Sales Comprobant
[26] = Sales Comproban II // Sales Comprobant Panels To show Together
[27] = Payment of Gains I and [28] = Payment of Gains II // Again both together to show
[29] = Main Pane User
[30] = Panel Entered To verify if the Client counts with cash
[31] = Simulation (Container) ....... [37] = Simulation
Some method for example to hide from Panels[23-29] and show 22 Main Panel or hide Panels[30-37] to show 29 Main Panel.. some know how? Thanx for patient
[1477 byte] By [
iTzAngela] at [2007-11-26 15:10:25]

like that, but first to know if the panel isVisible:
int i;
for(i=1;i<38;i++){
if((i>3&&i<16)||(i>16&&i<22)||(i>22&&i<28)||(i==23)||(i>32&&i<38))
continue;
if(pnlPaneles[i].isVisible())
break;
}
return i;
}
And to know the Panels to want hide with 2 parameters:
int estaVisible(int inicio, int fin){
int i=0;
for(i=inicio;i<=fin;i++)
if(pnlPaneles[i].isVisible())
break;
return i;
}
How about this? You can write a method to change the visibility of a consecutive group all at once:
void setPanelsVisible(int inicio, int fin, boolean visible){
for(int i=inicio;i<=fin;i++) {
pnlPaneles[i].setVisible(visible);
}
}
You can then call:
setPanelsVisible(25, 29, false); // set them all invisible
setPanelsVisible(25, 29, true); // set them all visible
Note that you don't need to check their visibility before you change it.
=====================
Or, as I suggested before:
JPanel employeePanel = new JPanel();
for(int i=25;i<=29;i++) {
employeePanel.add(pnlPaneles[i]);
}
Add employeePanel to your main panel. Then:
employeePanel.setVisible(false);
employeePanel.setVisible(true);
Then you don't need to set each panel to invisible individually.
You can check isVisible if you want. But, I think you probably want to study some more about layouts (as suggested in your other thread). If you have a group of 4 that get replaced by another group of 4 (or however many at a time), a CardLayout may be useful (with other layouts for each panel in the group of 4). I know you posted a link to code in your other thread, but I don't think I can read a .rar file.
You probably need to reorganize your code (as someone in your other thread suggested). If you have to do so much checking to see what is visible and what isn't in order to figure out what has to be displayed or undisplayed, you probably need a better design. Maybe you need a Map (e.g., HashMap) of panel numbers to be displayed when a given panel is undisplayed (and undisplayed when a panel is displayed). It's hard to tell exactly what to suggest, because I didn't look at all of your code (only the stuff you actually posted on this forum, not the linked .rar file). Maybe you just need more than one array, instead of having everything in one array. Your code will be confusing will all of those array numbers, anyway. At the least, you could define constants for the indexes, so you could say:
if (pnlPaneles[MAIN_EMPLOYEE_PANEL].isVisible())
{
pnlPaneles[BOX].setVisible(true);
pnlPaneles[OPTIONS_OF_BOX].setVisible(true);
...
}
Easier to read than 22, 23, 24, ...