• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

blinking tab pane

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i created a tabbed pane with 3 jPanel.
1 of them is for output display.
how can i make it's title blinking when there is output to be displayed?
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can write a thread for setting the title of the Output tab (say tab #3 in (0, 1, 2, 3)) TABBEDPANE.setTitleAt(3, "Output") and TABBEDPANE.setTitleAt(3, " ") alternately with a 600 ms delay(sleep interval)...
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tarun Bolla wrote:You can write a thread for setting the title of the Output tab (say tab #3 in (0, 1, 2, 3)) TABBEDPANE.setTitleAt(3, "Output") and TABBEDPANE.setTitleAt(3, " ") alternately with a 600 ms delay(sleep interval)...



Did you try that to see what happens?

Also, I recommend you go through these two tutorials: How to Use Swing Timers and Concurrency in Swing.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sk said wrote:i created a tabbed pane with 3 jPanel.
1 of them is for output display.
how can i make it's title blinking when there is output to be displayed?



You can try using setForegroundAt(...) using a Swing Timer.
 
Tarun Bolla
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:
Did you try that to see what happens?



Here is a sample code that demonstrates what i mean...



After running it...click on the JLabel with Text "1" in the first tab and see that the output tab text blinks...
 
Sheriff
Posts: 22787
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I personally would never use blinking. I'd instead use colouring - make it red or something like that when there's output, then make it black again when the tab is selected. Since Java 6 JTabbedPane has method setTabComponentAt which allows you to set a simple JLabel for that one tab, letting the default UI work for the others. There's no need for a timer then; keep a reference to this JLabel and simply change its foreground colour when needed.

Edit: or use setForegroundAt. I never knew this method existed. Thanks Darryl!

And Tarun, you clearly have not read the concurrency in Swing page Darryl linked to, or you wouldn't be using a regular thread.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tarun Bolla wrote:

Darryl Burke wrote:
Did you try that to see what happens?



Here is a sample code that demonstrates what i mean...



1. That's not what you wrote earlier.

TABBEDPANE.setTitleAt(3, "Output") and TABBEDPANE.setTitleAt(3, " ")



2. The number of spaces is totally dependent on the Font, making this a very fragile 'solution'.

Here's a more robust approach:
 
Tarun Bolla
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If not spaces ... colors can do that....

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic