本文整理匯總了Java中javax.swing.DefaultListSelectionModel.addListSelectionListener方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultListSelectionModel.addListSelectionListener方法的具體用法?Java DefaultListSelectionModel.addListSelectionListener怎麽用?Java DefaultListSelectionModel.addListSelectionListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.DefaultListSelectionModel
的用法示例。
在下文中一共展示了DefaultListSelectionModel.addListSelectionListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: CustomAttributeEditortest
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
public CustomAttributeEditortest(Object value, PropertyEditor editor, PropertyEnv env) {
this.env = env;
this.editor = editor;
this.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
this.env.addPropertyChangeListener(this);
initComponents();
DefaultListSelectionModel dlsm = (DefaultListSelectionModel) this.jTableAttribute.getSelectionModel();
dlsm.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
jTablePropertiesListSelectionValueChanged(e);
}
});
if (value != null && value instanceof Map) {
this.setPropertiesMap((Map) value);
} else if (value != null && value instanceof List) {
this.setPropertiesList((List) value);
}
}
示例2: CustomAttributeEditor
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
public CustomAttributeEditor(Object value, PropertyEditor editor, PropertyEnv env) {
this.env = env;
this.editor = editor;
this.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
this.env.addPropertyChangeListener(this);
initComponents();
DefaultListSelectionModel dlsm = (DefaultListSelectionModel) this.jTableAttribute.getSelectionModel();
dlsm.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
jTablePropertiesListSelectionValueChanged(e);
}
});
if (value != null && value instanceof Map) {
this.setPropertiesMap((Map) value);
} else if (value != null && value instanceof List) {
this.setPropertiesList((List) value);
}
}
示例3: testEventsONLeadAnchorAfterClearSelection
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
* sanity: understand DefaultListSelectionModel behaviour.
*
* Is it allowed that event.getFirstIndex < 0? This happens in
* table.clearLeadAnchor
*
*/
public void testEventsONLeadAnchorAfterClearSelection() {
DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
int selected = 5;
selectionModel.setSelectionInterval(selected, selected);
assertEquals(selected, selectionModel.getAnchorSelectionIndex());
assertEquals(selected, selectionModel.getLeadSelectionIndex());
// selectionModel.setLeadAnchorNotificationEnabled(false);
ListSelectionReport report = new ListSelectionReport();
selectionModel.addListSelectionListener(report);
// following lines are copied from table.clearLeadAnchor()
// selectionModel.setValueIsAdjusting(true);
selectionModel.clearSelection();
assertEquals(1, report.getEventCount());
assertTrue(report.getLastEvent(false).getFirstIndex() >= 0);
report.clear();
selectionModel.setAnchorSelectionIndex(-1);
assertEquals(1, report.getEventCount());
assertTrue(report.getLastEvent(false).getFirstIndex() >= 0);
report.clear();
selectionModel.setLeadSelectionIndex(-1);
assertEquals(1, report.getEventCount());
assertTrue(report.getLastEvent(false).getFirstIndex() >= 0);
report.clear();
}
示例4: testEventONLeadAnchorAfterClearSelection
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
* sanity: understand DefaultListSelectionModel behaviour.
*
* Is it allowed that event.getFirstIndex < 0? This happens in
* table.clearLeadAnchor
*
*/
public void testEventONLeadAnchorAfterClearSelection() {
DefaultListSelectionModel selectionModel = new DefaultListSelectionModel();
int selected = 5;
selectionModel.setSelectionInterval(selected, selected);
assertEquals(selected, selectionModel.getAnchorSelectionIndex());
assertEquals(selected, selectionModel.getLeadSelectionIndex());
selectionModel.setLeadAnchorNotificationEnabled(false);
ListSelectionReport report = new ListSelectionReport();
selectionModel.addListSelectionListener(report);
// following lines are copied from table.clearLeadAnchor()
selectionModel.setValueIsAdjusting(true);
selectionModel.clearSelection();
selectionModel.setAnchorSelectionIndex(-1);
selectionModel.setLeadSelectionIndex(-1);
assertEquals("", 0, report.getEventCount(true));
selectionModel.setValueIsAdjusting(false);
ListSelectionEvent event = report.getLastEvent(true);
assertEquals(5, event.getFirstIndex());
}
示例5: JRPropertiesMapPropertyCustomEditor
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
public JRPropertiesMapPropertyCustomEditor (Object value, PropertyEditor editor, PropertyEnv env) {
this.env = env;
this.editor = editor;
this.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
this.env.addPropertyChangeListener(this);
initComponents();
DefaultListSelectionModel dlsm = (DefaultListSelectionModel)this.jTableProperties.getSelectionModel();
dlsm.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
jTablePropertiesListSelectionValueChanged(e);
}
});
if (value instanceof JRPropertiesMap && value != null)
{
setPropertiesMap((JRPropertiesMap)value);
}
else if (value instanceof List && value != null)
{
setPropertiesList((List)value);
}
}
示例6: JRImportsPropertyCustomEditor
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
public JRImportsPropertyCustomEditor (Object value, PropertyEditor editor, PropertyEnv env) {
this.env = env;
this.editor = editor;
this.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
this.env.addPropertyChangeListener(this);
initComponents();
DefaultListSelectionModel dlsm = (DefaultListSelectionModel)this.jTableProperties.getSelectionModel();
dlsm.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
jTablePropertiesListSelectionValueChanged(e);
}
});
if (value != null && value.getClass().isArray() && value.getClass().getComponentType().equals(String.class))
{
setImports((String[])value);
}
}
示例7: CameraPosDialog
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
* Creates new form CameraPosDialog
*
* @param parent The parent object for this form
* @param modal Indicates whether this is a modal dialog
*/
public CameraPosDialog(AbstractTerrainViewerFrame parent, boolean modal)
{
super(parent, modal);
initComponents();
final DefaultListSelectionModel dlsm =
(DefaultListSelectionModel) cameraTable.getSelectionModel();
dlsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
dlsm.addListSelectionListener(new MySelectionListener());
cameraTable.addMouseListener(new MyMouseListener());
((DefaultCellEditor) cameraTable.getDefaultEditor(String.class)).setClickCountToStart(
1);
}
示例8: TaskModel
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
TaskModel(Executor eventExecutor) {
selectionModel = new DefaultListSelectionModel();
model = new DefaultListModel();
dataListeners = new LinkedHashSet<ListDataListener>();
selectionListeners = new LinkedHashSet<ListSelectionListener>();
TaskListener list = new TaskListener();
model.addListDataListener(list);
selectionModel.addListSelectionListener(list);
this.eventExecutor = eventExecutor;
}
示例9: PhotoList
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
public PhotoList(ZooracleContentPanel zooracleContentPanel)
{
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.zooracleContentPanel = zooracleContentPanel;
// Set the frame characteristics
// setSize(150, 600);
setBackground(Color.gray);
// Create a panel to hold all other components
topPanel = new JPanel();
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
this.add(topPanel);
// Create some data
// String dataValues[][] = { { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279", "9033", "3092" } };
// Create a new table instance
table = new JTable(null, columnNames);
// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// table.setMinimumSize(new Dimension(150, 600));
// table.setPreferredSize(new Dimension(150, 600));
// table.setD
selectionModel = new DefaultListSelectionModel();
model = new DefaultTableModel();
// table.setC
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectionModel.addListSelectionListener(new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent e)
{
int selectionIndex = table.getSelectedRow();
if (lastSelectionIndex != selectionIndex)
{
lastSelectionIndex = selectionIndex;
if (selectionIndex==-1)
return;
System.out.println(table.getValueAt(selectionIndex, 0));
System.out.println("sele:" + selectionIndex);
if (PhotoList.this.zooracleContentPanel instanceof ImportView)
{
((ImportView)(PhotoList.this.zooracleContentPanel)).setCurrentPhoto(selectionIndex);
}
// if (selectionIndex > 2)
// PhotoList.this.maximize(false);
}
}
});
// table.setDefaultRenderer(Object.class, new EditedCellRenderer(this));
table.setSelectionModel(selectionModel);
table.setDefaultRenderer(String.class, new BoardTableCellRenderer());
table.setDefaultRenderer(Object.class, new BoardTableCellRenderer());
table.setModel(model);
// table.setMaximumSize(new Dimension(100, 300));
// Add the table to a scrolling pane
scrollPane = new JScrollPane();
// scrollPane.add(table.getTableHeader());
// scrollPane.add(table);
// topPanel.add(scrollPane);
topPanel.add(table.getTableHeader());
topPanel.add(new JScrollPane(table));
}
示例10: testSelectionEvent
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
@Test
public void testSelectionEvent() {
DefaultListSelectionModel list = new DefaultListSelectionModel();
list.setLeadAnchorNotificationEnabled(false);
list.setSelectionInterval(0, 0);
ListSelectionReport report = new ListSelectionReport();
list.addListSelectionListener(report);
list.addSelectionInterval(1, 1);
assertEquals(1, report.getEventCount(true));
assertEquals(1, report.getLastEvent(true).getLastIndex());
assertEquals(1, report.getLastEvent(true).getFirstIndex());
}
示例11: JRTabStopsPropertyCustomEditor
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
public JRTabStopsPropertyCustomEditor (Object value, PropertyEditor editor, PropertyEnv env) {
this.env = env;
this.editor = editor;
this.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
this.env.addPropertyChangeListener(this);
initComponents();
Tag[] tags = new Tag[] {
new Tag( TabStopAlignEnum.LEFT.getValueByte(), I18n.getString("AbstractStyleNode.Property.Left") ),
new Tag( TabStopAlignEnum.CENTER.getValueByte(), I18n.getString("AbstractStyleNode.Property.Center") ),
new Tag( TabStopAlignEnum.RIGHT.getValueByte(), I18n.getString("AbstractStyleNode.Property.Right") )
};
jTableProperties.getColumnModel().getColumn(1).setCellEditor(new ComboBoxEditor(tags));
jTableProperties.getColumnModel().getColumn(1).setCellRenderer(new ComboBoxRenderer(tags));
DefaultListSelectionModel dlsm = (DefaultListSelectionModel)this.jTableProperties.getSelectionModel();
dlsm.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
jTablePropertiesListSelectionValueChanged(e);
}
});
if (value instanceof List && value != null)
{
setTabStops((List)value);
}
}
示例12: getTable
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
/**
* Needs to be called before displaying the DbfTableModel.
*/
public JTable getTable() {
if (table == null) {
lsm = new DefaultListSelectionModel();
table = new JTable();
table.setModel(getModel());
table.setSelectionModel(lsm);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
lsm.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
// Ignore extra messages.
if (e.getValueIsAdjusting()) {
return;
}
ListSelectionModel lsm2 = (ListSelectionModel) e.getSource();
if (lsm2.isSelectionEmpty()) {
// no rows are selected
} else {
int index = lsm2.getMinSelectionIndex();
selectGraphic(index);
getComponent().repaint();
}
}
});
}
return table;
}
示例13: EndmemberFormModel
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
public EndmemberFormModel(AppContext appContext) {
this.appContext = appContext;
endmemberListModel = new DefaultListModel<>();
endmemberListSelectionModel = new DefaultListSelectionModel();
endmemberListSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
endmemberListModel.addListDataListener(new EndmemberListDataListener());
endmemberListSelectionModel.addListSelectionListener(new EndmemberListSelectionListener());
endmemberDiagram = new Diagram();
endmemberDiagram.setXAxis(new DiagramAxis("Wavelength", ""));
endmemberDiagram.setYAxis(new DiagramAxis("Radiation", ""));
endmemberDiagram.setDrawGrid(false);
propertyChangeSupport = new PropertyChangeSupport(this);
}
示例14: CheckBoxListDecorator
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
public CheckBoxListDecorator(JList<T> list) {
this.list = list;
list.setCellRenderer(new CheckBoxListCellRenderer<T>());
list.addMouseListener(this);
list.addPropertyChangeListener(this);
list.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JComponent.WHEN_FOCUSED);
checkBoxSelectionModel = new DefaultListSelectionModel();
checkBoxSelectionModel.addListSelectionListener(this);
enabled = new HashMap<Integer, Boolean>();
width = new JCheckBox().getPreferredSize().width;
}
示例15: CheckBoxListDecorator
import javax.swing.DefaultListSelectionModel; //導入方法依賴的package包/類
public CheckBoxListDecorator(JList list) {
this.list = list;
list.setCellRenderer(new CheckBoxListCellRenderer());
list.addMouseListener(this);
list.addPropertyChangeListener(this);
list.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JComponent.WHEN_FOCUSED);
checkBoxSelectionModel = new DefaultListSelectionModel();
checkBoxSelectionModel.addListSelectionListener(this);
enabled = new HashMap<Integer, Boolean>();
width = new JCheckBox().getPreferredSize().width;
}