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


Java JList.setModel方法代碼示例

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


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

示例1: ListPanel

import javax.swing.JList; //導入方法依賴的package包/類
public ListPanel(FilterModel fltrmodel, Function<T, String> mapper) {
    setLayout(new java.awt.BorderLayout());
    JScrollPane sp = new javax.swing.JScrollPane();
    list = new JList();
    list.setModel(fltrmodel);
    list.setCellRenderer(new CheckBoxListRenderer(mapper));
    sp.setViewportView(list);
    add(sp, BorderLayout.CENTER);
    list.setSelectionModel(new MultiSelectionModel(this::onSelect));
    list.addKeyListener(onDelete());
    list.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ctrl A"), "SelectAll");
    list.getActionMap().put("SelectAll", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            list.setSelectionInterval(0, list.getModel().getSize() - 1);
        }
    });
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:19,代碼來源:JSList.java

示例2: importData

import javax.swing.JList; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public boolean importData(JComponent target, Transferable data) {
    JList<TradeRouteStop> stl = TradeRouteInputPanel.this.stopList;
    if (canImport(target, data.getTransferDataFlavors())
        && target == stl
        && data instanceof StopListTransferable) {
        List<TradeRouteStop> stops
            = ((StopListTransferable)data).getStops();
        DefaultListModel<TradeRouteStop> model
            = new DefaultListModel<>();
        int index = stl.getMaxSelectionIndex();
        for (TradeRouteStop stop : stops) {
            if (index < 0) {
                model.addElement(stop);
            } else {
                index++;
                model.add(index, stop);
            }
        }
        stl.setModel(model);
        return true;
    }
    return false;
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:28,代碼來源:TradeRouteInputPanel.java

示例3: ListParameter

import javax.swing.JList; //導入方法依賴的package包/類
public ListParameter(JList list, String parameter, String encoding) {
    super(parameter, encoding);
    this.list = list;
    list.setModel(new DefaultListModel());
    list.addListSelectionListener(new ListSelectionListener(){
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int[] s = ListParameter.this.list.getSelectedIndices();
            if(e.getValueIsAdjusting()) {
                return;
            }
            fireStateChanged();
        };
    });
    original = list.getSelectedIndices();
    fireStateChanged();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:QueryParameter.java

示例4: createSyntaxPanel

import javax.swing.JList; //導入方法依賴的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

示例5: createSyntaxPanel

import javax.swing.JList; //導入方法依賴的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

示例6: PluginDialog

import javax.swing.JList; //導入方法依賴的package包/類
public PluginDialog()
{
	listModel = new DefaultListModel();

	list = new JList();
	list.setModel(listModel);
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	for( String name : plugins.keySet() )
	{
		listModel.addElement(name);
	}

	setLayout(new BorderLayout());
	add(new JScrollPane(list));
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:17,代碼來源:SearchTool.java

示例7: connectAvailable

import javax.swing.JList; //導入方法依賴的package包/類
public static void connectAvailable(JList availableTablesList, TableClosure tableClosure, FilterAvailable filter) {
    availableTablesList.setModel(new AvailableTablesModel(tableClosure));

    if (!(availableTablesList.getCellRenderer() instanceof AvailableTableRenderer)) {
        availableTablesList.setCellRenderer(new AvailableTableRenderer(filter));
    } else {
        AvailableTableRenderer renderer = (AvailableTableRenderer) availableTablesList.getCellRenderer();
        renderer.updateFilter(filter);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:TableUISupport.java

示例8: initExcluderList

import javax.swing.JList; //導入方法依賴的package包/類
private void initExcluderList(JList jList, String list) {
    DefaultListModel model = new DefaultListModel();
    String [] entries = list.split(","); //NOI18N
    for (String entry : entries){
        if (entry.length() != 0)
            model.addElement(entry);
    }
    jList.setModel(model);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:CodeCompletionPanel.java

示例9: buildChooser

import javax.swing.JList; //導入方法依賴的package包/類
@Override
public void buildChooser() {
    setLayout(new BorderLayout());// GridLayout(0, 1));

    if (!itens.isEmpty()) {
        JScrollPane jsp = new javax.swing.JScrollPane();
        lst = new JList(itens.toArray(new Legenda.ItemDeLegenda[]{}));
        add(jsp, BorderLayout.EAST);
        jsp.add(lst);
        jsp.setViewportView(lst);
        lst.setModel(new javax.swing.AbstractListModel() {

            @Override
            public int getSize() {
                return itens.size();
            }

            @Override
            public Object getElementAt(int i) {
                return itens.get(i);
            }
        });
        lst.addListSelectionListener( e -> {
            if (e == null || lst.getSelectedIndex() < 0) {
                return;
            }
            
            Legenda.ItemDeLegenda r = itens.get(lst.getSelectedIndex());
            
            getColorSelectionModel().setSelectedColor(r.getCor());
        });
        lst.setCellRenderer(new JListItemParaItemLegenda(false));
    }
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:35,代碼來源:PainelSelecaoCor.java

示例10: connectSelected

import javax.swing.JList; //導入方法依賴的package包/類
public static void connectSelected(JList selectedTablesList, TableClosure tableClosure) {
    selectedTablesList.setModel(new SelectedTablesModel(tableClosure));

    if (!(selectedTablesList.getCellRenderer() instanceof SelectedTableRenderer)) {
        selectedTablesList.setCellRenderer(new SelectedTableRenderer());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:TableUISupport.java

示例11: createNewInfoLabelJList

import javax.swing.JList; //導入方法依賴的package包/類
/**
 * Creates a new JList for info labels of a source
 *
 * @param source
 *            can be null for local source, otherwise name of the source
 * @return the created JList
 */
private JList<String> createNewInfoLabelJList(String source) {
	final JList<String> createdInfoLabelList = new JList<>();
	createdInfoLabelList.setModel(source == null ? localInfoLabelListModel : remoteInfoLabelListModels.get(source));
	createdInfoLabelList.setCellRenderer(new ConfigurableInfoLabelRenderer());
	createdInfoLabelList.setFixedCellHeight(20);
	createdInfoLabelList.setBackground(LIGHTER_GRAY);
	return createdInfoLabelList;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:16,代碼來源:ConfigurableDialog.java

示例12: initListModel

import javax.swing.JList; //導入方法依賴的package包/類
/**
 * 初始化數據庫表列表的數據模型
 */
@SuppressWarnings("unchecked")
public void initListModel()
{
    JList<String> v_Tables = (JList<String>)XJava.getObject("xlTables");
    
    this.listModel = new DefaultListModel<String>();
    
    v_Tables.setModel(this.listModel);
    v_Tables.setBackground(this.getBackground());
}
 
開發者ID:HY-ZhengWei,項目名稱:HBaseClient,代碼行數:14,代碼來源:AppFrame.java

示例13: connectGroupsList

import javax.swing.JList; //導入方法依賴的package包/類
public static void connectGroupsList(List<ConfigFileGroup> groups, JList list) {
    list.setModel(new ConfigFileGroupListModel(groups));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:ConfigFilesUIs.java

示例14: connectFilesList

import javax.swing.JList; //導入方法依賴的package包/類
public static void connectFilesList(List<File> files, JList list) {
    list.setModel(new ConfigFileListModel(files));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:ConfigFilesUIs.java

示例15: disconnect

import javax.swing.JList; //導入方法依賴的package包/類
public static void disconnect(JList list) {
    list.setModel(new DefaultListModel());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:ConfigFilesUIs.java


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