public class Scrollbar extends StyledWidget
The size of a scrollbar is dependent on the font size.
This example shows a simple scrollbar:
Scrollbar scrollbar = new Scrollbar(100); scrollbar.setHorizontal(false); scrollbar.show(); scrollbar.setValue(50);
This example shows a styled scrollbar:
Scrollbar scrollbar = new Scrollbar(100); scrollbar.show(); scrollbar.setHorizontal(false); scrollbar.setValue(50); EditableStyle scrollbarStyle = new EditableStyle(); scrollbarStyle.setForegroundColor(Colors.BLUE); scrollbarStyle.setBackgroundColor(Colors.SILVER); scrollbarStyle.setPadding(new SimpleOutline(1)); scrollbar.mergeStyle(scrollbarStyle);
EMPTY_ELEMENT_ARRAY
Constructor and Description |
---|
Scrollbar(int maximum)
Creates a new scrollbar with the specified size.
|
Modifier and Type | Method and Description |
---|---|
int |
getMaximum()
Gets the max step.
|
int |
getValue()
Gets the current value.
|
int |
getVisibilityLevel()
From
GraphicsContext.TRANSPARENT (hidden) to GraphicsContext.OPAQUE (fully visible). |
void |
hide()
Hides the scrollbar.
|
void |
hideNotify() |
boolean |
isHorizontal() |
void |
renderContent(ej.microui.display.GraphicsContext g,
Style style,
Rectangle bounds)
Renders the content of the renderable without the border, margin and padding specified in the style.
|
void |
setHorizontal(boolean horizontal)
Sets the scrollbar orientation: horizontal or vertical.
|
void |
setMaximum(int maximum)
Sets the maximum bound of the scrollbar.
|
void |
setValue(int value)
Sets the current value.
|
void |
show()
Shows the scrollbar.
|
void |
showNotify() |
void |
updateValue(int increment)
Updates the current value with an increment.
|
Rectangle |
validateContent(Style style,
Rectangle bounds)
Gets the content size of the renderable without the border, margin and padding specified in the style.
|
addClassSelector, contains, gainFocus, getAttribute, getChild, getChildrenCount, getChildrenElements, getContentBounds, getParentElement, getStyle, hasClassSelector, isInState, isTransparent, lostFocus, mergeStyle, removeAllClassSelectors, removeClassSelector, removeInstanceStyle, render, setClassSelectors, setEnabled, updateStyle, updateStyleOnly, validate
getAbsoluteX, getAbsoluteX, getAbsoluteY, getAbsoluteY, getEventHandler, getHeight, getPanel, getParent, getPreferredHeight, getPreferredWidth, getRelativeX, getRelativeY, getWidgetAt, getWidth, getX, getY, handleEvent, hasFocus, invalidate, isEnabled, isShown, isValid, isVisible, repaint, repaint, requestFocus, requestFocus, revalidate, revalidateSubTree, setBounds, setEventHandler, setLocation, setPreferredSize, setSize, setVisible
public Scrollbar(int maximum)
maximum
- the maximum bound.public void setHorizontal(boolean horizontal)
horizontal
- true
to set the slider horizontal, false
to set the slider vertical.public Rectangle validateContent(Style style, Rectangle bounds)
StyledRenderable
style
- the style to use.bounds
- the bounds available for the content. A width or a height equals to MWT.NONE
means no
constraint on this dimension.public void renderContent(ej.microui.display.GraphicsContext g, Style style, Rectangle bounds)
StyledRenderable
The given graphics context is translated and clipped according to the given bounds (the border, margin and padding are applied on this graphics context before).
g
- the graphics context where to render the content of the renderable.style
- the style to use.bounds
- the remaining size to render the content.Outline.apply(GraphicsContext, Rectangle)
,
Border.apply(GraphicsContext, Rectangle, int)
,
StyleHelper.renderWithoutContent(GraphicsContext, Rectangle, Style)
public void hide()
public void showNotify()
showNotify
in interface ej.mwt.Renderable
showNotify
in class ej.mwt.Widget
public void hideNotify()
hideNotify
in interface ej.mwt.Renderable
hideNotify
in class ej.mwt.Widget
public void show()
public int getVisibilityLevel()
GraphicsContext.TRANSPARENT
(hidden) to GraphicsContext.OPAQUE
(fully visible).public boolean isHorizontal()
true
if the scrollbar is horizontal, false
otherwise.public int getMaximum()
public int getValue()
public void updateValue(int increment)
increment
- the increment to apply to the current value.public void setValue(int value)
The scrollbar is not repainted. The caller is responsible for the repaint.
value
- the value to set.public void setMaximum(int maximum)
maximum
- the maximum to set.