Jump to content


[Java] Properly using .onClick()


1 reply to this topic

#1 logical2u

    Professional

  • Member
  • 382 posts
  • Projects: A figment of my imagination

Posted 16 January 2008 - 23:44

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....
Keep Going On Till Dawn
How Many Times Must Another Line Be Drawn
We Could Be Down And Gone
But We Hold On

#2 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 18 January 2008 - 17:43

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.
CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users