Example usage for java.awt.event MouseEvent getPoint

List of usage examples for java.awt.event MouseEvent getPoint

Introduction

In this page you can find the example usage for java.awt.event MouseEvent getPoint.

Prototype

public Point getPoint() 

Source Link

Document

Returns the x,y position of the event relative to the source component.

Usage

From source file:Main.java

@Override
protected void processMouseMotionEvent(MouseEvent e, JLayer<? extends JTabbedPane> l) {
    pt.setLocation(e.getPoint());
    JTabbedPane tabbedPane = (JTabbedPane) l.getView();
    int index = tabbedPane.indexAtLocation(pt.x, pt.y);
    if (index >= 0) {
        tabbedPane.repaint(tabbedPane.getBoundsAt(index));
    } else {//from   w  ww  . j  a v a 2s  .  co  m
        tabbedPane.repaint();
    }
}

From source file:ru.codemine.pos.ui.windows.users.UsersListWindow.java

@Override
public void setupActionListeners() {
    setNewActionListener(newUser);/*w ww. j  a  v  a 2  s  . c om*/
    setEditActionListener(editUser);
    setDeleteActionListener(deleteUser);
    setRefreshActionListener(refreshUsersList);

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            int row = table.rowAtPoint(p);
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                menuItemEdit.doClick();
            }
        }
    });

    actionListenersInit = true;
}

From source file:Main.java

private Element getHyperlinkElement(MouseEvent event) {
    Point p = event.getPoint();
    int selRow = tree.getRowForLocation(p.x, p.y);
    TreeCellRenderer r = tree.getCellRenderer();
    if (selRow == -1 || r == null) {
        return null;
    }/*from w w  w .jav a  2  s  .c  o m*/
    TreePath path = tree.getPathForRow(selRow);
    Object lastPath = path.getLastPathComponent();
    Component rComponent = r.getTreeCellRendererComponent(tree, lastPath, tree.isRowSelected(selRow),
            tree.isExpanded(selRow), tree.getModel().isLeaf(lastPath), selRow, true);

    if (rComponent instanceof JEditorPane == false) {
        return null;
    }
    Rectangle pathBounds = tree.getPathBounds(path);
    JEditorPane editor = (JEditorPane) rComponent;
    editor.setBounds(tree.getRowBounds(selRow));
    p.translate(-pathBounds.x, -pathBounds.y);
    int pos = editor.getUI().viewToModel(editor, p);
    if (pos >= 0 && editor.getDocument() instanceof HTMLDocument) {
        HTMLDocument hdoc = (HTMLDocument) editor.getDocument();
        Element elem = hdoc.getCharacterElement(pos);
        if (elem.getAttributes().getAttribute(HTML.Tag.A) != null) {
            return elem;
        }
    }
    return null;
}

From source file:uk.co.modularaudio.util.audio.gui.patternsequencer.PatternSequenceAmpGridMouseListener.java

@Override
public void mouseDragged(final MouseEvent e) {
    processMouseClickAtPosition(e.getPoint());
}

From source file:ru.codemine.pos.ui.windows.stores.StoresListWindow.java

@Override
public void setupActionListeners() {
    setNewActionListener(newStore);//from  w w w  .  j a va2  s .com
    setEditActionListener(editStore);
    setDeleteActionListener(deleteStore);
    setRefreshActionListener(refreshStoreList);

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            int row = table.rowAtPoint(p);
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                menuItemEdit.doClick();
            }
        }
    });

    actionListenersInit = true;
}

From source file:Diva.java

@Override
protected void processMouseMotionEvent(MouseEvent e, JLayer l) {
    Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), l);
    mX = p.x;//from   w w w  .j a va 2 s. c o  m
    mY = p.y;
    l.repaint();
}

From source file:ru.codemine.pos.ui.windows.devices.barcodescanner.BarcodeScannerListWindow.java

@Override
public void setupActionListeners() {
    setNewActionListener(newBarcodeScannerDevice);
    setEditActionListener(editBarcodeScannerDevice);
    setDeleteActionListener(deleteBarcodeScannerDevice);
    setProcessActionListener(setActiveBarcodeScannerDevice);
    setRefreshActionListener(refreshBarcodeScannerDeviceList);

    table.addMouseListener(new MouseAdapter() {
        @Override/*w w w.jav  a 2 s  . c  o m*/
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            int row = table.rowAtPoint(p);
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                menuItemEdit.doClick();
            }
        }
    });

    actionListenersInit = true;
}

From source file:jmupen.MyListSelectionListener.java

@Override
public void mouseClicked(MouseEvent e) {
    int index = list.locationToIndex(e.getPoint());
    if (e.getClickCount() == 2) {
        if (list.getSelectedIndex() != -1) {
            System.out.println("INDEX: " + index + " Total:" + JMupenUtils.getGames().size());
            System.out.println("Games: " + JMupenUtils.getGames().get(index));
            System.out.println("Recents file: " + JMupenUtils.getRecents().toString());
            gamePathToBeOpened = JMupenUtils.getGames().get(index).split("\\|")[1];
            File file = new File(gamePathToBeOpened);
            System.out.println("os: " + System.getProperty("os.name"));
            JMupenGUI.getInstance().showProgress();
            if (JMupenUtils.getOs().equals("lin")) {
                CoreLin c = new CoreLin(file);
                Thread t = new Thread(c);
                t.start();// w  w  w. j a va  2s .  c om
            } else if (JMupenUtils.getOs().equals("mac")) {
                CoreMac c = new CoreMac(file);
                Thread t = new Thread(c);
                t.start();
            } else {
                CoreWin c = new CoreWin(file);
                Thread t = new Thread(c);
                t.start();
            }

        }
    }
}

From source file:MouseDragClip.java

public void mouseDragged(MouseEvent e) {
    Point p = e.getPoint();
    // showStatus("mouse dragged to " + p);
    curX = p.x;/*from w w w  . j  a va2s  .c o  m*/
    curY = p.y;
    if (inDrag) {
        repaint();
    }
}

From source file:MouseDragClip.java

/**
 * Invoked when the mouse moves; just update the status line with the new
 * coordinates./*from  w ww . java2s .c o  m*/
 */
public void mouseMoved(MouseEvent e) {
    showStatus("[" + e.getPoint().x + "," + e.getPoint().y + "]");
}