当前位置: 首页>>代码示例>>Java>>正文


Java JList.addListSelectionListener方法代码示例

本文整理汇总了Java中javax.swing.JList.addListSelectionListener方法的典型用法代码示例。如果您正苦于以下问题:Java JList.addListSelectionListener方法的具体用法?Java JList.addListSelectionListener怎么用?Java JList.addListSelectionListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JList的用法示例。


在下文中一共展示了JList.addListSelectionListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import javax.swing.JList; //导入方法依赖的package包/类
/** Constructs rest of dialog.
*/
private void draw () {
    list = new JList(listModel);
    list.addListSelectionListener (new javax.swing.event.ListSelectionListener () {
                                       public void valueChanged (javax.swing.event.ListSelectionEvent evt) {
                                           updateSaveButton ();
                                       }
                                   }
                                  );
    // bugfix 37941, select first item in list
    if (!listModel.isEmpty ()) {
        list.setSelectedIndex (0);
    } else {                              
        updateSaveButton ();
    }
    JScrollPane scroll = new JScrollPane (list);
 setBorder(BorderFactory.createEmptyBorder( 12, 12, 11, 12));
    add(scroll, java.awt.BorderLayout.CENTER);
    list.setCellRenderer(new ExitDlgListCellRenderer());
    list.getAccessibleContext().setAccessibleName((NbBundle.getBundle(ExitDialog.class)).getString("ACSN_ListOfChangedFiles"));
    list.getAccessibleContext().setAccessibleDescription((NbBundle.getBundle(ExitDialog.class)).getString("ACSD_ListOfChangedFiles"));
    this.getAccessibleContext().setAccessibleDescription((NbBundle.getBundle(ExitDialog.class)).getString("ACSD_ExitDialog"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ExitDialog.java

示例2: 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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:QueryParameter.java

示例3: Digitizer

import javax.swing.JList; //导入方法依赖的package包/类
public Digitizer( XMap map ) {
	this.map = map;
	objects = new Vector<Object>();
	currentObject = null;
	model = new DigListModel( this );
	list = new JList(model);
	list.setCellRenderer( new DigCellRenderer() );
	list.addListSelectionListener( this);
	list.addMouseListener( this);
	initTools();
	enabled = false;
	listening = false;
	lastSelectedIndex = -1;
	options = new DigitizerOptionsDialog( map );
	initDialog();
	profile = new DigProfile( map );
	graph = new XYGraph( profile, 0);
	graph.setScrollableTracksViewportHeight( true );
	graph.setScrollableTracksViewportWidth( false );
	graph.setAxesSides( Axes.LEFT | Axes.BOTTOM );
	Zoomer zoomer = new Zoomer( graph );
	graph.addMouseListener( zoomer );
	graph.addMouseMotionListener( zoomer );
	graph.addKeyListener( zoomer );
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:26,代码来源:Digitizer.java

示例4: UserPanel

import javax.swing.JList; //导入方法依赖的package包/类
public UserPanel()
{
	resultsModel = new GenericListModel<Object>();
	results = new JList(resultsModel);
	results.addListSelectionListener(this);

	query = new JTextField();
	query.addActionListener(this);
	search = new JButton(CurrentLocale.get("searching.userGroupRole.executeQuery"));
	search.addActionListener(this);
	JPanel panel = new JPanel();
	panel.setLayout(new BorderLayout(5, 5));
	panel.add(new JLabel(CurrentLocale.get("com.tle.admin.recipients.browserfinder.users")), BorderLayout.WEST);
	panel.add(query, BorderLayout.CENTER);
	panel.add(search, BorderLayout.EAST);

	query.addMouseListener(mouse);
	search.addMouseListener(mouse);
	results.addMouseListener(mouse);

	setLayout(new BorderLayout(5, 5));

	add(panel, BorderLayout.NORTH);
	add(new JScrollPane(results), BorderLayout.CENTER);
	setBorder(new EmptyBorder(5, 5, 5, 5));
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:BrowseFinder.java

示例5: setupGUI

import javax.swing.JList; //导入方法依赖的package包/类
protected void setupGUI()
{
	listeners = new EventListenerList();

	model = new GenericListModel<T>();
	list = new JList(model);
	list.addListSelectionListener(this);

	JScrollPane scroll = new JScrollPane(list);

	setLayout(new BorderLayout(5, 5));
	add(createTop(), BorderLayout.NORTH);
	add(scroll, BorderLayout.CENTER);
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:FilterList.java

示例6: createFilesList

import javax.swing.JList; //导入方法依赖的package包/类
private JList createFilesList(SaveCookie[] saveCookies) {
    JList filesList = new JList(
                listModel = new ArrayListModel<SaveCookie>(saveCookies));
    filesList.setVisibleRowCount(8);
    filesList.setPrototypeCellValue(PROTOTYPE_LIST_CELL_VALUE);
    filesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    filesList.addListSelectionListener(listener);
    filesList.setCellRenderer(new ListCellRenderer());

    return filesList;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:FilesModifiedConfirmation.java

示例7: createLeft

import javax.swing.JList; //导入方法依赖的package包/类
private Component createLeft() {
	usedUnits = new JList(usedUnitsModel);
	usedUnits.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	usedUnits.setVisibleRowCount(rowCount);
	usedUnits.addListSelectionListener(new UsedSelector());
	leftListPane = new JScrollPane(usedUnits);
	return leftListPane;
}
 
开发者ID:etomica,项目名称:etomica,代码行数:9,代码来源:UnitGraphics.java

示例8: initComponents

import javax.swing.JList; //导入方法依赖的package包/类
private void initComponents() {
	setLayout(new BorderLayout(5, 5));
	this.setBorder(new EmptyBorder(20, 20, 20, 20));
	//classesList = new JList(new StationsListModel());
	stationsList = new JList();
	stationsList.setListData(stationData.getStationKeys());
	stationsList.setCellRenderer(new StationElementRenderer());
	stationsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	panelDescription = new JLabel(STATIONS_PAR_DESCRIPTION);
	JScrollPane jsp = new JScrollPane(stationsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	jsp.setPreferredSize(new Dimension(140, 200));
	add(panelDescription, BorderLayout.NORTH);
	add(jsp, BorderLayout.WEST);
	stationsList.addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent e) {
			if (e.getValueIsAdjusting()) {
				return;
			}
			updateParsPane();
		}
	});
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:24,代码来源:AllStationsParametersPanel.java

示例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));
    }
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:35,代码来源:PainelSelecaoCor.java

示例10: MenuListener

import javax.swing.JList; //导入方法依赖的package包/类
public MenuListener(JFrame mainContainer, GuiEventListener listener, JTabbedPane tabbedPane,
		JList<String> firstListOfAnthills, JList<String> secondListOfAnthills, JList<String> thirdListOfAnthills,
		JList<String> replays, JButton buttonStart, JRadioButton radioQualification,
		JRadioButton radioTournamentSemiFinals, JScrollPane scrollPaneQualification,
		JScrollPane scrollPaneTournament, JCheckBox runInBackgroundCheckbox) {
	this.tabbedPane = tabbedPane;
	this.buttonStart = buttonStart;
	this.firstListOfAnthills = firstListOfAnthills;
	this.secondListOfAnthills = secondListOfAnthills;
	this.thirdListOfAnthills = thirdListOfAnthills;
	this.replays = replays;
	this.radioQualification = radioQualification;
	this.radioTournamentSemiFinals = radioTournamentSemiFinals;
	this.scrollPaneQualification = scrollPaneQualification;
	this.scrollPaneTournament = scrollPaneTournament;
	this.listener = listener;
	this.runInBackgroundCheckbox = runInBackgroundCheckbox;

	tabbedPane.addChangeListener(this);
	firstListOfAnthills.addListSelectionListener(this);
	secondListOfAnthills.addListSelectionListener(this);
	thirdListOfAnthills.addListSelectionListener(this);
	replays.addListSelectionListener(this);
	buttonStart.addActionListener(this);
	radioQualification.addActionListener(this);
	radioTournamentSemiFinals.addActionListener(this);
}
 
开发者ID:gamefest2017,项目名称:ants,代码行数:28,代码来源:MenuListener.java

示例11: subscribeActual

import javax.swing.JList; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super ListSelectionEvent> observer) {
    JList<?> w = widget;

    ListSelectionEventConsumer aec = new ListSelectionEventConsumer(observer, w);
    observer.onSubscribe(aec);

    w.addListSelectionListener(aec);
    if (aec.get() == null) {
        aec.onDispose(w);
    }
}
 
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:13,代码来源:ListSelectionEventObservable.java

示例12: createFoldedSpace

import javax.swing.JList; //导入方法依赖的package包/类
/**
 * @param jl
 * @return
 */
private void createFoldedSpace(JList jl)
{
	jl.addListSelectionListener(new RemoveAndRefold(bpg));

	bipartitePanel = new JPanel();
	foldAndDisplay(bpg);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:12,代码来源:TestSouthernWomenBipartite.java

示例13: setup

import javax.swing.JList; //导入方法依赖的package包/类
private void setup(String entityName)
{
	title = CurrentLocale.get("com.tle.admin.search.entitydialog.select", entityName);

	model = new GenericListModel<NameId>();
	list = new JList(model);
	list.addListSelectionListener(this);
	list.addMouseListener(this);

	JScrollPane scroll = new JScrollPane(list);

	okButton = new JButton(CurrentLocale.get("com.dytech.edge.admin.helper.ok"));
	cancelButton = new JButton(CurrentLocale.get("com.dytech.edge.admin.helper.cancel"));

	okButton.addActionListener(this);
	cancelButton.addActionListener(this);

	JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
	buttons.add(okButton);
	buttons.add(cancelButton);

	buttons.setPreferredSize(buttons.getMinimumSize());

	content = new JPanel(new BorderLayout(5, 5));
	content.setBorder(AppletGuiUtils.DEFAULT_BORDER);

	content.add(new JLabel(title), BorderLayout.NORTH);
	content.add(scroll, BorderLayout.CENTER);
	content.add(buttons, BorderLayout.SOUTH);

	updateButtons();
}
 
开发者ID:equella,项目名称:Equella,代码行数:33,代码来源:EntityDialog.java

示例14: setup

import javax.swing.JList; //导入方法依赖的package包/类
private void setup()
{
	JLabel label = new JLabel(CurrentLocale.get("com.tle.admin.workflow.stepdialog.title"));

	model = new GenericListModel<Class<? extends WorkflowNode>>();
	list = new JList(model);
	list.setCellRenderer(new WorkflowCellRenderer());
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.addListSelectionListener(this);
	list.addMouseListener(this);

	ok = new JButton(CurrentLocale.get("com.tle.admin.ok"));
	cancel = new JButton(CurrentLocale.get("com.tle.admin.cancel"));

	ok.addActionListener(this);
	cancel.addActionListener(this);

	final int height1 = label.getPreferredSize().height;
	final int height2 = ok.getPreferredSize().height;
	final int width1 = cancel.getPreferredSize().width;

	final int[] rows = {height1, TableLayout.FILL, height2,};
	final int[] cols = {TableLayout.FILL, width1, width1,};

	content = new JPanel(new TableLayout(rows, cols));
	content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	content.add(label, new Rectangle(0, 0, 3, 1));
	content.add(new JScrollPane(list), new Rectangle(0, 1, 3, 1));
	content.add(ok, new Rectangle(1, 2, 1, 1));
	content.add(cancel, new Rectangle(2, 2, 1, 1));

	updateButtons();
}
 
开发者ID:equella,项目名称:Equella,代码行数:35,代码来源:StepDialog.java

示例15: setup

import javax.swing.JList; //导入方法依赖的package包/类
private void setup()
{
	JLabel label = new JLabel(getTitle());

	model = new DefaultListModel();
	list = new JList(model);
	list.setCellRenderer(new Renderer(repository));
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.addListSelectionListener(this);
	list.addMouseListener(this);

	ok = new JButton("OK");
	cancel = new JButton("Cancel");

	ok.addActionListener(this);
	cancel.addActionListener(this);

	final int height1 = label.getPreferredSize().height;
	final int height2 = ok.getPreferredSize().height;
	final int width1 = cancel.getPreferredSize().width;

	final int[] rows = {height1, TableLayout.FILL, height2,};
	final int[] cols = {TableLayout.FILL, width1, width1,};

	content = new JPanel(new TableLayout(rows, cols));
	content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	content.add(label, new Rectangle(0, 0, 3, 1));
	content.add(new JScrollPane(list), new Rectangle(0, 1, 3, 1));
	content.add(ok, new Rectangle(1, 2, 1, 1));
	content.add(cancel, new Rectangle(2, 2, 1, 1));

	updateButtons();
}
 
开发者ID:equella,项目名称:Equella,代码行数:35,代码来源:ControlDialog.java


注:本文中的javax.swing.JList.addListSelectionListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。