←  Code Block

Fallout Studios Forums

»

[Java] Properly using .onClick()

logical2u's Photo logical2u 16 Jan 2008

So, I'm writing a GUI app for an old Java (1.5) and I'm trying to create an automatic splash screen. I'm trying to do this by having a button automatically clicked after the panel and its components are written, and then that click starts a timer, which upon completion closes the window.

[Note that Jbutton is my example button]

The code in itself works. However, if I set the button to be clicked (using Jbutton.doClick() inside the overloaded primary class), once I run it, the only thing that loads in the panel is the Button, and everything else is invisible or transparent. Setting the panel to reset itself once the button was clicked didn't work, and I can't set the doClick anywhere else without running into a Static/Non-static problem or getting "<identifier expected> at JButton.doClick();

I can't figure out what to do from here....
Quote

CodeCat's Photo CodeCat 18 Jan 2008

The problem is that no matter what you'll do, if you do something resource intensive, it holds back the entire thread. So an easy solution would be to do the processing in a separate thread, and then send the primary thread a message of some kind when it's done.
Quote