Example usage for javax.swing.plaf.basic BasicListUI BasicListUI

List of usage examples for javax.swing.plaf.basic BasicListUI BasicListUI

Introduction

In this page you can find the example usage for javax.swing.plaf.basic BasicListUI BasicListUI.

Prototype

BasicListUI

Source Link

Usage

From source file:com.projity.pm.graphic.chart.ChartLegend.java

JList getListInstance(boolean cost) {
    final JList list = new JList() { // do not want to update the UI. see below also
        private static final long serialVersionUID = 1L;

        public void updateUI() {
            if (!Environment.isNewLook())
                super.updateUI();
        }/*ww  w .  j a va 2  s. c om*/
    };
    if (Environment.isNewLook()) // The PLAF can override the custom renderer. This avoids that
        list.setUI(new BasicListUI());
    list.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    list.setCellRenderer(new ListRenderer());
    setListFields(list, cost);
    if (!simple) {
        list.setSelectedIndex(0); // start off with first choice selected         
        list.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (chartInfo.isRestoring()) // don't want to listen if updating from workspace
                    return;
                if (e.getValueIsAdjusting() == false) {
                    chartInfo.setTraces(list.getSelectedValues());
                }
            }
        });
    }

    return list;
}