本文整理匯總了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);
}
});
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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));
}
示例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);
}
}
示例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);
}
示例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));
}
}
示例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());
}
}
示例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;
}
示例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());
}
示例13: connectGroupsList
import javax.swing.JList; //導入方法依賴的package包/類
public static void connectGroupsList(List<ConfigFileGroup> groups, JList list) {
list.setModel(new ConfigFileGroupListModel(groups));
}
示例14: connectFilesList
import javax.swing.JList; //導入方法依賴的package包/類
public static void connectFilesList(List<File> files, JList list) {
list.setModel(new ConfigFileListModel(files));
}
示例15: disconnect
import javax.swing.JList; //導入方法依賴的package包/類
public static void disconnect(JList list) {
list.setModel(new DefaultListModel());
}