Example usage for javax.swing ListSelectionModel SINGLE_SELECTION

List of usage examples for javax.swing ListSelectionModel SINGLE_SELECTION

Introduction

In this page you can find the example usage for javax.swing ListSelectionModel SINGLE_SELECTION.

Prototype

int SINGLE_SELECTION

To view the source code for javax.swing ListSelectionModel SINGLE_SELECTION.

Click Source Link

Document

A value for the selectionMode property: select one list index at a time.

Usage

From source file:Main.java

public Main() {
    setSize(200, 150);//from w  w w  . j a va2s. c  o  m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);

    DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());

    list = new JList(label);
    JScrollPane pane = new JScrollPane(list);

    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m.setLeadAnchorNotificationEnabled(false);
    list.setSelectionModel(m);//  www  .  ja  v a 2s.co m

    ListSelectionListener lis = new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            System.out.println(e.toString());
        }
    };

    m.addListSelectionListener(lis);
    m.removeListSelectionListener(lis);

    add(pane, BorderLayout.NORTH);
}

From source file:Main.java

public Main() {
    super("Gesture Test");
    setSize(200, 150);//from w w  w. j av  a 2s  . co  m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);
    DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());

    list = new JList(label);
    JScrollPane pane = new JScrollPane(list);

    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m.setLeadAnchorNotificationEnabled(false);
    list.setSelectionModel(m);/*  w w w  .j a  v a  2s.  c  o  m*/

    list.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            System.out.println(e.toString());
        }
    });

    add(pane, BorderLayout.NORTH);
}

From source file:Main.java

public Main() {
    super("Gesture Test");
    setSize(200, 150);//  w  w  w . ja v a2  s .co m
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);

    DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());

    list = new JList(label);
    JScrollPane pane = new JScrollPane(list);

    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m.setLeadAnchorNotificationEnabled(false);
    list.setSelectionModel(m);/* w  ww .  j a  v a2 s  .com*/

    m.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            System.out.println(e.toString());
        }
    });

    add(pane, BorderLayout.NORTH);
}

From source file:MainClass.java

public MainClass() {
    setLayout(new BorderLayout());

    list = new JList(label);
    JScrollPane pane = new JScrollPane(list);

    DefaultListSelectionModel m = new DefaultListSelectionModel();
    m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m.setLeadAnchorNotificationEnabled(false);
    list.setSelectionModel(m);/*from w  w w. j a  v a2  s.  co m*/

    list.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            System.out.println(e.toString());
        }
    });

    add(pane, BorderLayout.NORTH);
}

From source file:GestureTest.java

public GestureTest() {
    super("Gesture Test");
    setSize(200, 150);//from www  .  ja v a 2s.  co  m
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);

    DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(jl, DnDConstants.ACTION_COPY, this);
    setVisible(true);
}

From source file:LongListTest.java

public LongListTest() {
    setTitle("LongListTest");
    setSize(400, 300);//ww  w .j a  va  2  s .  c  o  m
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    JList wordList = new JList(new WordListModel(300000));
    wordList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    wordList.setFixedCellWidth(50);
    wordList.setFixedCellHeight(15);

    JScrollPane scrollPane = new JScrollPane(wordList);

    JPanel p = new JPanel();
    p.add(scrollPane);
    wordList.addListSelectionListener(this);

    getContentPane().add(p, "Center");

    getContentPane().add(label, "North");
}

From source file:Main.java

Main() {
    JFrame jfrm = new JFrame("JTable Demo");
    jfrm.setLayout(new FlowLayout());
    jfrm.setSize(460, 180);/*from   w w w  .  j  av  a 2s .com*/
    jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JScrollPane jscrlp = new JScrollPane(jtabOrders);
    jtabOrders.setPreferredScrollableViewportSize(new Dimension(420, 60));

    jtabOrders.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jfrm.setVisible(true);

    jtabOrders.setColumnSelectionAllowed(false);
    jtabOrders.setRowSelectionAllowed(true);
}