KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > plaf > css > ScrollPaneCG


1 /*
2  * $Id: ScrollPaneCG.java,v 1.1 2005/01/23 19:31:33 blueshift Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.plaf.css;
15
16 import org.wings.*;
17 import org.wings.io.Device;
18
19 import java.awt.*;
20 import java.io.IOException JavaDoc;
21
22 public class ScrollPaneCG extends org.wings.plaf.css.AbstractComponentCG implements org.wings.plaf.ScrollPaneCG {
23     public void write(Device device, SComponent component) throws IOException JavaDoc {
24         SScrollPane scrollPane = (SScrollPane) component;
25         Scrollable scrollable = scrollPane.getScrollable();
26         SScrollPaneLayout layout = (SScrollPaneLayout) scrollPane.getLayout();
27
28         if (!layout.isPaging() && scrollable instanceof SComponent) {
29             SComponent center = (SComponent) scrollable;
30             Rectangle viewportSize = scrollable.getViewportSize();
31             SDimension preferredSize = center.getPreferredSize();
32             try {
33                 scrollable.setViewportSize(scrollable.getScrollableViewportSize());
34                 center.setPreferredSize(component.getPreferredSize());
35                 component.setPreferredSize(null);
36                 super.write(device, component);
37             } finally {
38                 component.setPreferredSize(center.getPreferredSize());
39                 scrollable.setViewportSize(viewportSize);
40                 center.setPreferredSize(preferredSize);
41             }
42         } else
43             super.write(device, component);
44     }
45
46     public void writeContent(Device d, SComponent c)
47             throws IOException JavaDoc {
48         SScrollPane scrollPane = (SScrollPane) c;
49         scrollPane.synchronizeAdjustables();
50         Utils.renderContainer(d, scrollPane);
51     }
52 }
53
54
55
Popular Tags