下面列出了javax.swing.ListSelectionModel#setSelectionMode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public ModelMap createModels(final CharacterFacade character)
{
Objects.requireNonNull(character);
ModelMap models = new ModelMap();
ListSelectionModel listModel = new DefaultListSelectionModel();
listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
models.put(ListSelectionModel.class, listModel);
models.put(SkillPointTableModel.class, new SkillPointTableModel(character));
models.put(SkillTreeViewModel.class, new SkillTreeViewModel(character, listModel));
models.put(FilterHandler.class, new FilterHandler(character, listModel));
models.put(InfoHandler.class, new InfoHandler(character));
models.put(LevelSelectionHandler.class, new LevelSelectionHandler(character, listModel));
models.put(SkillRankSpinnerEditor.class, new SkillRankSpinnerEditor(character, listModel));
SkillSheetHandler skillSheetHandler = new SkillSheetHandler(character);
models.put(SkillSheetHandler.class, skillSheetHandler);
models.put(SkillFilterHandler.class, new SkillFilterHandler(character, skillSheetHandler));
return models;
}
public Hashtable<Object, Object> createState(CharacterFacade character,
ListFacade<AbilityCategory> categories, ListFacade<AbilityCategory> fullCategoryList, String title)
{
Hashtable<Object, Object> state = new Hashtable<>();
CategoryTableModel categoryTableModel =
new CategoryTableModel(character, fullCategoryList, categoryBar, categoryTable);
state.put(CategoryTableModel.class, categoryTableModel);
ListSelectionModel listModel = new DefaultListSelectionModel();
listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
state.put(ListSelectionModel.class, listModel);
state.put(AbilityTreeTableModel.class, new AbilityTreeTableModel(character, categories));
state.put(AvailableAbilityTreeViewModel.class, new AvailableAbilityTreeViewModel(character, listModel, title));
state.put(InfoHandler.class, new InfoHandler(character));
state.put(TreeRendererHandler.class, new TreeRendererHandler(character));
state.put(AddAction.class, new AddAction(character));
state.put(RemoveAction.class, new RemoveAction(character));
state.put(AbilityFilterHandler.class, new AbilityFilterHandler(character));
state.put(CategoryFilterHandler.class, new CategoryFilterHandler(categoryTableModel));
return state;
}
@Override
public ModelMap createModels(final CharacterFacade character)
{
Objects.requireNonNull(character);
ModelMap models = new ModelMap();
ListSelectionModel listModel = new DefaultListSelectionModel();
listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
models.put(ListSelectionModel.class, listModel);
models.put(SkillPointTableModel.class, new SkillPointTableModel(character));
models.put(SkillTreeViewModel.class, new SkillTreeViewModel(character, listModel));
models.put(FilterHandler.class, new FilterHandler(character, listModel));
models.put(InfoHandler.class, new InfoHandler(character));
models.put(LevelSelectionHandler.class, new LevelSelectionHandler(character, listModel));
models.put(SkillRankSpinnerEditor.class, new SkillRankSpinnerEditor(character, listModel));
SkillSheetHandler skillSheetHandler = new SkillSheetHandler(character);
models.put(SkillSheetHandler.class, skillSheetHandler);
models.put(SkillFilterHandler.class, new SkillFilterHandler(character, skillSheetHandler));
return models;
}
public Hashtable<Object, Object> createState(CharacterFacade character,
ListFacade<AbilityCategory> categories, ListFacade<AbilityCategory> fullCategoryList, String title)
{
Hashtable<Object, Object> state = new Hashtable<>();
CategoryTableModel categoryTableModel =
new CategoryTableModel(character, fullCategoryList, categoryBar, categoryTable);
state.put(CategoryTableModel.class, categoryTableModel);
ListSelectionModel listModel = new DefaultListSelectionModel();
listModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
state.put(ListSelectionModel.class, listModel);
state.put(AbilityTreeTableModel.class, new AbilityTreeTableModel(character, categories));
state.put(AvailableAbilityTreeViewModel.class, new AvailableAbilityTreeViewModel(character, listModel, title));
state.put(InfoHandler.class, new InfoHandler(character));
state.put(TreeRendererHandler.class, new TreeRendererHandler(character));
state.put(AddAction.class, new AddAction(character));
state.put(RemoveAction.class, new RemoveAction(character));
state.put(AbilityFilterHandler.class, new AbilityFilterHandler(character));
state.put(CategoryFilterHandler.class, new CategoryFilterHandler(categoryTableModel));
return state;
}
public void setTo(ListSelectionModel sm) {
sm.clearSelection();
sm.setSelectionMode(selectionMode);
for (int[] itv : intervals) {
sm.addSelectionInterval(itv[0], itv[1]);
}
sm.setAnchorSelectionIndex(anchor);
sm.setLeadSelectionIndex(lead);
}
public HandlerTable() {
JTableHeader header = getTableHeader();
header.setResizingAllowed(false);
header.setReorderingAllowed(false);
ListSelectionModel model = getSelectionModel();
model.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
model.addListSelectionListener(new HandlerListSelectionListener());
}
public TubeTable(boolean client) {
super();
this.client = client;
JTableHeader header = getTableHeader();
header.setResizingAllowed(false);
header.setReorderingAllowed(false);
ListSelectionModel model = getSelectionModel();
model.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
model.addListSelectionListener(new TubeListSelectionListener(client));
}
public TubeTable() {
JTableHeader header = getTableHeader();
header.setResizingAllowed(false);
header.setReorderingAllowed(false);
ListSelectionModel model = getSelectionModel();
model.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
model.addListSelectionListener(new TubeListSelectionListener());
}
@Override
public ModelMap createModels(CharacterFacade character)
{
ModelMap models = new ModelMap();
DefaultListModel<PageItem> listModel = new DefaultListModel<>();
List<NoteInfoPane> notePaneList = new ArrayList<>();
PageItem firstPage = new PageItem(
character, LanguageBundle.getString("in_descBiography"), bioPane); //$NON-NLS-1$
listModel.addElement(firstPage);
listModel.addElement(new PageItem(
character, LanguageBundle.getString("in_portrait"), portraitPane)); //$NON-NLS-1$
listModel.addElement(new PageItem(
character, LanguageBundle.getString("in_descCampHist"), histPane)); //$NON-NLS-1$
models.put(ListModel.class, listModel);
models.put(List.class, notePaneList);
models.put(NoteListHandler.class, new NoteListHandler(character, listModel, notePaneList));
ListSelectionModel model = new DefaultListSelectionModel();
model.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
model.setSelectionInterval(0, 0);
models.put(ListSelectionModel.class, model);
models.put(PageHandler.class, new PageHandler(model, firstPage));
models.put(AddAction.class, new AddAction(character));
return models;
}
private void initComponents()
{
setTitle(LanguageBundle.getString("in_companionSelectRace")); //$NON-NLS-1$
setLayout(new BorderLayout());
Container container = getContentPane();
{
final ListSelectionModel selectionModel = raceTable.getSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectionModel.addListSelectionListener(e -> {
if (!e.getValueIsAdjusting())
{
selectButton.setEnabled(!selectionModel.isSelectionEmpty());
}
});
}
SearchFilterPanel searchBar = new SearchFilterPanel();
container.add(searchBar, BorderLayout.NORTH);
raceTable.setDisplayableFilter(searchBar);
raceTable.addActionListener(this);
raceTable.setTreeViewModel(this);
container.add(new JScrollPane(raceTable), BorderLayout.CENTER);
JPanel buttonPane = new JPanel(new FlowLayout());
selectButton.addActionListener(this);
selectButton.setEnabled(false);
selectButton.setActionCommand("SELECT");
buttonPane.add(selectButton);
JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel"));
cancelButton.addActionListener(this);
cancelButton.setActionCommand("CANCEL");
buttonPane.add(cancelButton);
container.add(buttonPane, BorderLayout.SOUTH);
Utility.installEscapeCloseOperation(this);
}
@Override
public ModelMap createModels(CharacterFacade character)
{
ModelMap models = new ModelMap();
DefaultListModel<PageItem> listModel = new DefaultListModel<>();
List<NoteInfoPane> notePaneList = new ArrayList<>();
PageItem firstPage = new PageItem(
character, LanguageBundle.getString("in_descBiography"), bioPane); //$NON-NLS-1$
listModel.addElement(firstPage);
listModel.addElement(new PageItem(
character, LanguageBundle.getString("in_portrait"), portraitPane)); //$NON-NLS-1$
listModel.addElement(new PageItem(
character, LanguageBundle.getString("in_descCampHist"), histPane)); //$NON-NLS-1$
models.put(ListModel.class, listModel);
models.put(List.class, notePaneList);
models.put(NoteListHandler.class, new NoteListHandler(character, listModel, notePaneList));
ListSelectionModel model = new DefaultListSelectionModel();
model.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
model.setSelectionInterval(0, 0);
models.put(ListSelectionModel.class, model);
models.put(PageHandler.class, new PageHandler(model, firstPage));
models.put(AddAction.class, new AddAction(character));
return models;
}
private void initComponents()
{
setTitle(LanguageBundle.getString("in_companionSelectRace")); //$NON-NLS-1$
setLayout(new BorderLayout());
Container container = getContentPane();
{
final ListSelectionModel selectionModel = raceTable.getSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectionModel.addListSelectionListener(e -> {
if (!e.getValueIsAdjusting())
{
selectButton.setEnabled(!selectionModel.isSelectionEmpty());
}
});
}
SearchFilterPanel searchBar = new SearchFilterPanel();
container.add(searchBar, BorderLayout.NORTH);
raceTable.setDisplayableFilter(searchBar);
raceTable.addActionListener(this);
raceTable.setTreeViewModel(this);
container.add(new JScrollPane(raceTable), BorderLayout.CENTER);
JPanel buttonPane = new JPanel(new FlowLayout());
selectButton.addActionListener(this);
selectButton.setEnabled(false);
selectButton.setActionCommand("SELECT");
buttonPane.add(selectButton);
JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel"));
cancelButton.addActionListener(this);
cancelButton.setActionCommand("CANCEL");
buttonPane.add(cancelButton);
container.add(buttonPane, BorderLayout.SOUTH);
Utility.installEscapeCloseOperation(this);
}