I have been trying to display a number of jpanels after one another with different timings between each. I have used swing timer, thread.sleep and int++ counters to try and create spacing between the display of each jpanel, each without success.
In a previous post, I was told that timers would be the best option. I have tried many different tutorials and have had no luck at all, tbh I really do not understand its implementation.
my button that initiates the whole process uses a mouseListener, whereas all tutorials I have read refer to using ActionListeners which has confused me further.
Could I ask that someone enlightens me with how this process would be achieved.
What would be coded in my comment parts?
if (a.getSource() == button){
panel1.setVisible(true);
ActionListener listener = new ActionListener(){
public void actiinPerformed(ActionEvent event){
panel1.setVisible(false);
panel2.setVisible(true);
}
};
Timer timer = new Timer(4000, listener);
timer.start();
// This is one method I tried, and even ifit had worked I wouldnt know where to begin timing the following panels.Would I create a new timer for each part of the panel exchange?
// panel1.setVisible(false);
// panel2.setVisible(true);
// panel2.setVisible(false);
// panel3.setVisible(true);
// panel3.setVisible(false);
// menu.setVisible(true);
}
Thanks in advance guys.