當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultListSelectionModel類代碼示例

本文整理匯總了Java中javax.swing.DefaultListSelectionModel的典型用法代碼示例。如果您正苦於以下問題:Java DefaultListSelectionModel類的具體用法?Java DefaultListSelectionModel怎麽用?Java DefaultListSelectionModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultListSelectionModel類屬於javax.swing包,在下文中一共展示了DefaultListSelectionModel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setFixedColumnSelection

import javax.swing.DefaultListSelectionModel; //導入依賴的package包/類
public void setFixedColumnSelection(final int column) {
    if (fixedSelectionColumn == column) return;
    
    if (column == -1) {
        getColumnModel().setSelectionModel(new DefaultListSelectionModel());
    } else {
        getColumnModel().setSelectionModel(new DefaultListSelectionModel() {
            public void setSelectionInterval(int index0, int index1) {
                int index = convertColumnIndexToView(column);
                super.setSelectionInterval(index, index);
            }
        });
    }
    
    fixedSelectionColumn = column;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:ProfilerTable.java

示例2: createSyntaxPanel

import javax.swing.DefaultListSelectionModel; //導入依賴的package包/類
private JComponent createSyntaxPanel(Logic logic) {
    final JList<String> list = new JList<>();
    DefaultListModel<String> model = new DefaultListModel<>();
    Map<String,String> docMap = FormulaParser.getDocMap(logic);
    for (Map.Entry<String,String> entry : docMap.entrySet()) {
        model.addElement(entry.getKey());
    }
    list.setModel(model);
    list.setCellRenderer(new MyCellRenderer(docMap));
    list.addMouseListener(new DismissDelayer(list));
    list.setSelectionModel(new DefaultListSelectionModel() {
        @Override
        public void setSelectionInterval(int index0, int index1) {
            super.setSelectionInterval(-1, -1);
        }
    });
    JPanel result = new JPanel(new BorderLayout());
    result.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
    result.add(new JLabel("<html><b>Syntax:"), BorderLayout.NORTH);
    result.add(new JScrollPane(list), BorderLayout.CENTER);
    return result;
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:23,代碼來源:HelpFactory.java

示例3: createSyntaxPanel

import javax.swing.DefaultListSelectionModel; //導入依賴的package包/類
private JComponent createSyntaxPanel() {
    final JList<String> list = new JList<>();
    DefaultListModel<String> model = new DefaultListModel<>();
    for (Map.Entry<String,String> entry : this.docMap.entrySet()) {
        model.addElement(entry.getKey());
    }
    list.setModel(model);
    list.setCellRenderer(new MyCellRenderer(this.docMap));
    list.addMouseListener(new DismissDelayer(list));
    list.setSelectionModel(new DefaultListSelectionModel() {
        @Override
        public void setSelectionInterval(int index0, int index1) {
            super.setSelectionInterval(-1, -1);
        }
    });
    JPanel result = new JPanel(new BorderLayout());
    result.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
    result.add(new JLabel("<html><b>Syntax:"), BorderLayout.NORTH);
    result.add(new JScrollPane(list), BorderLayout.CENTER);
    return result;
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:22,代碼來源:StringDialog.java

示例4: createUI

import javax.swing.DefaultListSelectionModel; //導入依賴的package包/類
private static void createUI(final String lookAndFeelString)
        throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            String[][] data = {{"Foo"}};
            String[] cols = {"One"};
            table = new JTable(data, cols);
            table.setSelectionMode(
                    DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
            frame = new JFrame(lookAndFeelString);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(table);
            frame.pack();
            frame.setSize(500, frame.getSize().height);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
            frame.toFront();
        }
    });
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:SelectEditTableCell.java

示例5: NewMulticastFrame

import javax.swing.DefaultListSelectionModel; //導入依賴的package包/類
/**
 * Creates new form NewMulticast
 */

public NewMulticastFrame() {
    initComponents();
    jList1.setModel(Client.model1);//set the curent active users
    jList1.setFixedCellWidth(80);
    jList1.setSelectionModel(new DefaultListSelectionModel() {//enable multiple selection without holding ctrl key
        @Override
        public void setSelectionInterval(int index0, int index1) {
            if (super.isSelectedIndex(index0)) {
                super.removeSelectionInterval(index0, index1);
            } else {
                super.addSelectionInterval(index0, index1);
            }
        }
    }); 
    this.setDefaultCloseOperation(this.DISPOSE_ON_CLOSE);
    new Heartbeat(Client.nickname,Client.i2p_dest);
}
 
開發者ID:georgemakrakis,項目名稱:TrackMeIfYouCanChat,代碼行數:22,代碼來源:NewMulticastFrame.java

示例6: ObjetiveSelectorPanel

import javax.swing.DefaultListSelectionModel; //導入依賴的package包/類
public ObjetiveSelectorPanel(String[] options, int[] indices) {

		listCurrentObjs = new JList<String>(options);
		listCurrentObjs.setVisibleRowCount(4);
		listCurrentObjs.setSelectionModel(new DefaultListSelectionModel() {
			private static final long serialVersionUID = 1L;

			@Override
		    public void setSelectionInterval(int index0, int index1) {
		        if(super.isSelectedIndex(index0)) {
		            super.removeSelectionInterval(index0, index1);
		        }
		        else {
		            super.addSelectionInterval(index0, index1);
		        }
		    }
		});
		listCurrentObjs.setSelectedIndices(indices);
		
		JScrollPane scrollPane = new JScrollPane(listCurrentObjs);
		add(scrollPane);
	}
 
開發者ID:hecoding,項目名稱:Pac-Man,代碼行數:23,代碼來源:ObjetiveSelectorPanel.java

示例7: OperationPanel

import javax.swing.DefaultListSelectionModel; //導入依賴的package包/類
public OperationPanel(ModelerFile file) {
    this(null, true);

    this.file = file;
    definition = (TDefinitions) file.getDefinitionElement();

    error_ListModel = new ErrorListModel();
    error_List.setModel(error_ListModel);
    error_List.setSelectionModel(new DefaultListSelectionModel() {
        public void setSelectionInterval(int index0, int index1) {
            if (isSelectedIndex(index0)) {
                super.removeSelectionInterval(index0, index1);
            } else {
                super.addSelectionInterval(index0, index1);
            }
        }
    });

}
 
開發者ID:jGauravGupta,項目名稱:jBPMNSuite,代碼行數:20,代碼來源:OperationPanel.java

示例8: actionPerformed

import javax.swing.DefaultListSelectionModel; //導入依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
	int size = listModel.getSize();
	listSelectionModel.setValueIsAdjusting(true);
	ListSelectionModelMemento listSelectionModelMemento = new ListSelectionModelMemento();
	listSelectionModelMemento.save(listSelectionModel);
	DefaultListSelectionModel oldSelection = new DefaultListSelectionModel();
	listSelectionModelMemento.restore(oldSelection);

	listSelectionModel.clearSelection();
	for (int i = 0; i < size; i++) {
		if (!oldSelection.isSelectedIndex(i)) {
			listSelectionModel.addSelectionInterval(i, i);
		}
	}
	listSelectionModel.setValueIsAdjusting(false);
}
 
開發者ID:link-intersystems,項目名稱:GitDirStat,代碼行數:18,代碼來源:InvertSelectionAction.java

示例9: 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);
    }
}
 
開發者ID:jeddict,項目名稱:NBModeler,代碼行數:23,代碼來源:CustomAttributeEditortest.java

示例10: 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);
    }
}
 
開發者ID:jeddict,項目名稱:NBModeler,代碼行數:23,代碼來源:CustomAttributeEditor.java

示例11: isEnabled

import javax.swing.DefaultListSelectionModel; //導入依賴的package包/類
public boolean isEnabled(Object c) {
    Object name = getName();
    if (name == SELECT_PREVIOUS_COLUMN_CHANGE_LEAD ||
            name == SELECT_NEXT_COLUMN_CHANGE_LEAD ||
            name == SELECT_PREVIOUS_ROW_CHANGE_LEAD ||
            name == SELECT_NEXT_ROW_CHANGE_LEAD ||
            name == SELECT_FIRST_ROW_CHANGE_LEAD ||
            name == SELECT_LAST_ROW_CHANGE_LEAD ||
            name == SCROLL_UP_CHANGE_LEAD ||
            name == SCROLL_DOWN_CHANGE_LEAD) {

        // discontinuous selection actions are only enabled for
        // DefaultListSelectionModel
        return c != null && ((JList)c).getSelectionModel()
                                instanceof DefaultListSelectionModel;
    }

    return true;
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:20,代碼來源:BasicXListUI.java

示例12: 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();
    }
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:33,代碼來源:ListSelectionIssues.java

示例13: 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());
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:27,代碼來源:ListSelectionIssues.java

示例14: valueChanged

import javax.swing.DefaultListSelectionModel; //導入依賴的package包/類
@Override
public void valueChanged(ListSelectionEvent e) {
	DefaultListSelectionModel selectionModel = (DefaultListSelectionModel) e.getSource();
	int count = selectionModel.getMaxSelectionIndex() - selectionModel.getMinSelectionIndex() + 1;
	if (count > 1) {
		btEdit.setEnabled(false);
		btCopy.setEnabled(false);
		btDelete.setEnabled(allowMultiDelete);
		if (hasOrder) {
			btOrderUp.setEnabled(false);
			btOrderDown.setEnabled(false);
		}
		return;
	}
	int row = selectionModel.getMinSelectionIndex();
	AbstractEntity entity = getEntityFromRow(row);
	boolean b=true;
	if (entity == null) b=false;
	btEdit.setEnabled(b);
	btCopy.setEnabled(b);
	btDelete.setEnabled(b);
	if (hasOrder) {
		btOrderUp.setEnabled(b);
		btOrderDown.setEnabled(b);
	}
}
 
開發者ID:markkohdev,項目名稱:oStorybook,代碼行數:27,代碼來源:AbstractTable.java

示例15: 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);
    }
}
 
開發者ID:JockiHendry,項目名稱:ireport-fork,代碼行數:25,代碼來源:JRPropertiesMapPropertyCustomEditor.java


注:本文中的javax.swing.DefaultListSelectionModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。