I'm writing an app in which I need to change the background color between black and an image as soon as I issue the command. I'm new to Swing so I'm not sure what I'm missing. I can change the background just fine, but I need it to happen before anything else happens. My code looks like this:
private void rhythmCopyingMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
try
{
RhythmCopyingTest rct = new RhythmCopyingTest();
//display black screen
mainPanel.setBackground(Color.BLACK);
rct.doNextTrial();
}
catch (Exception e) {}
}
What I wish would happen is for the background to change to black and then rct.doNextTrial() to happen. When I run this thing, rct.doNextTrial() clearly executed before the background changes to black. Does it just take a long time for the background to change?