src/solaris/classes/sun/awt/X11/XListPeer.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  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


1652             handleJavaMouseEventOnEDT(me);
1653             return true;
1654         }else if ((eventId == MouseEvent.MOUSE_PRESSED ||
1655                    eventId == MouseEvent.MOUSE_CLICKED) &&
1656                   (inVerticalScrollbar(me.getX(), me.getY()) ||
1657                    inHorizontalScrollbar(me.getX(), me.getY())))
1658         {
1659             if (eventId == MouseEvent.MOUSE_PRESSED) {
1660                 isScrollBarOriginated = true;
1661             }
1662             handleJavaMouseEventOnEDT(me);
1663             return true;
1664         }
1665         return false;
1666     }
1667 
1668     /*
1669      * Do handleJavaMouseEvent on EDT
1670      */
1671     void handleJavaMouseEventOnEDT(final MouseEvent me){
1672         EventQueue.invokeLater(new Runnable() {
1673                 public void run() {
1674                     handleJavaMouseEvent(me);
1675                 }
1676             });

1677     }
1678 
1679     /*
1680      * Fixed 5010944: List's rows overlap one another
1681      * The bug is due to incorrent caching of the list item size
1682      * So we should recalculate font metrics on setFont
1683      */
1684     public void setFont(Font f){
1685         super.setFont(f);
1686         initFontMetrics();
1687         layout();
1688         repaint();
1689     }
1690 
1691     /**
1692      * Sometimes painter is called on Toolkit thread, so the lock sequence is:
1693      *     awtLock -> Painter -> awtLock
1694      * Sometimes it is called on other threads:
1695      *     Painter -> awtLock
1696      * Since we can't guarantee the sequence, use awtLock.


   1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  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


1652             handleJavaMouseEventOnEDT(me);
1653             return true;
1654         }else if ((eventId == MouseEvent.MOUSE_PRESSED ||
1655                    eventId == MouseEvent.MOUSE_CLICKED) &&
1656                   (inVerticalScrollbar(me.getX(), me.getY()) ||
1657                    inHorizontalScrollbar(me.getX(), me.getY())))
1658         {
1659             if (eventId == MouseEvent.MOUSE_PRESSED) {
1660                 isScrollBarOriginated = true;
1661             }
1662             handleJavaMouseEventOnEDT(me);
1663             return true;
1664         }
1665         return false;
1666     }
1667 
1668     /*
1669      * Do handleJavaMouseEvent on EDT
1670      */
1671     void handleJavaMouseEventOnEDT(final MouseEvent me){
1672         InvocationEvent ev = new InvocationEvent(target, new Runnable() {
1673             public void run() {
1674                 handleJavaMouseEvent(me);
1675             }
1676         });
1677         postEvent(ev);
1678     }
1679 
1680     /*
1681      * Fixed 5010944: List's rows overlap one another
1682      * The bug is due to incorrent caching of the list item size
1683      * So we should recalculate font metrics on setFont
1684      */
1685     public void setFont(Font f){
1686         super.setFont(f);
1687         initFontMetrics();
1688         layout();
1689         repaint();
1690     }
1691 
1692     /**
1693      * Sometimes painter is called on Toolkit thread, so the lock sequence is:
1694      *     awtLock -> Painter -> awtLock
1695      * Sometimes it is called on other threads:
1696      *     Painter -> awtLock
1697      * Since we can't guarantee the sequence, use awtLock.