< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/InfoWindow.java

Print this page




  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt.X11;
  27 
  28 import java.awt.*;
  29 import java.awt.event.*;
  30 import java.awt.peer.TrayIconPeer;
  31 import sun.awt.*;
  32 import sun.misc.ManagedLocalsThread;
  33 
  34 import java.awt.image.*;
  35 import java.text.BreakIterator;
  36 import java.util.concurrent.ArrayBlockingQueue;
  37 import java.security.AccessController;
  38 import java.security.PrivilegedAction;
  39 import java.lang.reflect.InvocationTargetException;
  40 
  41 /**
  42  * An utility window class. This is a base class for Tooltip and Balloon.
  43  */
  44 @SuppressWarnings("serial") // JDK-implementation class
  45 public abstract class InfoWindow extends Window {
  46     private Container container;
  47     private Closer closer;
  48 
  49     protected InfoWindow(Frame parent, Color borderColor) {
  50         super(parent);
  51         setType(Window.Type.POPUP);
  52         container = new Container() {


 435             public void mouseClicked(MouseEvent e) {
 436                 // hide the balloon by any click
 437                 hide();
 438                 if (e.getButton() == MouseEvent.BUTTON1) {
 439                     ActionEvent aev = new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
 440                                                       liveArguments.getActionCommand(),
 441                                                       e.getWhen(), e.getModifiers());
 442                     XToolkit.postEvent(XToolkit.targetToAppContext(aev.getSource()), aev);
 443                 }
 444             }
 445         }
 446 
 447         private class Displayer implements Runnable {
 448             final int MAX_CONCURRENT_MSGS = 10;
 449 
 450             ArrayBlockingQueue<Message> messageQueue = new ArrayBlockingQueue<Message>(MAX_CONCURRENT_MSGS);
 451             boolean isDisplayed;
 452             final Thread thread;
 453 
 454             Displayer() {
 455                 this.thread = new ManagedLocalsThread(this);
 456                 this.thread.setDaemon(true);
 457             }
 458 
 459             @Override
 460             public void run() {
 461                 while (true) {
 462                     Message msg = null;
 463                     try {
 464                         msg = messageQueue.take();
 465                     } catch (InterruptedException e) {
 466                         return;
 467                     }
 468 
 469                     /*
 470                      * Wait till the previous message is displayed if any
 471                      */
 472                     XToolkit.awtLock();
 473                     try {
 474                         while (isDisplayed) {
 475                             try {




  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt.X11;
  27 
  28 import java.awt.*;
  29 import java.awt.event.*;
  30 import java.awt.peer.TrayIconPeer;
  31 import sun.awt.*;

  32 
  33 import java.awt.image.*;
  34 import java.text.BreakIterator;
  35 import java.util.concurrent.ArrayBlockingQueue;
  36 import java.security.AccessController;
  37 import java.security.PrivilegedAction;
  38 import java.lang.reflect.InvocationTargetException;
  39 
  40 /**
  41  * An utility window class. This is a base class for Tooltip and Balloon.
  42  */
  43 @SuppressWarnings("serial") // JDK-implementation class
  44 public abstract class InfoWindow extends Window {
  45     private Container container;
  46     private Closer closer;
  47 
  48     protected InfoWindow(Frame parent, Color borderColor) {
  49         super(parent);
  50         setType(Window.Type.POPUP);
  51         container = new Container() {


 434             public void mouseClicked(MouseEvent e) {
 435                 // hide the balloon by any click
 436                 hide();
 437                 if (e.getButton() == MouseEvent.BUTTON1) {
 438                     ActionEvent aev = new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
 439                                                       liveArguments.getActionCommand(),
 440                                                       e.getWhen(), e.getModifiers());
 441                     XToolkit.postEvent(XToolkit.targetToAppContext(aev.getSource()), aev);
 442                 }
 443             }
 444         }
 445 
 446         private class Displayer implements Runnable {
 447             final int MAX_CONCURRENT_MSGS = 10;
 448 
 449             ArrayBlockingQueue<Message> messageQueue = new ArrayBlockingQueue<Message>(MAX_CONCURRENT_MSGS);
 450             boolean isDisplayed;
 451             final Thread thread;
 452 
 453             Displayer() {
 454                 this.thread = new Thread(null, this, "Displayer", 0, false);
 455                 this.thread.setDaemon(true);
 456             }
 457 
 458             @Override
 459             public void run() {
 460                 while (true) {
 461                     Message msg = null;
 462                     try {
 463                         msg = messageQueue.take();
 464                     } catch (InterruptedException e) {
 465                         return;
 466                     }
 467 
 468                     /*
 469                      * Wait till the previous message is displayed if any
 470                      */
 471                     XToolkit.awtLock();
 472                     try {
 473                         while (isDisplayed) {
 474                             try {


< prev index next >