ScrollPanel.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
/*
* Copyright (C) 1996 Active Software, Inc.
* All rights reserved.
*
* @(#) ScrollPanel.java 1.41 - last change made 07/25/97
*/
public class ScrollPanel extends VJPanel {
private boolean hasFocus;
private int scrollAreaWidth = 0;
private int scrollAreaHeight = 0;
private Insets scrollAreaInsets;
public ScrollPanel() {
super(Util.WIN95_FIELD_BORDER);
GBConstraints c = new GBConstraints();
c.gridx = 1;
c.gridy = 0;
c.shrinkx = false;
c.shrinky = true;
// #ifdef JDK1.1
// #else
// super.add(vbar, -1);
// #endif
c.gridx = 0;
c.gridy = 1;
c.shrinkx = true;
c.shrinky = false;
// #ifdef JDK1.1
// #else
// super.add(hbar, -1);
// #endif
// Have the initial minimumSize include the vertical scrollbar,
// but not the horizontal scrollbar.
vshow = true;
}
// #ifdef JDK1.1
int index) {
}
// #else
// public Component add(Component comp, int pos) {
// super.add(comp, pos);
// doAdd(comp);
// return comp;
// }
// #endif
if (!(comp instanceof Scrollable))
"sunsoft.jws.visual.rt.awt.ScrollPanel.OnlyOneInstance"));
GBConstraints c = new GBConstraints();
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
c.weighty = 1;
c.shrinkx = true;
c.shrinky = true;
c.insets = scrollAreaInsets;
}
public int getScrollAreaWidth() {
return scrollAreaWidth;
}
public void setScrollAreaWidth(int scrollAreaWidth) {
this.scrollAreaWidth = scrollAreaWidth;
}
public int getScrollAreaHeight() {
return scrollAreaHeight;
}
public void setScrollAreaHeight(int scrollAreaHeight) {
this.scrollAreaHeight = scrollAreaHeight;
}
public Insets getScrollAreaInsets() {
return scrollAreaInsets;
}
}
}
public int getVisibleIndex() {
if (!vshow)
return 0;
}
public void makeVisible(int index) {
if (!vshow)
return;
if (index == -1)
return;
int y = lineHeight*index;
if (y < scrolly) {
scrollable.scrollY(y);
if (y < 0)
y = 0;
scrollable.scrollY(y);
}
}
public boolean handleEvent(Event e) {
hasFocus = true;
return super.handleEvent(e);
hasFocus = false;
return super.handleEvent(e);
else
return super.handleEvent(e);
return true;
}
// take out our insets
if (scrollAreaInsets == null)
}
// Always leave space for the scrollbars
public Dimension minimumSize() {
}
else
}
// Always leave space for the scrollbars
public Dimension preferredSize() {
}
else
}
if (scrollAreaInsets == null)
if (scrollAreaWidth != 0)
if (scrollAreaHeight != 0)
insetsWidth));
insetsHeight));
return compMin;
}
public void layout() {
super.layout();
return;
}
Dimension d;
boolean revalidate = false;
needHShow = true;
needVShow = true;
if (needVShow) {
d = vbar.minimumSize();
needHShow = true;
} else if (needHShow) {
d = hbar.minimumSize();
needVShow = true;
}
}
if (needHShow) {
if (!hshow) {
hshow = true;
revalidate = true;
}
} else {
if (hshow) {
hshow = false;
revalidate = true;
}
}
if (needVShow) {
if (!vshow) {
vshow = true;
revalidate = true;
}
} else {
if (vshow) {
vshow = false;
revalidate = true;
}
}
if (hshow)
if (vshow)
if (revalidate) {
validate();
comp.requestFocus();
} else {
super.layout();
}
}
public void updateWindow() {
invalidate();
validate();
}
protected void updateHScrollbar() {
if (vshow) {
}
// (viewSize.width-d.width) can become negative
// during initialization
return;
// #ifndef MAXIMUM_HACK
// maximum -= viewSize.width;
// #endif
pageSize);
}
protected void updateVScrollbar() {
if (hshow) {
}
// (viewSize.height-d.height) can become
// negative during initialization
return;
// #ifndef MAXIMUM_HACK
// maximum -= viewSize.height;
// #endif
int pageSize =
pageSize);
}
}