本文整理汇总了Java中javax.swing.DefaultListModel类的典型用法代码示例。如果您正苦于以下问题:Java DefaultListModel类的具体用法?Java DefaultListModel怎么用?Java DefaultListModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultListModel类属于javax.swing包,在下文中一共展示了DefaultListModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setVerticalLineSelected
import javax.swing.DefaultListModel; //导入依赖的package包/类
/**
* Vertical lines selected.
*/
private void setVerticalLineSelected() {
// show horizontal lines
rangeAxisSelectionCombobox.setEnabled(false);
linesList.clearSelection();
// get all horizontal lines and display them
DefaultListModel<AxisParallelLineConfiguration> model = new DefaultListModel<AxisParallelLineConfiguration>();
List<AxisParallelLineConfiguration> domainLines = engine.getPlotInstance().getMasterPlotConfiguration()
.getDomainConfigManager().getCrosshairLines().getLines();
for (int i = 0; i < domainLines.size(); i++) {
AxisParallelLineConfiguration line = domainLines.get(i);
model.addElement(line);
}
linesList.setModel(model);
}
示例2: initializeList
import javax.swing.DefaultListModel; //导入依赖的package包/类
private void initializeList() {
this.listTrechos = new JList<RotaVO>();
this.listTrechos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.listTrechos.setLayoutOrientation(JList.VERTICAL);
this.listTrechos.setModel(new DefaultListModel<RotaVO>());
JScrollPane listScroller = new JScrollPane(this.listTrechos);
GridBagConstraints gbc_list = new GridBagConstraints();
gbc_list.gridheight = 2;
gbc_list.gridwidth = 5;
gbc_list.insets = new Insets(0, 0, 0, 5);
gbc_list.fill = GridBagConstraints.BOTH;
gbc_list.gridx = 1;
gbc_list.gridy = 1;
this.panelSecond.add(listScroller, gbc_list);
}
示例3: StackTraceList
import javax.swing.DefaultListModel; //导入依赖的package包/类
public StackTraceList(Throwable t) {
super(new DefaultListModel());
setFont(getFont().deriveFont(Font.PLAIN));
setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
appendAllStackTraces(t);
addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (getSelectedIndex() >= 0) {
if (!(getSelectedValue() instanceof FormattedStackTraceElement)) {
editButton.setEnabled(false);
} else {
editButton.setEnabled(true);
}
} else {
editButton.setEnabled(true);
}
}
});
}
示例4: getNewComboBoxModelFilter
import javax.swing.DefaultListModel; //导入依赖的package包/类
/**
* Gets the ComboBoxModel filter.
* @return the ComboBoxModel filter
*/
private DefaultComboBoxModel<String> getNewComboBoxModelFilter() {
Vector<String> filterStrings = new Vector<String>();
DefaultListModel<ComponentTypeListElement> typeList = this.getListModelComponentTypes();
for (int i=0; i < typeList.size(); i++) {
ComponentTypeListElement ctle = typeList.getElementAt(i);
if (filterStrings.contains(ctle.getDomain())==false) {
filterStrings.add(ctle.getDomain());
}
}
Collections.sort(filterStrings);
comboBoxModeFilter = new DefaultComboBoxModel<String>();
comboBoxModeFilter.addElement(AddComponentDialog.NoFilterString);
for (String filterString : filterStrings) {
comboBoxModeFilter.addElement(filterString);
}
return comboBoxModeFilter;
}
示例5: createP3
import javax.swing.DefaultListModel; //导入依赖的package包/类
JPanel createP3() {
p3 = new JPanel(new BorderLayout());
model = new DefaultListModel();
list = new JList(model);
list.setCellRenderer(new YTListRenderer());
p3.add(new JScrollPane(list));
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
btnDwnld = new JButton("Download");
btnDwnld.addActionListener(this);
btnCancel = new JButton("Close");
btnCancel.addActionListener(this);
box.add(btnDwnld);
box.add(Box.createHorizontalStrut(10));
box.add(btnCancel);
btnCancel.setPreferredSize(btnDwnld.getPreferredSize());
box.add(Box.createHorizontalStrut(10));
box.add(Box.createRigidArea(new Dimension(0, 40)));
p3.add(box, BorderLayout.SOUTH);
box.setOpaque(true);
box.setBackground(StaticResource.titleColor);
return p3;
}
示例6: updateLocales
import javax.swing.DefaultListModel; //导入依赖的package包/类
private void updateLocales() {
DefaultListModel model = new DefaultListModel();
List<Locale> locales = new ArrayList<Locale>(Arrays.asList(DictionaryProviderImpl.getInstalledDictionariesLocales()));
for (DictionaryDescription desc : addedDictionaries) {
locales.add(desc.getLocale());
}
locales.removeAll(removedDictionaries);
for (Locale l : locales) {
model.addElement(l);
}
installedLocalesList.setModel(model);
}
示例7: createSyntaxPanel
import javax.swing.DefaultListModel; //导入依赖的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;
}
示例8: PluginDialog
import javax.swing.DefaultListModel; //导入依赖的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));
}
示例9: importData
import javax.swing.DefaultListModel; //导入依赖的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;
}
示例10: btnAddActionPerformed
import javax.swing.DefaultListModel; //导入依赖的package包/类
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-HEADEREND:event_btnAddActionPerformed
NotifyDescriptor.InputLine nd = new NonEmptyInputLine(org.openide.util.NbBundle.getMessage(ActionMappings.class, "TIT_Add_action"), org.openide.util.NbBundle.getMessage(ActionMappings.class, "LBL_AddAction"));
Object ret = DialogDisplayer.getDefault().notify(nd);
if (ret == NotifyDescriptor.OK_OPTION) {
NetbeansActionMapping nam = new NetbeansActionMapping();
nam.setDisplayName(nd.getInputText());
nam.setActionName(CUSTOM_ACTION_PREFIX + nd.getInputText());
getActionMappings().addAction(nam);
if (handle != null) {
handle.markAsModified(getActionMappings());
}
MappingWrapper wr = new MappingWrapper(nam);
wr.setUserDefined(true);
((DefaultListModel)lstMappings.getModel()).addElement(wr);
lstMappings.setSelectedIndex(lstMappings.getModel().getSize() - 1);
lstMappings.ensureIndexIsVisible(lstMappings.getModel().getSize() - 1);
}
}
示例11: GlobalOptionsPanel
import javax.swing.DefaultListModel; //导入依赖的package包/类
/** Creates new form GlobalOptionsPanel */
public GlobalOptionsPanel() {
initComponents();
DefaultListModel dlm = new DefaultListModel();
descMap = new HashMap<String, String>();
int i = 0;
String[] desc = SettingsPanel.getAvailableOptionsDescriptions();
for (String s : SettingsPanel.AVAILABLE_OPTIONS) {
dlm.addElement(s);
descMap.put(s, desc[i]);
i = i + 1;
}
jList1.setModel(dlm);
jList1.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
String val = (String) jList1.getSelectedValue();
if (val != null) {
jTextArea1.setText(descMap.get(val));
} else {
jTextArea1.setText("");
}
}
});
}
示例12: javaCompletionExcluderDialogOkButtonActionPerformed
import javax.swing.DefaultListModel; //导入依赖的package包/类
private void javaCompletionExcluderDialogOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderDialogOkButtonActionPerformed
JList list = getSelectedExcluderList();
String text = javaCompletionExcluderDialogTextField.getText();
DefaultListModel model = (DefaultListModel) list.getModel();
int index = model.size();
if (javaExcluderEditing != null){
// if this was an "edit" rather than "add", then remove the old entry first
index = model.indexOf(javaExcluderEditing);
model.remove(index);
javaExcluderEditing = null;
}
String[] entries = text.split(","); // NOI18N
for (String entry : entries) {
// strip zero width spaces
entry = entry.replaceAll("\u200B", ""); // NOI18N
entry = entry.trim();
if (entry.length() != 0 && entry.matches(JAVA_FQN_REGEX)){
model.insertElementAt(entry, index);
index++;
}
}
updateExcluder(list);
javaCompletionExcluderDialog2.setVisible(false);
javaCompletionExcluderDialogTextField.setText(null);
}
示例13: updateGoals
import javax.swing.DefaultListModel; //导入依赖的package包/类
private void updateGoals() {
DefaultListModel m = (DefaultListModel) goalsList.getModel();
m.clear();
if (selVi != null) {
Set<String> goals = null;
try {
goals = PluginIndexManager.getPluginGoals(selVi.getGroupId(),
selVi.getArtifactId(), selVi.getVersion());
} catch (Exception ex) {
// TODO - put err msg in dialog?
Exceptions.printStackTrace(ex);
}
if (goals != null) {
for (String goal : goals) {
m.addElement(new GoalEntry(goal));
}
}
}
}
示例14: perform
import javax.swing.DefaultListModel; //导入依赖的package包/类
@Override
public void perform () {
try {
final DefaultListModel targetsModel = new DefaultListModel();
targetsModel.addElement(INITIAL_MESSAGE);
EventQueue.invokeLater(new Runnable() {
@Override
public void run () {
panel.tagList.setModel(targetsModel);
if (!targetsModel.isEmpty()) {
panel.tagList.setSelectedIndex(0);
}
}
});
refreshRevisions(this);
} finally {
backgroundSupport = null;
}
}
示例15: populateAccessory
import javax.swing.DefaultListModel; //导入依赖的package包/类
/**
* Set up GUI fields according to the requested project.
* @param project a subproject, or null
*/
private void populateAccessory( Project project ) {
DefaultListModel model = (DefaultListModel)jListArtifacts.getModel();
model.clear();
jTextFieldName.setText(project == null ? "" : ProjectUtils.getInformation(project).getDisplayName()); //NOI18N
if ( project != null ) {
List<AntArtifact> artifacts = new ArrayList<AntArtifact>();
for (int i=0; i<artifactTypes.length; i++) {
artifacts.addAll (Arrays.asList(AntArtifactQuery.findArtifactsByType(project, artifactTypes[i])));
}
for(AntArtifact artifact : artifacts) {
URI uris[] = artifact.getArtifactLocations();
for( int y = 0; y < uris.length; y++ ) {
model.addElement( new AntArtifactItem(artifact, uris[y]));
}
}
jListArtifacts.setSelectionInterval(0, model.size());
}
}