When my program starts, my JProgressBar runs just like I want it and shows the progress of my program loading, but I have a restart function for the database and I have to use the dispose() to reset all the components and thus reloading all the components.
The restart process is exactly the same as startup, but in this instance the JProgressbar Doesn't load at all(Just a blank window), the whole class doesn't want to work.
a run through the below code: the If statement tests if the database file exists, from there it loads the progress bar class and sets i's max parameters and values. As the database and GUI loads it then increases the value of the Progress Bar and when the GUI is done loading, it uses the dispose() to close the window the JProgressBar uses. It goes on that if it is not there it will restart it with a new JProgressBar.
What I know is that when it the progressbar is loaded the first time, it will work. BUT when I need it a second time, it fails. Even if I reset the Values, it still doesn't want to work.
GUIBackEnd()
{
if(ec.hasDatabase())
{
pbc = new ProgressBarController(23, "Initializing E.M.M.A.", true);
pbc.setProgressText("Start-up");
update();
pbc.increaseBar();
pbc.setProgressText("Loading Equipment");
equipmentData = ec.viewEquipment();
pbc.increaseBar();
pbc.setProgressText("Loading Customers");
customerData = cc.viewCustomer();
pbc.increaseBar();
pbc.setProgressText("Loading Services");
serviceData = mc.viewService();
pbc.increaseBar();
pbc.setProgressText("Loading GUI");
frameGen();
pbc.dispose();
}
else
{
JOptionPane.showMessageDialog(null, "Main database was not found. \nE.M.M.A. will attempt to load the backup...", "WARNING",
JOptionPane.WARNING_MESSAGE);
String feed = ec.loadMainBackup();
JOptionPane.showMessageDialog(null, feed, "Loading",
JOptionPane.INFORMATION_MESSAGE);
if(!EquipmentController.hasLoaded)
{
JOptionPane.showMessageDialog(null, EquipmentController.mainLoaded, "RESTART", JOptionPane.PLAIN_MESSAGE);
restartGUI(true);
}
else
{
pbc = new ProgressBarController(23, "Initializing E.M.M.A.", true);
pbc.setProgressText("Start-up");
update();
pbc.increaseBar();
pbc.setProgressText("Loading Equipment");
equipmentData = ec.viewEquipment();
pbc.increaseBar();
pbc.setProgressText("Loading Customers");
customerData = cc.viewCustomer();
pbc.increaseBar();
pbc.setProgressText("Loading Services");
serviceData = mc.viewService();
pbc.increaseBar();
pbc.setProgressText("Loading GUI");
frameGen();
pbc.dispose();
}
}
}
What I need from this, is that I should be able to call the JProgressBar anytime during the program and have it show the user the progress the program is taking while working in the background... reason is that, as the database grows or when imports are done, it takes time and The program has to show that it is working on the task and not just idling there.