JList: setDragEnabled(boolean b) : JList « javax.swing « Java by API






JList: setDragEnabled(boolean b)

  

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;

public class DragTest14 extends JFrame {

  JList jl;

  String[] items = { "Java", "C", "C++", "Lisp", "Perl", "Python" };

  public DragTest14() {
    super("Drag Test 1.4");
    setSize(200, 150);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    jl = new JList(items);
    jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jl.setDragEnabled(true);

    getContentPane().add(new JScrollPane(jl), BorderLayout.CENTER);
    setVisible(true);
  }

  public static void main(String args[]) {
    new DragTest14();
  }
}

           
         
    
  








Related examples in the same category

1.JList.VERTICAL_WRAP
2.new JList(Object[] listData)
3.new JList(Vector listData)
4.new JList(ListModel dataModel) (Share model with JComboBox)
5.new JScrollPane(JList list)
6.JList: addListSelectionListener(ListSelectionListener listener)
7.JList: addMouseListener(MouseListener lis)
8.JList: addSelectionInterval(int anchor, int lead)
9.JList: clearSelection()
10.JList: getFirstVisibleIndex()
11.JList: getLastVisibleIndex()
12.JList: getLayoutOrientation()
13.JList: getMaxSelectionIndex()
14.JList: getNextMatch(String prefix, int startIndex, Bias bias)
15.JList: getSelectedIndices()
16.JList: getSelectedValues()
17.JList.getSelectionBackground()
18.JList: getSelectionForeground()
19.JList: getVisibleRowCount()
20.JList: isSelectedIndex(int index)
21.JList: isSelectionEmpty()
22.JList: locationToIndex(Point p)
23.JList: removeSelectionInterval(int index0, int index1)
24.JList: setCellRenderer(ListCellRenderer cellRenderer)
25.JList: setFixedCellHeight(int height)
26.JList: setFixedCellWidth(int width)
27.JList: setLayoutOrientation(int ori)
28.JList: setModel(ListModel model)
29.JList: setPrototypeCellValue(Object prototypeCellValue)
30.JList: setSelectedIndex(int index)
31.JList: setSelectedValue(Object anObject, boolean shouldScroll)
32.JList: setSelectionInterval(int anchor, int lead)
33.JList: setSelectionMode(int selectionMode)
34.JList: setVisibleRowCount(int count)
35.extends JList (custom tooltops)