javax.swing.AbstractListModel Java Examples

The following examples show how to use javax.swing.AbstractListModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExportDialog.java    From jeveassets with GNU General Public License v2.0 6 votes vote down vote up
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);
		}
	});
}
 
Example #2
Source File: ColorSelectionComponentRunner.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: NamesAssociationDialog.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: NamesAssociationDialog.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: IdentifierPickerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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();
        }
    });
}
 
Example #6
Source File: SelectionList.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 );
        }
    });
}
 
Example #7
Source File: SelectBaseFunctionDialog.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #8
Source File: WorkSpaceTrashDialog.java    From jeddict with Apache License 2.0 5 votes vote down vote up
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);
        }
    };
}
 
Example #9
Source File: CIOptionsPanel.java    From nb-ci-plugin with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #10
Source File: AddTableDlg.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** 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);


}
 
Example #11
Source File: ChannelFilterSinkJPanel.java    From clearvolume with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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
	{
	}

}
 
Example #12
Source File: IsochronsSelectorDialog.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
private void updateList(JList<IsochronModel> jlist, AbstractListModel<IsochronModel> listModel) {
    jlist.setModel(new IsochronModelList());
    jlist.setModel(listModel);
    jlist.validate();
}
 
Example #13
Source File: CIOptionsPanel.java    From nb-ci-plugin with GNU General Public License v2.0 4 votes vote down vote up
/** 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)
    );
}
 
Example #14
Source File: Editor.java    From jclic with GNU General Public License v2.0 4 votes vote down vote up
public AbstractListModel<Object> getListModel() {
  if (listModel == null) {
    listModel = new LModel();
  }
  return listModel;
}