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

public Main(JFrame frame) {
    this.frame = frame;
    cursor = new Point();
    this.addMouseMotionListener(new MouseMotionAdapter() {
        public void mouseMoved(MouseEvent evt) {
            cursor = new Point(evt.getPoint());
            Main.this.repaint();
        }// www .j av  a  2s .c o  m
    });
    this.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            Main.this.setVisible(false);
        }
    });
}

From source file:Main.java

public String getToolTipText(MouseEvent event) {
    Point p = event.getPoint();
    int location = locationToIndex(p);
    String key = (String) model.getElementAt(location);
    String tip = tipProps.getProperty(key);
    return tip;//from   ww w  .j a v  a 2  s  . c  om
}

From source file:Main.java

public void mouseClicked(MouseEvent evt) {
    if ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
        System.out.println("left" + (evt.getPoint()));
    }//from  w  w w.j a  v a2s  .  c  o m
    if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) {
        System.out.println("middle" + (evt.getPoint()));
    }
    if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
        System.out.println("right" + (evt.getPoint()));
    }
}

From source file:com.github.lindenb.jvarkit.tools.bamviewgui.BamFileRef.java

private static JTable createTable(TableModel m) {
    JTable t = new JTable(m) {
        @Override/* w  w w .j  ava2s .  com*/
        public String getToolTipText(MouseEvent event) {
            JTable t = (JTable) event.getSource();
            int x = t.rowAtPoint(event.getPoint());
            if (x == -1)
                return null;
            int y = t.columnAtPoint(event.getPoint());
            if (y == -1)
                return null;
            Object o = t.getValueAt(x, y);
            if (o == null)
                return null;
            return String.valueOf(o);
        }

    };
    t.setToolTipText("");
    t.setShowVerticalLines(false);
    DefaultTableCellRenderer render = new DefaultTableCellRenderer() {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (!isSelected && !hasFocus)
                this.setBackground(row % 2 == 0 ? color1 : color2);
            if (value != null && value instanceof Boolean) {
                if (Boolean.TRUE.equals(value))
                    this.setText("\u2612");
                else if (Boolean.FALSE.equals(value))
                    this.setText("");
            }
            return c;
        }
    };
    render.setOpaque(true);
    for (int i = 0; i < t.getColumnModel().getColumnCount(); ++i) {
        t.getColumnModel().getColumn(i).setCellRenderer(render);
    }
    return t;
}

From source file:org.openmicroscopy.shoola.util.ui.TooltipTableHeader.java

/**
 * Overridden to return the tool tip depending on the location of the mouse.
 * @see JTableHeader#getToolTipText(MouseEvent)
 *///  w  w  w . j a v a  2  s  .co m
public String getToolTipText(MouseEvent e) {
    int col = columnAtPoint(e.getPoint());
    JTable table = getTable();
    if (table == null)
        return "";
    int modelCol = getTable().convertColumnIndexToModel(col);
    String retStr;
    try {
        retStr = toolTips.get(modelCol);
    } catch (Exception ex) {
        retStr = "";
    }
    if (StringUtils.isBlank(retStr))
        retStr = super.getToolTipText(e);
    return retStr;
}

From source file:MouseDrag.java

/** Called when the mouse has been pressed. */
public void mousePressed(MouseEvent e) {
    Point p = e.getPoint();
    System.err.println("mousePressed at " + p);
    startX = p.x;/*from  ww w.  j a va 2 s  . c om*/
    startY = p.y;
    inDrag = true;
}

From source file:slash.navigation.converter.gui.profileview.LazyToolTipChartPanel.java

public String getToolTipText(MouseEvent e) {
    return getTooltipAtPoint(e.getPoint());
}

From source file:MouseDrag.java

public void mouseDragged(MouseEvent e) {
    Point p = e.getPoint();
    // System.err.println("mouse drag to " + p);
    showStatus("mouse Dragged to " + p);
    curX = p.x;//from  w ww  . j  av  a  2  s .  com
    curY = p.y;
    if (inDrag) {
        repaint();
    }
}

From source file:ru.codemine.pos.ui.windows.document.cheque.ChequeListWindow.java

@Override
public void setupActionListeners() {
    setEditActionListener(viewCheque);/*w  w  w.j  a  v a2s  .c om*/

    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:MouseDrag.java

public void mouseMoved(MouseEvent e) {
    showStatus("mouse Moved to " + e.getPoint());
}