类javax.swing.AbstractListModel源码实例Demo

下面列出了怎么用javax.swing.AbstractListModel的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jeveassets   文件: ExportDialog.java
public void setColumns(final List<EnumTableColumn<E>> enumColumns) {
	columns.clear();
	columnIndex.clear();
	columnIndex.addAll(enumColumns);
	for (EnumTableColumn<E> column : enumColumns) {
		columns.put(column.name(), column);
	}
	jColumnSelection.setModel(new AbstractListModel<EnumTableColumn<E>>() {
		@Override
		public int getSize() {
			return columnIndex.size();
		}

		@Override
		public EnumTableColumn<E> getElementAt(int index) {
			return columnIndex.get(index);
		}
	});
}
 
@Override
protected JComponent createColorPicker() {
    List<ColorItem> colors = getColorItems();
    JList<ColorItem> view = new JList<>(new AbstractListModel<ColorItem>() {
        @Override
        public int getSize() {
            return colors.size();
        }

        @Override
        public ColorItem getElementAt(int index) {
            return colors.get(index);
        }
    });
    view.setCellRenderer(new ColorItemListCellRenderer());
    view.addListSelectionListener(e -> {
        setSelectedColor(view.getSelectedValue().color);
    });
    return new JScrollPane(view);
}
 
源代码3 项目: snap-desktop   文件: NamesAssociationDialog.java
private JComponent createCenterList() {
    centerNames = new JList<>(new AbstractListModel<String>() {
        @Override
        public int getSize() {
            return nameProvider.getCenterNames().length;
        }

        @Override
        public String getElementAt(int index) {
            return nameProvider.getCenterNames()[index];
        }
    });
    centerNames.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    centerNames.addListSelectionListener(new CenterListSelectionListener(centerNames));
    centerNames.setEnabled(false);
    final JScrollPane scrollPane = new JScrollPane(centerNames);
    scrollPane.setPreferredSize(new Dimension(160, 200));
    return scrollPane;
}
 
源代码4 项目: snap-desktop   文件: NamesAssociationDialog.java
private JComponent createRightList() {
    rightNames = new JList<>(new AbstractListModel<String>() {

        @Override
        public int getSize() {
            return nameProvider.getRightNames().length;
        }

        @Override
        public String getElementAt(int index) {
            return nameProvider.getRightNames()[index];
        }
    });
    rightNames.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    rightNames.addListSelectionListener(new RightListSelectionListener(rightNames));
    rightNames.setEnabled(false);
    final JScrollPane scrollPane = new JScrollPane(rightNames);
    scrollPane.setPreferredSize(new Dimension(160, 200));
    return scrollPane;
}
 
源代码5 项目: netbeans   文件: IdentifierPickerPanel.java
private void initList() {
    listMime.setModel(new AbstractListModel() {
        @Override
        public int getSize() {
            return availableMimes.size();
        }

        @Override
        public Object getElementAt(int index) {
            return availableMimes.get(index).getDisplayName();
        }
    });
}
 
源代码6 项目: netbeans   文件: SelectionList.java
public void setItems( List<? extends ListItem> items ) {
    final List<? extends ListItem> listItems = Collections.unmodifiableList( items );
    setItems( new AbstractListModel<ListItem>() {

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

        @Override
        public ListItem getElementAt( int index ) {
            return listItems.get( index );
        }
    });
}
 
源代码7 项目: ramus   文件: SelectBaseFunctionDialog.java
public SelectBaseFunctionDialog(GUIFramework framework) {
    super(framework.getMainFrame(), true);
    setTitle(GlobalResourcesManager.getString("SelectModel"));
    result = null;
    final List<Qualifier> base = IDEF0Plugin.getBaseQualifiers(framework
            .getEngine());
    Collections.sort(base, new Comparator<Qualifier>() {

        private Collator collator = Collator.getInstance();

        @Override
        public int compare(Qualifier o1, Qualifier o2) {
            return collator.compare(o1.getName(), o2.getName());
        }
    });
    list.setModel(new AbstractListModel() {

        @Override
        public Object getElementAt(int index) {
            return base.get(index);
        }

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

    });

    JScrollPane pane = new JScrollPane();
    pane.setViewportView(list);
    setMainPane(pane);
    pack();
    setMinimumSize(getSize());
    setLocationRelativeTo(null);
    Options.loadOptions(this);
}
 
源代码8 项目: jeddict   文件: WorkSpaceTrashDialog.java
private AbstractListModel<WorkSpace> getWorkSpaceModel() {
    return new AbstractListModel<WorkSpace>() {
        @Override
        public int getSize() {
            return workSpaces.size();
        }

        @Override
        public WorkSpace getElementAt(int i) {
            return workSpaces.get(i);
        }
    };
}
 
源代码9 项目: nb-ci-plugin   文件: CIOptionsPanel.java
CIOptionsPanel(CIOptionsPanelController controller) {
    this.controller = controller;
    initComponents();

    categoryPanels = new StorablePanel[]{
        new CategoryPanelGeneral(),
        new CategoryArchiveFiles(CIEntry.Type.BASE),
        new CategoryArchiveFiles(CIEntry.Type.LANGUAGE_PACK),};

    categoriesList.setModel(new AbstractListModel() {

        private static final long serialVersionUID = 1L;
        String[] categories = {
            getMessage("LBL_CATEGORY_GENERAL"),
            getMessage("LBL_CATEGORY_BASE_FILES"),
            // NbBundle.getMessage(CIOptionsPanel.class, "LBL_CATEGORY_LANGUAGE_PACKS")
        };

        @Override
        public int getSize() {
            return categories.length;
        }

        @Override
        public Object getElementAt(int index) {
            return categories[index];
        }
    });

    categoriesList.setSelectedIndex(0);
}
 
源代码10 项目: netbeans   文件: AddTableDlg.java
/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
private void initComponents() {//GEN-BEGIN:initComponents

    java.awt.GridBagConstraints gridBagConstraints;

    _mainPanel = new JPanel();
    _tableScrollPane = new JScrollPane();
    _tableJList = new JList();

    setLayout(new java.awt.GridBagLayout());

    _mainPanel.setLayout(new java.awt.GridBagLayout());

    // Set the model to be the array that was passed to it
    _tableJList.setModel(new AbstractListModel() {
        public int getSize() { return _tableList.length; }
        public Object getElementAt(int i) { return _tableList[i]; }
    });
    _tableJList.getAccessibleContext().
        setAccessibleName(NbBundle.getMessage(AddTableDlg.class, "TABLE_LIST_a11yName"));
    _tableJList.getAccessibleContext().
        setAccessibleDescription(NbBundle.getMessage(AddTableDlg.class, "TABLE_LIST_a11yDescription"));
    tableListLabel = new JLabel();
    tableListLabel.setText(NbBundle.getMessage(AddTableDlg.class, "TABLE_LIST_label"));
    tableListLabel.setLabelFor(_tableJList);
    _tableScrollPane.setViewportView(_tableJList);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    _mainPanel.add(_tableScrollPane, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 10);
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;

    add(_mainPanel, gridBagConstraints);


}
 
源代码11 项目: clearvolume   文件: ChannelFilterSinkJPanel.java
/**
 * Create the panel.
 * 
 * @param pChannelFilterSink
 *            channel filter sink
 */
public ChannelFilterSinkJPanel(final ChannelFilterSink pChannelFilterSink)
{
	mChannelFilterSink = pChannelFilterSink;
	setBackground(Color.WHITE);
	setLayout(new MigLayout("",
							"[grow,fill]",
							"[26px:26px,grow,fill]"));

	mActiveChannelJList = new JList<String>();
	mActiveChannelJList.setVisibleRowCount(16);
	mActiveChannelJList.setSelectionBackground(new Color(	102,
															102,
															255));
	mActiveChannelJList.setModel(new AbstractListModel()
	{
		String[] values = new String[]
		{	"1",
			"2",
			"3",
			"4",
			"5",
			"6",
			"7",
			"8",
			"9",
			"10",
			"11",
			"12",
			"13",
			"14",
			"15",
			"16" };

		@Override
		public int getSize()
		{
			return values.length;
		}

		@Override
		public Object getElementAt(int index)
		{
			return values[index];
		}
	});
	mActiveChannelJList.addListSelectionListener(this);
	add(mActiveChannelJList, "cell 0 0,grow");
	// mActiveChannelJList.setModel(null);

	if (pChannelFilterSink != null)
	{
		final ListModel<String> lChannelListModel = pChannelFilterSink.getChannelListModel();
		mActiveChannelJList.setModel(lChannelListModel);

		lChannelListModel.addListDataListener(this);
	}
	else
	{
	}

}
 
源代码12 项目: ET_Redux   文件: IsochronsSelectorDialog.java
private void updateList(JList<IsochronModel> jlist, AbstractListModel<IsochronModel> listModel) {
    jlist.setModel(new IsochronModelList());
    jlist.setModel(listModel);
    jlist.validate();
}
 
源代码13 项目: nb-ci-plugin   文件: CIOptionsPanel.java
/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    categoriesPanel = new javax.swing.JPanel();
    categoriesList = new javax.swing.JList();
    categoryPanel = new javax.swing.JPanel();

    categoriesPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    categoriesPanel.setPreferredSize(new java.awt.Dimension(150, 285));

    categoriesList.setModel(new javax.swing.AbstractListModel() {
        String[] strings = { "General", "CodeIgniter Files", "Language Packs" };
        public int getSize() { return strings.length; }
        public Object getElementAt(int i) { return strings[i]; }
    });
    categoriesList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            categoriesListValueChanged(evt);
        }
    });

    javax.swing.GroupLayout categoriesPanelLayout = new javax.swing.GroupLayout(categoriesPanel);
    categoriesPanel.setLayout(categoriesPanelLayout);
    categoriesPanelLayout.setHorizontalGroup(
        categoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(categoriesList, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
    );
    categoriesPanelLayout.setVerticalGroup(
        categoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(categoriesList, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
    );

    categoryPanel.setLayout(new javax.swing.BoxLayout(categoryPanel, javax.swing.BoxLayout.LINE_AXIS));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(categoriesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(categoryPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(categoriesPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
        .addComponent(categoryPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
    );
}
 
源代码14 项目: jclic   文件: Editor.java
public AbstractListModel<Object> getListModel() {
  if (listModel == null) {
    listModel = new LModel();
  }
  return listModel;
}
 
 类所在包
 同包方法