ContextMenuAuxScrollBarUI.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:2k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: ContextMenuAuxScrollBarUI.java,v 1.4 2005/10/13 08:59:57 kleopatra Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  */
  21. package org.jdesktop.swingx.plaf;
  22. import java.awt.Graphics;
  23. import java.awt.event.MouseListener;
  24. import javax.swing.JComponent;
  25. import javax.swing.JScrollBar;
  26. import javax.swing.plaf.ComponentUI;
  27. import javax.swing.plaf.ScrollBarUI;
  28. /**
  29.  * @author Jeanette Winzenburg
  30.  */
  31. public class ContextMenuAuxScrollBarUI extends ScrollBarUI {
  32.     
  33.     private MouseListener mouseHandler;
  34.     private JScrollBar scrollBar;
  35.     
  36.     public static ComponentUI createUI(JComponent c) {
  37.         return new ContextMenuAuxScrollBarUI(); 
  38.     }
  39.     // PENDING: need to listen to orientation changes
  40.     // 
  41.     public void installUI(JComponent comp) {
  42.         this.scrollBar = (JScrollBar) comp;
  43.         comp.addMouseListener(getMouseListener());
  44.     }
  45.     // PENDING: need to cleanup references - 
  46.     // DelegateAction holds a reference to the comp!
  47.     public void uninstallUI(JComponent comp) {
  48.         comp.removeMouseListener(getMouseListener());
  49.         this.scrollBar = null;
  50.     }
  51.     private MouseListener getMouseListener() {
  52.         if (mouseHandler == null) {
  53.             mouseHandler = createPopupHandler();
  54.         }
  55.         return mouseHandler;
  56.     }
  57.     private MouseListener createPopupHandler() {
  58.         return new ContextMenuHandler(createContextSource());
  59.     }
  60.     private ContextMenuSource createContextSource() {
  61.         return new ScrollBarContextMenuSource(scrollBar.getOrientation());
  62.     }
  63.     public void update(Graphics g, JComponent c) {
  64.     }
  65.     
  66. }