Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-20-2008, 11:19 PM
Member
 
Join Date: May 2008
Posts: 2
geoffreybarwise is on a distinguished road
Help with JButton - how to make a button blink
Hi!

I am currently developing a game - poker dice - for a major project in matric. The project is coming along swimmingly , but I still don't know how to make a JButton flash / blink. The intention is to attract the user's attention to the particular button.

Please can someone help me with the code / method for this problem. I am coding in Java format.

Thanks a million

Last edited by geoffreybarwise : 05-21-2008 at 12:43 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-21-2008, 07:08 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
If you mean Jbutton blinks,

do it in thread...
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-21-2008, 07:51 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
How about the use of a Timer. Define a array of colors, and with the timer tick change the background color of it.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-21-2008, 12:41 PM
Member
 
Join Date: May 2008
Posts: 2
geoffreybarwise is on a distinguished road
Array of colours
Thanks for the help man, i'll definately try that
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-21-2008, 12:48 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yes, why not. Try something like this. This is not what exactly you need, but the logic is there.

Code:
import java.awt.*; import java.awt.event.*; import java.util.Random; import javax.swing.*; public class ButtonBlinker extends JFrame { private JButton btn; final Color[] colors = {Color.RED, Color.GREEN, Color.ORANGE}; ButtonBlinker() { Container content = getContentPane(); btn = new JButton("Blinker"); content.add(btn); pack(); setVisible(true); } public static void main(String[] args) { new ButtonBlinker().blinkTimer(); } private void blinkTimer(){ Timer tt = new Timer(2000, new ActionListener() { public void actionPerformed(ActionEvent e) { btn.setBackground(colors[colorChoocer()]); } }); tt.start(); } private int colorChoocer() { return new Random().nextInt(3); } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with JButton and layout adlb1300 AWT / Swing 1 12-25-2007 10:33 AM
Need help with JButton event adlb1300 New To Java 2 11-19-2007 03:15 AM
mouse over on JButton gradon Java Applets 1 08-04-2007 07:50 AM
Few action in one Jbutton kubiasty New To Java 0 07-25-2007 12:19 PM
Mouse over JButton sandor AWT / Swing 1 05-17-2007 11:15 PM


All times are GMT +3. The time now is 07:50 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org