Example usage for javax.swing JList getDropLocation

List of usage examples for javax.swing JList getDropLocation

Introduction

In this page you can find the example usage for javax.swing JList getDropLocation.

Prototype

@BeanProperty(bound = false)
public final DropLocation getDropLocation() 

Source Link

Document

Returns the location that this component should visually indicate as the drop location during a DnD operation over the component, or null if no location is to currently be shown.

Usage

From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java

Color getForegroundColor(final JList list, final int index, final boolean isSelected) {
    Color foreground;/* w  w w. j  av  a2  s  .com*/

    // check if this cell represents the current DnD drop location
    final JList.DropLocation dropLocation = list.getDropLocation();
    if (dropLocation != null && !dropLocation.isInsert() && dropLocation.getIndex() == index) {
        foreground = Color.WHITE;
    } else if (isSelected) {
        foreground = UIManager.getColor("Tree.selectionForeground");
    } else {
        foreground = Color.BLACK;
    }
    return foreground;
}

From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java

Color getBackgroundColor(final JList list, final int index, final boolean isSelected) {
    Color background;/*from  w w  w.j a v a 2s . c  o m*/

    // check if this cell represents the current DnD drop location
    final JList.DropLocation dropLocation = list.getDropLocation();
    if (dropLocation != null && !dropLocation.isInsert() && dropLocation.getIndex() == index) {
        background = Color.RED;
    } else if (isSelected) {
        background = UIManager.getColor("Tree.selectionBackground");
    } else {
        background = Color.WHITE;
    }

    return background;
}