Overlapping scrollbar arrow
When invoking the IMG_display_bitmap_aspect
method with both vertical and horizontal scrollbars enabled, the scroll arrow for the scrollbars may overlap in some cases. You can use one of the following ways to work around this issue:
- Adjust the height and width of the window.
- Adjust the zoom factor.
- Adjust the paint method used to display the bit map and the scroll bars.
Please see the sample Paint
method below:
public void paint(Graphics x_g)
{
Dimension p_dimension; Insets p_insets;
if (g_clearFlag)
{
p_dimension = getSize(); p_insets = getInsets();
p_dimension.width -= (p_insets.right + p_insets.left); p_dimension.height -= (p_insets.top + p_insets.bottom); x_g.setColor(getBackground());
x_g.fillRect(0, 0, p_dimension.width, p_dimension.height); x_g.setColor(getForeground());
g_clearFlag = false;
}
if (g_snowbnd != null)
{
int p_stat = 0; p_dimension = getSize(); p_insets = getInsets();
x_g.translate(p_insets.left, p_insets.top); g_snowbnd.fit_to_width(0); g_snowbnd.fit_to_height(0);
p_dimension.width -= (p_insets.right + p_insets.left); p_dimension.height -= (p_insets.top + p_insets.bottom); boolean hsbBeforePaint = g_snowbnd.hsb != null;
boolean vsbBeforePaint = g_snowbnd.vsb != null; p_stat = g_snowbnd
.IMG_display_bitmap_aspect(x_g, this,
0,
0,
p_dimension.width, p_dimension.height, 75);
boolean hsbAfterPaint = g_snowbnd.hsb != null; boolean vsbAfterPaint = g_snowbnd.vsb != null;
boolean scrollBarAddedInDisplay = (hsbAfterPaint && !hsbBeforePaint)
|| (vsbAfterPaint && !vsbBeforePaint); if (scrollBarAddedInDisplay)
{
/* paint again with new scollbar set up */ p_stat = g_snowbnd
.IMG_display_bitmap_aspect(x_g, this,
0,
0,
p_dimension.width, p_dimension.height, 75);
/* validate the container with the scroll bars */ validate();
}
if (p_stat < 0)
{
System.out.println("Error display bitmap aspect: stat = "
+ p_stat);
}
}
super.paintChildren(x_g);
}
Have questions, corrections, or concerns about this topic? Please let us know!