org.grinvin.gui

Class DropList


public class DropList
extends JList

Extension to JList which enables dropping at positions between list elements and indicates the drop position by means of a horizontal cursor.

Field Summary

protected int
cursorMargin
Extra vertical space to be left on top of the list and at the bottom to make sure the cursor is fully visible when drawn at both extremes of the list.

Constructor Summary

DropList(ListModel dataModel)
Construct a list of this type for a given data model.

Method Summary

int
getCursorIndex()
Return the position at which the cursor is drawn.
protected void
paintCursor(Graphics g, int index)
Paint the cursor at the given position.
protected void
paintCursor(Graphics g, int x, int y, int width)
Draw a cursor at the given position.
void
setCursorIndex(Point location)
Set the cursor index according to the given location.
void
setCursorIndex(int index)
Set the position at which the cursor should be drawn.
protected @Override
void paintComponent(Graphics g)

Field Details

cursorMargin

protected int cursorMargin
Extra vertical space to be left on top of the list and at the bottom to make sure the cursor is fully visible when drawn at both extremes of the list.

Constructor Details

DropList

public DropList(ListModel dataModel)
Construct a list of this type for a given data model.

Method Details

getCursorIndex

public int getCursorIndex()
Return the position at which the cursor is drawn.

paintCursor

protected void paintCursor(Graphics g,
                           int index)
Paint the cursor at the given position.

paintCursor

protected void paintCursor(Graphics g,
                           int x,
                           int y,
                           int width)
Draw a cursor at the given position.
Parameters:
g - graphics context
x - X-position of the cursor
y - Y-position of the left side of the cursor
width - Width of the cursor

setCursorIndex

public void setCursorIndex(Point location)
Set the cursor index according to the given location.

setCursorIndex

public void setCursorIndex(int index)
Set the position at which the cursor should be drawn.
Parameters:
index - Index of the list element in front of which the cursor should be drawn. If out of range, the cursor will not be drawn.

void paintComponent

protected @Override void paintComponent(Graphics g)