Example usage for java.awt.event MouseEvent getComponent

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

Introduction

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

Prototype

public Component getComponent() 

Source Link

Document

Returns the originator of the event.

Usage

From source file:com.mirth.connect.client.ui.ChannelSetup.java

/**
 * Shows the trigger-button popup menu.// ww  w  . j  av  a2s .c  o m
 */
private void showChannelEditPopupMenu(java.awt.event.MouseEvent evt) {
    if (evt.isPopupTrigger()) {
        parent.channelEditPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
    }
}

From source file:Form.Principal.java

public void PanelClientes() {
    int i = 0;//from   w ww.  ja  v a 2 s. com
    int Altura = 0;
    Color gris = new Color(44, 44, 44);
    Color rojo = new Color(221, 76, 76);
    Color azul = new Color(0, 153, 255);
    try {
        //Consultamos todos los clientes
        ResultSet Comandos = Funcion.Select(st, "SELECT * FROM cliente;");
        //Ciclo para crear un panel para cada uno
        while (Comandos.next()) {
            //Creamos un panel con alineacion a la izquierda
            JPanel Panel = new JPanel();
            Panel.setLayout(null);
            jPanel8.add(Panel);
            //Tamao del panel
            Panel.setSize(700, 195);
            // La posicion y del panel ira incrementando para que no se encimen
            Altura = 30 + (i * 205);
            Panel.setLocation(50, Altura);
            Panel.setBackground(Color.white);
            Panel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
            //Creamos label para mostrar los datos del cliente, el codigo html es para que al llegar al final del panel
            //se pase a la siguiente linea y para el margen izquierdo
            JLabel RFC = new JLabel();
            RFC.setText("RFC: " + Comandos.getString("RFC"));
            JLabel Nombre = new JLabel();
            Nombre.setText("Nombre: " + Comandos.getString("NombreCliente"));
            JTextArea Direccion = new JTextArea();
            Direccion.setLineWrap(true);
            Direccion.setBorder(null);
            Direccion.setText("Direccin: " + Comandos.getString("Direccion"));
            JLabel Correo = new JLabel();
            Correo.setText("Correo: " + Comandos.getString("correo"));
            JButton VerMas = new JButton();
            VerMas.setText("Ver ms");
            VerMas.setName(Comandos.getString("idCliente"));
            VerMas.setBackground(azul);
            JButton Eliminar = new JButton();
            Eliminar.setText("Eliminar");
            Eliminar.setName(Comandos.getString("idCliente"));
            Eliminar.setBackground(rojo);
            MouseListener mlVerMas = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                    e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    id = Integer.parseInt(source.getName());
                    jTabbedPane2.setSelectedIndex(4);
                    jButton16.setVisible(true);
                    jButton17.setVisible(true);
                    jButtonEditar.setVisible(true);
                    jPanel9.setVisible(true);
                    jPanel10.setVisible(true);
                    jPanel14.setVisible(false);
                    LlenarPanel();
                }
            };
            VerMas.addMouseListener(mlVerMas);
            MouseListener mlEliminar = new MouseListener() {
                @Override
                public void mouseReleased(MouseEvent e) {
                    //System.out.println("Released!");
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    //System.out.println("Pressed!");
                }

                @Override
                public void mouseExited(MouseEvent e) {
                    //System.out.println("Exited!");
                }

                @Override
                public void mouseEntered(MouseEvent e) {
                    //System.out.println("Entered!");
                    e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                }

                @Override
                public void mouseClicked(MouseEvent e) {
                    JButton source = (JButton) e.getSource();
                    Funcion.Update(st, "DELETE FROM cliente WHERE idCliente = " + source.getName() + ";");
                    Autocompletar.removeAllItems();
                    Autocompletar = new TextAutoCompleter(jTextField2);
                    ResultSet Comandos = Funcion.Select(st, "SELECT * FROM cliente;");
                    try {
                        while (Comandos.next()) {
                            Autocompletar.addItem(Comandos.getString("RFC"));
                        }
                    } catch (SQLException ex) {
                        //Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    jPanel8.removeAll();
                    PanelClientes();
                    jPanel8.repaint();
                }
            };
            Eliminar.addMouseListener(mlEliminar);
            //Fuente del texto
            RFC.setFont(new Font("Verdana", Font.PLAIN, 14));
            RFC.setForeground(gris);
            Nombre.setFont(new Font("Verdana", Font.PLAIN, 14));
            Nombre.setForeground(gris);
            Direccion.setFont(new Font("Verdana", Font.PLAIN, 14));
            Direccion.setForeground(gris);
            Correo.setFont(new Font("Verdana", Font.PLAIN, 14));
            Correo.setForeground(gris);
            VerMas.setFont(new Font("Verdana", Font.PLAIN, 14));
            VerMas.setForeground(Color.white);
            Eliminar.setFont(new Font("Verdana", Font.PLAIN, 14));
            Eliminar.setForeground(Color.white);
            /*VERMAS.setFont(new Font("Verdana", Font.PLAIN, 13));
            VERMAS.setForeground(azul);*/
            //Aadimos los label al panel correspondiente del cliente
            Panel.add(RFC);
            Panel.add(Nombre);
            Panel.add(Direccion);
            Panel.add(Correo);
            Panel.add(VerMas);
            Panel.add(Eliminar);
            RFC.setLocation(30, 10);
            RFC.setSize(610, 30);
            Nombre.setLocation(30, 40);
            Nombre.setSize(610, 30);
            Direccion.setLocation(30, 75);
            Direccion.setSize(610, 40);
            Correo.setLocation(30, 115);
            Correo.setSize(610, 30);
            VerMas.setLocation(210, 150);
            VerMas.setSize(120, 35);
            Eliminar.setLocation(390, 150);
            Eliminar.setSize(120, 35);
            //Panel.add(VERMAS);
            i++;
        }
    } catch (SQLException ex) {
        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
    }
    //Dependiendo de cuantos clientes se agregaron, se ajusta el tamao del panel principal para que el scroll llegue hasta ahi
    jPanel8.setPreferredSize(new Dimension(jPanel8.getWidth(), Altura + 205));
}

From source file:gdt.jgui.entity.webset.JWeblinkEditor.java

private void showIconMenu(MouseEvent e) {
    try {/*from w  ww.ja va 2 s.  c  om*/
        iconMenu = new JPopupMenu();
        JMenuItem loadItem = new JMenuItem("Load");
        iconMenu.add(loadItem);
        loadItem.setHorizontalTextPosition(JMenuItem.RIGHT);
        loadItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    String favicon$ = "http://www.google.com/s2/favicons?domain=" + addressField.getText();
                    URL url = new URL(favicon$);
                    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                    connection.setDoInput(true);
                    connection.connect();
                    InputStream input = connection.getInputStream();
                    ImageIcon icon = new ImageIcon(ImageIO.read(input));
                    int type = BufferedImage.TYPE_INT_RGB;
                    BufferedImage out = new BufferedImage(24, 24, type);
                    Color background = JWeblinkEditor.this.getBackground();
                    Graphics2D g2 = out.createGraphics();
                    g2.setBackground(background);
                    g2.clearRect(0, 0, 24, 24);
                    Image image = icon.getImage();
                    g2.drawImage(image, 4, 4, null);
                    g2.dispose();
                    icon = new ImageIcon(out);
                    iconIcon.setIcon(icon);
                    input.close();
                } catch (Exception ee) {
                    Logger.getLogger(getClass().getName()).info(ee.toString());
                }
            }
        });
        JMenuItem setItem = new JMenuItem("Set");
        iconMenu.add(setItem);
        setItem.setHorizontalTextPosition(JMenuItem.RIGHT);
        setItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("WeblinkEditor:set icon");
                JIconSelector is = new JIconSelector();
                String isLocator$ = is.getLocator();
                if (entihome$ != null)
                    isLocator$ = Locator.append(isLocator$, Entigrator.ENTIHOME, entihome$);
                if (entityKey$ != null)
                    isLocator$ = Locator.append(isLocator$, EntityHandler.ENTITY_KEY, entityKey$);

                String responseLocator$ = getLocator();
                responseLocator$ = Locator.append(responseLocator$, JRequester.REQUESTER_ACTION,
                        ACTION_SET_ICON);
                responseLocator$ = Locator.append(responseLocator$, BaseHandler.HANDLER_METHOD, "response");
                isLocator$ = Locator.append(isLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                        Locator.compressText(responseLocator$));
                JConsoleHandler.execute(console, isLocator$);
            }
        });
        iconMenu.show(e.getComponent(), e.getX(), e.getY());
    } catch (Exception ee) {
        Logger.getLogger(getClass().getName()).severe(ee.toString());
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void jobQueueMousePressedCommon(java.awt.event.MouseEvent evt, JTable table) {
    if (evt.isPopupTrigger()) {
        if (table.getSelectedRowCount() == 0) {
            int row = table.rowAtPoint(evt.getPoint());
            if (row > -1) {
                table.setRowSelectionInterval(row, row);
            }//from   w w w  . j  a va  2  s  . c o  m
        }
        JPopupMenu menu = depositPresenter.getJobQueueMenu((JTable) evt.getSource());
        if (menu != null) {
            menu.show(evt.getComponent(), evt.getX(), evt.getY());
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void jobQueueMouseReleaseCommon(java.awt.event.MouseEvent evt, JTable table) {
    if (evt.isPopupTrigger()) {
        if (table.getSelectedRowCount() == 0) {
            int row = table.rowAtPoint(evt.getPoint());
            if (row > -1) {
                table.setRowSelectionInterval(row, row);
            }/*from   www.  jav  a 2 s .c  o m*/
        }
        JPopupMenu menu = depositPresenter.getJobQueueMenu((JTable) evt.getSource());
        if (menu != null) {
            menu.show(evt.getComponent(), evt.getX(), evt.getY());
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeEntitiesMouseReleased(java.awt.event.MouseEvent evt) {
    if (evt.isPopupTrigger()) {
        TreePath path = treeEntities.getClosestPathForLocation(evt.getX(), evt.getY());
        if (path != null) {
            treeEntities.setSelectionPath(path);
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
            JPopupMenu menu = depositPresenter.getEntityMenu(node);
            if (menu != null) {
                menu.show(evt.getComponent(), evt.getX(), evt.getY());
            }/*from   www  .  ja  v  a2s  .c  o m*/
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeEntitiesMousePressed(java.awt.event.MouseEvent evt) {
    if (evt.isPopupTrigger()) {
        TreePath path = treeEntities.getClosestPathForLocation(evt.getX(), evt.getY());
        if (path != null) {
            treeEntities.setSelectionPath(path);
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
            JPopupMenu menu = depositPresenter.getEntityMenu(node);
            if (menu != null) {
                menu.show(evt.getComponent(), evt.getX(), evt.getY());
            }/* w  ww .ja v  a 2  s.c  o m*/
        }
    } else {
        setDragSourceEntity();
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeStructMapMousePressed(java.awt.event.MouseEvent evt) {
    if (evt.isPopupTrigger()) {
        TreePath path = treeStructMap.getClosestPathForLocation(evt.getX(), evt.getY());
        if (path != null) {
            treeStructMap.setSelectionPath(path);
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
            JPopupMenu menu = depositPresenter.getStructMapMenu(node);
            if (menu != null) {
                menu.show(evt.getComponent(), evt.getX(), evt.getY());
            }//from  w  ww . j  av a 2  s  .co  m
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeStructMapMouseReleased(java.awt.event.MouseEvent evt) {
    if (evt.isPopupTrigger()) {
        TreePath path = treeStructMap.getClosestPathForLocation(evt.getX(), evt.getY());
        if (path != null) {
            treeStructMap.setSelectionPath(path);
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
            JPopupMenu menu = depositPresenter.getStructMapMenu(node);
            if (menu != null) {
                menu.show(evt.getComponent(), evt.getX(), evt.getY());
            }/*from  ww w  . j  a  v a2 s.  c  o  m*/
        }
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void treeFileSystemMouseReleased(java.awt.event.MouseEvent evt) {
    if (evt.isPopupTrigger()) {
        TreePath path = treeFileSystem.getClosestPathForLocation(evt.getX(), evt.getY());
        if (path != null) {
            treeFileSystem.setSelectionPath(path);
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
            JPopupMenu menu = depositPresenter.getFileSystemMenu(node);
            if (menu != null) {
                menu.show(evt.getComponent(), evt.getX(), evt.getY());
            }/*  ww  w  . j a va 2 s. c o  m*/
        }
    }
}