Example usage for java.awt.event MouseEvent getY

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

Introduction

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

Prototype

public int getY() 

Source Link

Document

Returns the vertical y position of the event relative to the source component.

Usage

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

private void initComponents() {
    JPanel containerPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill"));
    containerPanel.setBackground(getBackground());
    containerPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Database Tasks",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));
    containerPanel.add(new JLabel(
            "Cleanup or optimization tasks for the internal database. If no tasks are present, no action is necessary."),
            "top, wrap");

    taskTable = new MirthTable();
    taskTable/*from  w w w .ja  v  a  2 s. c o m*/
            .setModel(new RefreshTableModel(new Object[] { "Status", "Name", "Description", "Start Time" }, 0));
    taskTable.setDragEnabled(false);
    taskTable.setRowSelectionAllowed(true);
    taskTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    taskTable.setRowHeight(UIConstants.ROW_HEIGHT);
    taskTable.setFocusable(false);
    taskTable.setOpaque(true);
    taskTable.getTableHeader().setReorderingAllowed(false);
    taskTable.setEditable(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        taskTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    taskTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent evt) {
            checkSelection(evt);
        }

        @Override
        public void mouseReleased(MouseEvent evt) {
            checkSelection(evt);
        }

        private void checkSelection(MouseEvent evt) {
            if (taskTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) {
                taskTable.clearSelection();
                setVisibleTasks(2, 3, false);
            }
        }
    });

    taskTable.getColumnModel().getColumn(0).setMinWidth(75);
    taskTable.getColumnModel().getColumn(0).setMaxWidth(75);
    taskTable.getColumnModel().getColumn(0).setCellRenderer(new ImageCellRenderer());

    taskTable.getColumnModel().getColumn(1).setMinWidth(45);
    taskTable.getColumnModel().getColumn(1).setPreferredWidth(250);

    taskTable.getColumnModel().getColumn(2).setMinWidth(75);
    taskTable.getColumnModel().getColumn(2).setPreferredWidth(475);

    taskTable.getColumnModel().getColumn(3).setMinWidth(95);
    taskTable.getColumnModel().getColumn(3).setMaxWidth(95);
    taskTable.getColumnModel().getColumn(3).setCellRenderer(new DateCellRenderer());

    taskTable.getSelectionModel().addListSelectionListener(this);

    JScrollPane taskTableScrollPane = new JScrollPane(taskTable);
    containerPanel.add(taskTableScrollPane, "grow, push");

    add(containerPanel, "grow, h 60%");

    JPanel channelsPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill"));
    channelsPanel.setBackground(getBackground());
    channelsPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Affected Channels",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    channelsTable = new MirthTable();
    channelsTable.setModel(new RefreshTableModel(new Object[] { "Name", "Id" }, 0));
    channelsTable.setDragEnabled(false);
    channelsTable.setRowSelectionAllowed(false);
    channelsTable.setRowHeight(UIConstants.ROW_HEIGHT);
    channelsTable.setFocusable(false);
    channelsTable.setOpaque(true);
    channelsTable.getTableHeader().setReorderingAllowed(false);
    channelsTable.setEditable(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        channelsTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    channelsPanel.add(new JScrollPane(channelsTable), "grow");

    add(channelsPanel, "newline, grow, h 40%");
}

From source file:com.tradedesksoftware.ets.client.charting.ChartShiftController.java

public void mouseDragged(MouseEvent mouseEvent) {
    if (!mouseEvent.isControlDown())
        return;//from w  w  w  .j  a v a  2  s  .  com

    if (oldx > -1 && oldy > -1) {
        ValueAxis domAxis = getPlotAxis(chartPanel.getChart(), !axesSwaped);
        ValueAxis rngAxis = getPlotAxis(chartPanel.getChart(), axesSwaped);

        int xdif = mouseEvent.getX() - oldx;
        int ydif = mouseEvent.getY() - oldy;

        final Rectangle scaledDataArea = chartPanel.getScreenDataArea();

        double xdelta = (double) xdif * domAxis.getRange().getLength() / (scaledDataArea.width);
        double ydelta = (double) ydif * rngAxis.getRange().getLength() / (scaledDataArea.height);

        domAxis.setRange(domAxis.getLowerBound() - xdelta, domAxis.getUpperBound() - xdelta);
        rngAxis.setRange(rngAxis.getLowerBound() + ydelta, rngAxis.getUpperBound() + ydelta);
    }

    oldx = mouseEvent.getX();
    oldy = mouseEvent.getY();
}

From source file:JavaXWin.java

public void mousePressed(MouseEvent e) {
    //toFront();//from w  w  w .j a v  a2s. c  o m
    m_dragging = true;
    m_dragX = e.getX();
    m_dragY = e.getY();
    if (e.getX() < CORNER) {
        m_mode = SOUTHWEST;
    } else if (e.getX() > getWidth() - CORNER) {
        m_mode = SOUTHEAST;
    } else {
        m_mode = SOUTH;
    }
}

From source file:com.openbravo.pos.admin.RolesViewTree.java

private void createTree() {

    //Create the jtree            
    root = new DefaultMutableTreeNode();
    uTree = new CheckboxTree(root);
    root.setUserObject("All Permissions");
    uTree.getCheckingModel().setCheckingMode(TreeCheckingModel.CheckingMode.PROPAGATE_PRESERVING_CHECK);
    uTree.clearSelection();/*from  w  w  w  . ja v  a2 s .  c o m*/

    DefaultCheckboxTreeCellRenderer renderer = (DefaultCheckboxTreeCellRenderer) uTree.getCellRenderer();
    renderer.setLeafIcon(null);
    renderer.setClosedIcon(null);
    renderer.setOpenIcon(null);

    // set up listeners
    MouseListener ml = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            int selRow = uTree.getRowForLocation(e.getX(), e.getY());
            TreePath selPath = uTree.getPathForLocation(e.getX(), e.getY());

            if (selPath != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath.getLastPathComponent();
                // If using Right to left Language change the way the check tree works    
                if (!uTree.getComponentOrientation().isLeftToRight()) {
                    if (uTree.isPathChecked(new TreePath(node.getPath()))) {
                        uTree.removeCheckingPath(new TreePath(node.getPath()));
                    } else {
                        uTree.addCheckingPath(new TreePath(node.getPath()));
                    }
                }
                jPermissionDesc.setText(descriptionMap.get(node));
            }
        }
    };
    uTree.addMouseListener(ml);

    // when this listener is fired changes state to dirty 
    uTree.addTreeCheckingListener(new TreeCheckingListener() {
        public void valueChanged(TreeCheckingEvent e) {
            passedDirty.setDirty(true);
        }
    });

    try {
        // Get list of all the permisions in the database
        // and the list of sections
        dbPermissions = (List) m_dlAdmin.getAlldbPermissions();
        branches = m_dlAdmin.getSectionsList();
    } catch (BasicException ex) {
        Logger.getLogger(RolesViewTree.class.getName()).log(Level.SEVERE, null, ex);
    }

    // Create the main branches in the tree
    for (Object branch : branches) {
        section = ((StringUtils.substring(branch.toString(), 0, 2)).equals("##"))
                ? AppLocal.getIntString(StringUtils.right(branch.toString(), branch.toString().length() - 2))
                : branch.toString();
        root.add(new DefaultMutableTreeNode(section));
    }

    classMap = new HashMap();
    descriptionMap = new HashMap();
    nodePaths = new HashMap();
    // Replace displayname, Section and Description 
    // from the database with the correct details from the permissions locale        
    for (DBPermissionsInfo Perm : dbPermissions) {
        Perm.setDisplayName(((StringUtils.substring(Perm.getDisplayName(), 0, 2)).equals("##"))
                ? AppLocal.getIntString(
                        StringUtils.right(Perm.getDisplayName(), Perm.getDisplayName().length() - 2))
                : Perm.getDisplayName());
        Perm.setSection(((StringUtils.substring(Perm.getSection(), 0, 2)).equals("##"))
                ? AppLocal.getIntString(StringUtils.right(Perm.getSection(), Perm.getSection().length() - 2))
                : Perm.getSection());
        Perm.setDescription(((StringUtils.substring(Perm.getDescription(), 0, 2)).equals("##"))
                ? AppLocal.getIntString(
                        StringUtils.right(Perm.getDescription(), Perm.getDescription().length() - 2))
                : Perm.getDescription());
    }
    //put the list into order by display name
    sort();
    // Create the leaf nodes & fill in hashmap's
    for (DBPermissionsInfo Perm : dbPermissions) {
        DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(Perm.getDisplayName(), false);
        if (searchNode(Perm.getSection(), root) != null) {
            searchNode(Perm.getSection(), root).add(newNode);
            classMap.put("[All Permissions, " + Perm.getSection() + ", " + newNode + "]", Perm.getClassName());
            descriptionMap.put(newNode, Perm.getDescription());
            nodePaths.put(Perm.getClassName(), newNode);
        }
    }
    root = sortTree(root);
    jScrollPane1.setViewportView(uTree);
    uTree.expandAll();
}

From source file:ScribbleDragAndDrop.java

/**
 * This method and mouseMoved() below are from the MouseMotionListener
 * interface. If we're in drawing mode, this method adds a new point to the
 * current scribble and requests a redraw
 *///from   www  .ja  v a  2 s.c o m
public void mouseDragged(MouseEvent e) {
    if (dragMode)
        return;
    currentScribble.lineto(e.getX(), e.getY());
    repaint();
}

From source file:com.ivli.roim.controls.ChartControl.java

private ChartEntity findEntity(MouseEvent e) {
    if (null != getChart()) {
        final Insets insets = getInsets();
        final int x = (int) ((e.getX() - insets.left) / this.getScaleX());
        final int y = (int) ((e.getY() - insets.top) / this.getScaleY());

        if (this.getChartRenderingInfo() != null) {
            EntityCollection entities = this.getChartRenderingInfo().getEntityCollection();

            if (entities != null)
                return entities.getEntity(x, y);
        }/*from  w ww  . j  av  a 2s .  c o m*/
    }
    return null;
}

From source file:nz.govt.natlib.ndha.manualdeposit.bulkupload.BulkUploadPresenter.java

private void tblJobListMouseReleased(final java.awt.event.MouseEvent evt) {
    if (evt.isPopupTrigger()) {
        if (theJobListTable.getSelectedRowCount() == 0) {
            final int row = theJobListTable.rowAtPoint(evt.getPoint());
            if (row > -1) {
                theJobListTable.setRowSelectionInterval(row, row);
            }//from   w  ww  . jav  a 2 s .c  om
        }
        final JPopupMenu menu = bulkUploadManager.getBulkUploadMenu();
        if (menu != null) {
            menu.show(evt.getComponent(), evt.getX(), evt.getY());
        }

    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.bulkupload.BulkUploadPresenter.java

private void tableMouseClicked(final java.awt.event.MouseEvent evt) {
    if (evt.isPopupTrigger()) {
        if (theJobListTable.getSelectedRowCount() == 0) {
            final int row = theJobListTable.rowAtPoint(evt.getPoint());
            if (row > -1) {
                theJobListTable.setRowSelectionInterval(row, row);
            }/*from   ww w . ja v a  2s.c  o  m*/
        }
        final JPopupMenu menu = bulkUploadManager.getBulkUploadMenu();
        if (menu != null) {
            menu.show(evt.getComponent(), evt.getX(), evt.getY());
        }

    }
}

From source file:com.mirth.connect.connectors.jdbc.DatabaseMetadataDialog.java

private void checkTableNameSelected(java.awt.event.MouseEvent evt) {
    if (!evt.isPopupTrigger()) {
        int row = includedMetaDataTable.rowAtPoint(new Point(evt.getX(), evt.getY()));
        int column = includedMetaDataTable.columnAtPoint(new Point(evt.getX(), evt.getY()));

        if (row != -1 && column == 0) {
            String type = (String) includedMetaDataTable.getModel().getValueAt(row, 2);
            Boolean selected = (Boolean) includedMetaDataTable.getModel().getValueAt(row, 0);

            if (type.equals(TABLE_TYPE_COLUMN)) {
                RefreshTableModel model = (RefreshTableModel) includedMetaDataTable.getModel();
                boolean nextTableFound = false;
                int tableLength = model.getRowCount();
                int endRow = -1;
                for (int i = row + 1; !nextTableFound && i != tableLength; i++) {
                    String nextType = (String) includedMetaDataTable.getModel().getValueAt(i, 2);
                    if (nextType.equals(TABLE_TYPE_COLUMN)) {
                        endRow = i;/*from w  ww .  j  a v a2  s  .c om*/
                        nextTableFound = true;
                    } else if (i + 1 == tableLength) {
                        endRow = i + 1;
                    }
                }

                if (endRow == -1) {
                    return;
                }

                for (int i = row + 1; i < endRow; i++) {
                    model.setValueAt(selected, i, 0);
                }
            }
        }
    }
}

From source file:com.yosanai.java.aws.console.panel.InstancesPanel.java

public void showPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {
        tblPopup.show(e.getComponent(), e.getX(), e.getY());
    }
}