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


Java JList.addMouseListener方法代码示例

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


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

示例1: createSyntaxPanel

import javax.swing.JList; //导入方法依赖的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;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:23,代码来源:HelpFactory.java

示例2: createSyntaxPanel

import javax.swing.JList; //导入方法依赖的package包/类
private JComponent createSyntaxPanel() {
    final JList<String> list = new JList<>();
    DefaultListModel<String> model = new DefaultListModel<>();
    for (Map.Entry<String,String> entry : this.docMap.entrySet()) {
        model.addElement(entry.getKey());
    }
    list.setModel(model);
    list.setCellRenderer(new MyCellRenderer(this.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;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:22,代码来源:StringDialog.java

示例3: 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

示例4: CheckRenderer

import javax.swing.JList; //导入方法依赖的package包/类
public CheckRenderer(final JList<Object> list) {
    this.list = list;
    list.addMouseListener(
            new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    int index = list.locationToIndex(e.getPoint());
                    Point p2 = list.indexToLocation(index);
                    Rectangle r = new Rectangle(p2.x, p2.y, getPreferredSize().height, getPreferredSize().height);
                    if (r.contains(e.getPoint())) {
                        CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index);
                        node.setSelected(!node.isSelected());
                        list.repaint();
                        e.consume();
                    }
                }
            });

    this.setPreferredSize(new Dimension(getPreferredSize().width, getPreferredSize().height - 5));
    startBackground = this.getBackground();
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:23,代码来源:CheckRenderer.java

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: ParameterizedCompletionChoicesWindow

import javax.swing.JList; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param parent The parent window (hosting the text component).
 * @param ac The auto-completion instance.
 * @param context The completion context.
 */
public ParameterizedCompletionChoicesWindow(Window parent,
					AutoCompletion ac,
					final ParameterizedCompletionContext context) {

	super(parent);
	this.ac = ac;
	ComponentOrientation o = ac.getTextComponentOrientation();

	model = new DefaultListModel();
	list = new JList(model);
	if (ac.getParamChoicesRenderer()!=null) {
		list.setCellRenderer(ac.getParamChoicesRenderer());
	}
	list.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			if (e.getClickCount()==2) {
				context.insertSelectedChoice();
			}
		}
	});
	sp = new JScrollPane(list);

	setContentPane(sp);
	applyComponentOrientation(o);
	setFocusableWindowState(false);

	// Give apps a chance to decorate us with drop shadows, etc.
	PopupWindowDecorator decorator = PopupWindowDecorator.get();
	if (decorator!=null) {
		decorator.decorate(this);
	}

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:42,代码来源:ParameterizedCompletionChoicesWindow.java

示例10: addAction

import javax.swing.JList; //导入方法依赖的package包/类
public static void addAction(JList source, Action action) {
    //  Handle enter key

    InputMap im = source.getInputMap();
    im.put(ENTER, ENTER);
    source.getActionMap().put(ENTER, action);

    //  Handle mouse double click
    source.addMouseListener(new ActionMouseListener());
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:11,代码来源:ClassChooserPanel.java

示例11: logFilesList

import javax.swing.JList; //导入方法依赖的package包/类
private JList<String> logFilesList() {
	
	
	file = new File(System.getProperty("user.dir") + File.separator + "Logging Store/");
	
	final JFileChooser fileChooser = new JFileChooser();
	fileChooser.setCurrentDirectory(file);
	fileChooser.setMultiSelectionEnabled(true);

	final DefaultListModel<String> model = new DefaultListModel<String>();
	
	final JList<String> list = new JList<String>(model);
	list.setPreferredSize(new Dimension(85, 480));
	list.setFont(new Font("Dialog", Font.PLAIN, 12));
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.setSelectedIndex(0);
	list.setFixedCellHeight(18);
	list.addMouseListener(new MouseAdapter() {
		@Override
		public void mousePressed(MouseEvent e) {
			if (e.getClickCount() == 2) {
				selectedItem = list.getSelectedValue();
				getSelectedFileName();
			}
		}
	});
	
	list.setCellRenderer(new LogRecordsListRenderer());

	File[] selectedFiles = fileChooser.getCurrentDirectory().listFiles();

	for (File f : selectedFiles) {
		if (f.getName().indexOf(".log") != -1) {
			model.addElement(f.getName());
		}else {
			continue;
		}
	}
	if(model.isEmpty()) {
		model.addElement("List is empty!");
	}
	
	return list;
}
 
开发者ID:Coder-ACJHP,项目名称:Hotel-Properties-Management-System,代码行数:45,代码来源:ReadLogsWindow.java


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