Java JList Select fireSelectRow(final JList list, final Object value)

Here you can find the source of fireSelectRow(final JList list, final Object value)

Description

fire Select Row

License

Open Source License

Declaration

public static void fireSelectRow(final JList list, final Object value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.*;

import javax.swing.*;

public class Main {
    public static void fireSelectRow(final JList list, final Object value) {
        if (value != null) {
            EventQueue.invokeLater(new Runnable() {
                @Override/*  w  w w .  j  a v  a 2  s  . co  m*/
                public void run() {
                    list.setSelectedValue(value, true);
                }
            });
        }
    }

    public static void fireSelectRow(final JList list, final int row) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                list.setSelectedIndex(row);
            }
        });
    }

    public static void fireSelectRow(final JTable table, final int row) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                if ((row >= 0) && (row < table.getRowCount())) {
                    table.clearSelection();
                    table.setRowSelectionInterval(row, row);
                }
            }
        });
    }
}

Related

  1. canMoveSelectedItemsUp(JList list)
  2. createStringFromSelectionList( JList aListComponent, boolean createQuotes)
  3. downListSelectedIndex(JList sourceList)
  4. ensureSelectionIsVisible(final JList list)
  5. fillSelectionListFromString(JList aListComponent, String theList, boolean removeQuotes)
  6. fireSelectRows(final JList list, final int[] rows)
  7. getSelectedIndecies(final ListSelectionModel lsm)
  8. getSelectedItems(DefaultListModel listModel, ListSelectionModel selectionModel)
  9. getSelectedMultipleList(JList anJList)