src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java

Print this page


   1 /*
   2  * Copyright (c) 2002, 2010, 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


 213     private SynthContext getContext(JComponent c, int state) {
 214         return SynthContext.getContext(SynthContext.class, c,
 215                     SynthLookAndFeel.getRegion(c), style, state);
 216     }
 217 
 218     private int getComponentState(JComponent c) {
 219         int baseState = SynthLookAndFeel.getComponentState(c);
 220         if (viewportViewFocusHandler!=null && viewportViewHasFocus){
 221             baseState = baseState | FOCUSED;
 222         }
 223         return baseState;
 224     }
 225 
 226     public void propertyChange(PropertyChangeEvent e) {
 227         if (SynthLookAndFeel.shouldUpdateStyle(e)) {
 228             updateStyle(scrollpane);
 229         }
 230     }
 231 
 232 
 233 
 234     private class ViewportBorder extends AbstractBorder implements UIResource {
 235         private Insets insets;
 236 
 237         ViewportBorder(SynthContext context) {
 238             this.insets = (Insets)context.getStyle().get(context,
 239                                             "ScrollPane.viewportBorderInsets");
 240             if (this.insets == null) {
 241                 this.insets = SynthLookAndFeel.EMPTY_UIRESOURCE_INSETS;
 242             }
 243         }
 244 
 245         @Override
 246         public void paintBorder(Component c, Graphics g, int x, int y,
 247                             int width, int height) {
 248             JComponent jc = (JComponent)c;
 249             SynthContext context = getContext(jc);
 250             SynthStyle style = context.getStyle();
 251             if (style == null) {
 252                 assert false: "SynthBorder is being used outside after the " +
 253                               " UI has been uninstalled";


   1 /*
   2  * Copyright (c) 2002, 2014, 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


 213     private SynthContext getContext(JComponent c, int state) {
 214         return SynthContext.getContext(SynthContext.class, c,
 215                     SynthLookAndFeel.getRegion(c), style, state);
 216     }
 217 
 218     private int getComponentState(JComponent c) {
 219         int baseState = SynthLookAndFeel.getComponentState(c);
 220         if (viewportViewFocusHandler!=null && viewportViewHasFocus){
 221             baseState = baseState | FOCUSED;
 222         }
 223         return baseState;
 224     }
 225 
 226     public void propertyChange(PropertyChangeEvent e) {
 227         if (SynthLookAndFeel.shouldUpdateStyle(e)) {
 228             updateStyle(scrollpane);
 229         }
 230     }
 231 
 232 
 233     @SuppressWarnings("serial") // Superclass is not serializable across versions
 234     private class ViewportBorder extends AbstractBorder implements UIResource {
 235         private Insets insets;
 236 
 237         ViewportBorder(SynthContext context) {
 238             this.insets = (Insets)context.getStyle().get(context,
 239                                             "ScrollPane.viewportBorderInsets");
 240             if (this.insets == null) {
 241                 this.insets = SynthLookAndFeel.EMPTY_UIRESOURCE_INSETS;
 242             }
 243         }
 244 
 245         @Override
 246         public void paintBorder(Component c, Graphics g, int x, int y,
 247                             int width, int height) {
 248             JComponent jc = (JComponent)c;
 249             SynthContext context = getContext(jc);
 250             SynthStyle style = context.getStyle();
 251             if (style == null) {
 252                 assert false: "SynthBorder is being used outside after the " +
 253                               " UI has been uninstalled";