Component addMouseListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Component addMouseListener method.

This code example shows how to use the following methods:addMouseListener, addMouseMotionListener, addMouseWheelListener
	} 
 
	public synchronized void register() { 
		resetCursorToCenter(); 
        if (component != null) {
            component.addMouseListener(this);
            component.addMouseMotionListener(this);
            component.addMouseWheelListener(this);
        } 
	} 
 
	public synchronized void unregister() { 
        if (component != null) {
            component.removeMouseListener(this);
            component.removeMouseMotionListener(this);
            component.removeMouseWheelListener(this);
        } 
	} 
 
	protected Component getComponent() {

7
CodeRank
This code example shows how to use the following methods:addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, getGraphicsConfiguration
import com.google.inject.Inject; 
 
public class Java2dDesktopApplication { 
 
	Java2dWindow java2dWindow;
	 
	@Inject 
	KeyboardInput keyboardInput;
	 
	@Inject 
	MouseInput mouseInput;
	 
	@Inject 
	Java2dGame java2dGame;
 
	boolean exitOnClose;
 
	public void init(String title, Dimension dimension, boolean exitOnClose) {
		this.exitOnClose = exitOnClose;
		createWindow(title, dimension, java2dGame);

6
CodeRank
This code example shows how to use the following methods:addMouseListener, setAutoscrolls, setBorder, addListSelectionListener, setCellRenderer
            textJList.setCellRenderer(new BugListCellRenderer());
            cmpMapdustBugs = ComponentUtil.createJScrollPane(textJList);
            add(cmpMapdustBugs, BorderLayout.CENTER);
        } else { 
            mapdustBugsJList = ComponentUtil.createJList(mapdustBugsList, menu);
            mapdustBugsJList.addListSelectionListener(this);
            DisplayMenu adapter = new DisplayMenu(mapdustBugsJList, menu);
            mapdustBugsJList.addMouseListener(adapter);
            cmpMapdustBugs = ComponentUtil.createJScrollPane(mapdustBugsJList);
            add(cmpMapdustBugs, BorderLayout.CENTER);
        } 
        /* add button panel */ 
        add(btnPanel, BorderLayout.SOUTH);
    } 
 
    /** 
     * Updates the <code>MapdustPanel</code> with the new list of 
     * <code>MapdustBug</code>s. If the list is null or empty an appropriate 
     * message will be displayed on the list. 
     * 

6
CodeRank
This code example shows how to use the following methods:addKeyListener, addMouseListener, addMouseMotionListener, addTreeSelectionListener, setCellRenderer
     *            the test tree listener 
     * 
     * @return the initialized test tree GUI 
     */ 
    private JTree makeTree(TreeModel treeModel, ReportTreeListener treeListener) {
        JTree treevar = new JTree(treeModel);
        treevar.setCellRenderer(getCellRenderer());
        treevar.setRootVisible(false);
        treevar.setShowsRootHandles(true);
 
        treeListener.setJTree(treevar);
        treevar.addTreeSelectionListener(treeListener);
        treevar.addMouseListener(treeListener);
        treevar.addMouseMotionListener(treeListener);
        treevar.addKeyListener(treeListener);
 
        return treevar;
    } 
 
    /** 
6
CodeRank
This code example shows how to use the following methods:addMouseListener, getBackground, getFont, getForeground
	public Component getTableCellRendererComponent(JTable table, Object value,     
			boolean isSelected, boolean hasFocus, int row, int column) {     
		if (table != null) {     
		  JTableHeader header = table.getTableHeader();     
		  if (header != null) {     
		    rendererComponent.setForeground(header.getForeground());     
		    rendererComponent.setBackground(header.getBackground());     
		    rendererComponent.setFont(header.getFont());     
		    header.addMouseListener(rendererComponent);     
		  }      
		}      
 
		setColumn(column); //For enable the header check box     
		setHorizontalAlignment(SwingConstants.CENTER);
		return rendererComponent;     
	}      
	protected void setColumn(int column) {     
		this.column = column;     
	}      
	public int getColumn() {      
6
CodeRank
This code example shows how to use the following methods:addMouseListener, setSize, setVisible
import test.java.awt.regtesthelpers.Util; 
 
public class GrabOnUnfocusableToplevel { 
    public static void main(String[] args) {
        Robot r = Util.createRobot();
        JWindow w = new JWindow();
        w.setSize(100, 100);
        w.setVisible(true);
        Util.waitForIdle(r);
 
        final JPopupMenu menu = new JPopupMenu();
        JButton item = new JButton("A button in popup");
 
        menu.add(item);
 
        w.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent me) {
                menu.show(me.getComponent(), me.getX(), me.getY());
 
                System.out.println("Showing menu at " + menu.getLocationOnScreen() +

6
CodeRank
This code example shows how to use the following methods:addMouseListener, setBackground, setMinimumSize
    public DrawingFrame() 
    { 
        super("Extender-Based Host"); 
 
        m_toolbar = new JToolBar("Toolbar");
        m_panel = new JPanel();
        m_panel.setBackground(Color.WHITE);
        m_panel.setLayout(null);
        m_panel.setMinimumSize(new Dimension(400, 400));
        m_panel.addMouseListener(this);
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(m_toolbar, BorderLayout.NORTH);
        getContentPane().add(m_panel, BorderLayout.CENTER);
        setSize(400, 400);
    } 
 
    /** 
     * This method sets the currently selected shape to be used for drawing 
     * on the canvas. 
     * @param name The name of the shape to use for drawing on the canvas. 
6
CodeRank
This code example shows how to use the following methods:addMouseListener, getSelectionModel, setCellRenderer, setSelectionMode
 
    categoryComboBox = new JComboBox();
    categoryComboBox.addActionListener(new CategorySelectionAction());
    categoryComboBox.setRenderer(new FunctionCategoryCellRenderer());
 
    formulaList = new JList();
    formulaList.setCellRenderer(new FunctionDescriptionCellRenderer());
    formulaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    formulaList.addMouseListener(new FormulaListMouseHandler());
    formulaList.getSelectionModel().addListSelectionListener(new FormulaListSelectionHandler());
 
    add(new JLabel(Messages.getInstance().getString("FunctionListPanel.Category")),
        new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    add(categoryComboBox,
        new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.NORTH,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
 
 
    final JScrollPane formulaListScrollPane = new JScrollPane(formulaList);
6
CodeRank
This code example shows how to use the following methods:addMouseListener
6
CodeRank
This code example shows how to use the following methods:addMouseListener, addMouseMotionListener, setCursor, setContentAreaFilled, setBorder
     * @return 
     */ 
    protected JXToolBar initToolbar(JXToolBar toolbar) {
 
        resizeBtn = UISupport.createToolbarButton(UISupport.createImageIcon("/icon_resize.gif"));
        resizeBtn.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR));
        resizeBtn.setContentAreaFilled(false);
        resizeBtn.setBorder(null);
        resizeBtn.setToolTipText("Drag to resize...");
        resizeBtn.addMouseMotionListener(new MouseMotionListener() {
 
            @Override 
            public void mouseMoved(MouseEvent e) {
                // TODO Auto-generated method stub 
 
            } 
 
            @Override 
            public void mouseDragged(MouseEvent e) {
                frame.setSize(frame.getWidth() - mouseX + e.getX(), frame.getHeight() - mouseY + e.getY());

6
CodeRank
addMouseListener Method Overview
Adds the specified mouse listener to receive mouse events from this component.
See Code Examples for other Java 8 Component Methods: