Example usage for javax.swing JList setSelectionForeground

List of usage examples for javax.swing JList setSelectionForeground

Introduction

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

Prototype

@BeanProperty(visualUpdate = true, description = "The foreground color of selected cells.")
public void setSelectionForeground(Color selectionForeground) 

Source Link

Document

Sets the color used to draw the foreground of selected items, which cell renderers can use to render text and graphics.

Usage

From source file:Main.java

public static void main(final String args[]) {
    String labels[] = { "A", "B", "C", "D", "E" };
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JList jlist1 = new JList(labels);
    jlist1.setVisibleRowCount(4);/* w  w  w.  j  av  a  2  s.c o m*/
    JScrollPane scrollPane1 = new JScrollPane(jlist1);
    frame.add(scrollPane1, BorderLayout.NORTH);

    jlist1.setSelectionForeground(Color.RED);

    frame.setSize(300, 350);
    frame.setVisible(true);
}