gate.gui.TabBlinker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gate-core Show documentation
Show all versions of gate-core Show documentation
GATE - general achitecture for text engineering - is open source
software capable of solving almost any text processing problem. This
artifact enables you to embed the core GATE Embedded with its essential
dependencies. You will able to use the GATE Embedded API and load and
store GATE XML documents. This artifact is the perfect dependency for
CREOLE plugins or for applications that need to customize the GATE
dependencies due to confict with their own dependencies or for lower
footprint.
The newest version!
/* TabBlinker.java
*
* Copyright (c) 1995-2012, The University of Sheffield. See the file
* COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
*
* This file is part of GATE (see http://gate.ac.uk/), and is free
* software, licenced under the GNU Library General Public License,
* Version 2, June 1991 (in the distribution as file licence.html,
* and also available at http://gate.ac.uk/gate/licence.html).
*
* Valentin Tablan 30/03/2001
*
* $Id: TabBlinker.java 17530 2014-03-04 15:57:43Z markagreenwood $
*
*/
package gate.gui;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
public class TabBlinker implements Runnable{
public TabBlinker(JTabbedPane pane, Component comp, Color blinkColor){
this.tPane = pane;
this.tab = tPane.indexOfComponent(comp);
this.blinkColor = blinkColor;
thread = new Thread(Thread.currentThread().getThreadGroup(),
this,
"TabBlinker1");
thread.setPriority(Thread.MIN_PRIORITY);
}// TabBlinker(JTabbedPane pane, Component comp, Color blinkColor)
@Override
public void run(){
oldColor = tPane.getBackgroundAt(tab);
synchronized(this){
stopIt = false;
}
while(true){
synchronized(this){
if(tPane.getSelectedIndex() == tab) stopIt = true;
if(stopIt){
tPane.setBackgroundAt(tab, oldColor);
return;
}
}
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run(){
if(tPane.getBackgroundAt(tab).equals(oldColor)){
tPane.setBackgroundAt(tab, blinkColor);
}else{
tPane.setBackgroundAt(tab, oldColor);
}
}// run()
});
try {
Thread.sleep(400);
} catch(InterruptedException ie){}
}// while
}//run()
public void stopBlinking(int foo){
synchronized(this){
if(thread.isAlive()){
stopIt = true;
}
}
}// void stopBlinking()
public void startBlinking(){
synchronized(this){
if(!thread.isAlive()){
thread = new Thread(Thread.currentThread().getThreadGroup(),
this,
"TabBlinker2");
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
}// void startBlinking()
boolean stopIt;
JTabbedPane tPane;
int tab;
Color blinkColor;
Color oldColor;
Thread thread;
}//class TabBlinker implements Runnable