Example usage for java.awt.event MouseEvent consume

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

Introduction

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

Prototype

public void consume() 

Source Link

Document

Consumes this event so that it will not be processed in the default manner by the source which originated it.

Usage

From source file:br.com.utfpr.pb.view.CaixasView.java

private void jTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableMouseClicked
    // TODO add your handling code here:
    tableEvent();/*from   w  w  w  .  ja  va2s. c  o  m*/
    if (evt.getClickCount() == 2 && !evt.isConsumed()) {
        evt.consume();
        //handle double click event.
        openModal();
    }

}

From source file:com.diversityarrays.kdxplore.editing.EntityPropertiesTable.java

@Override
public boolean editCellAt(int row, int column, EventObject e) {
    if (e instanceof MouseEvent) {
        MouseEvent me = (MouseEvent) e;
        if (SwingUtilities.isLeftMouseButton(me) && 2 != me.getClickCount()) {
            return false;
        }/*w w w  . j a  v  a  2s  .  c o  m*/
        me.consume();
    }

    @SuppressWarnings("unchecked")
    EntityPropertiesTableModel<T> eptm = (EntityPropertiesTableModel<T>) getModel();
    if (!eptm.isCellEditable(row, column)) {
        return false;
    }

    if (handleEditCellAt(eptm, row, column)) {
        return false;
    }

    PropertyDescriptor pd = eptm.getPropertyDescriptor(row);
    if (pd == null) {
        return super.editCellAt(row, column);
    }

    Class<?> propertyClass = pd.getPropertyType();

    if (propertyChangeConfirmer != null && !propertyChangeConfirmer.isChangeAllowed(pd)) {
        return false;
    }

    if (java.util.Date.class.isAssignableFrom(propertyClass)) {
        try {
            java.util.Date dateValue = (Date) pd.getReadMethod().invoke(eptm.getEntity());

            if (propertyChangeConfirmer != null) {
                propertyChangeConfirmer.setValueBeforeChange(dateValue);
            }

            Closure<Date> onComplete = new Closure<Date>() {
                @Override
                public void execute(Date result) {
                    if (result != null) {
                        if (propertyChangeConfirmer == null
                                || propertyChangeConfirmer.valueChangeCanCommit(pd, result)) {
                            getModel().setValueAt(result, row, column);
                        }
                    }
                }
            };

            String title = pd.getDisplayName();
            DatePickerDialog datePicker = new DatePickerDialog(GuiUtil.getOwnerWindow(this), title, onComplete);
            datePicker.setDate(dateValue);
            datePicker.setVisible(true);

        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e1) {
            e1.printStackTrace();
        }
        return false;
    }
    // else if (Enum.class.isAssignableFrom(propertyClass)) {
    // }

    Log.d(TAG, "editCellAt(" + row + "," + column + ") No Editor override provided for "
            + propertyClass.getName());
    return super.editCellAt(row, column, e);
}

From source file:Main.java

public void mouseMoved(MouseEvent e) {
    if (!rectangle.contains(e.getX(), e.getY()) || e.isConsumed()) {
        if (isActive) {
            isActive = false;// w w w  . j ava  2s. c o  m
            repaint();
        }
        return; // quickly return, if outside our rectangle
    }

    int x = e.getX() - rectangle.x;
    int y = e.getY() - rectangle.y;
    boolean active = polygon.contains(x, y);

    if (isActive != active)
        setState(active);
    if (active)
        e.consume();
}

From source file:DragPictureDemo2.java

public void mousePressed(MouseEvent e) {
    //Don't bother to drag if there is no image.
    if (image == null)
        return;//from www  . j  ava 2s  .  c  om

    firstMouseEvent = e;
    e.consume();
}

From source file:br.com.utfpr.pb.view.PedidoCompraView.java

private void jTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableMouseClicked
    // TODO add your handling code here:
    tableEvent();/*ww w .  j av  a 2 s . c om*/
    if (evt.getClickCount() == 2 && !evt.isConsumed()) {
        evt.consume();
        //handle double click event.
        openModal();
    }
}

From source file:DragPictureDemo2.java

public void mouseDragged(MouseEvent e) {
    //Don't bother to drag if the component displays no image.
    if (image == null)
        return;//from   w w  w  .j a  v a  2 s.  co m

    if (firstMouseEvent != null) {
        e.consume();

        //If they are holding down the control key, COPY rather than MOVE
        int ctrlMask = InputEvent.CTRL_DOWN_MASK;
        int action = ((e.getModifiersEx() & ctrlMask) == ctrlMask) ? TransferHandler.COPY
                : TransferHandler.MOVE;

        int dx = Math.abs(e.getX() - firstMouseEvent.getX());
        int dy = Math.abs(e.getY() - firstMouseEvent.getY());
        //Arbitrarily define a 5-pixel shift as the
        //official beginning of a drag.
        if (dx > 5 || dy > 5) {
            //This is a drag, not a click.
            JComponent c = (JComponent) e.getSource();
            TransferHandler handler = c.getTransferHandler();
            //Tell the transfer handler to initiate the drag.
            handler.exportAsDrag(c, firstMouseEvent, action);
            firstMouseEvent = null;
        }
    }
}

From source file:edu.ku.brc.ui.dnd.SimpleGlassPane.java

/**
 * @param e// ww  w.  j av  a  2s .c o  m
 */
protected void checkMouseEvent(MouseEvent e) {
    Rectangle r = getInternalBounds();
    Point p = e.getPoint();

    if (r.contains(p)) {
        if (!dblClickProgBar || !getProgressBarRect().contains(p)) {
            e.consume();
        }
    }
}

From source file:AncestorTree.java

public boolean isCellEditable(EventObject evt) {
    if (evt instanceof MouseEvent) {
        MouseEvent mEvt = (MouseEvent) evt;
        if (mEvt.getClickCount() == 1) {
            int row = m_tree.getRowForLocation(mEvt.getX(), mEvt.getY());
            if (row != m_lastRow) {
                m_lastRow = row;/*from   www . j  ava2s  . c  om*/
                m_lastClick = System.currentTimeMillis();
                return false;
            } else if (System.currentTimeMillis() - m_lastClick > 1000) {
                m_lastRow = -1;
                m_lastClick = 0;
                prepareEditor();
                mEvt.consume();
                return true;
            } else
                return false;
        }
    }
    return false;
}

From source file:com.limegroup.gnutella.gui.search.ResultPanel.java

/**
 * Sets extra values for non dummy ResultPanels.
 * (Used for all tables that will have results.)
 *
 * Currently://w  ww  . jav  a2  s.  co m
 * - Sorts the count column, if it is visible & real-time sorting is on.
 * - Adds listeners, so the filters can be displayed when necessary.
 */
private void setupRealTable() {
    SearchTableColumns columns = ((ResultPanelModel) DATA_MODEL).getColumns();
    LimeTableColumn countColumn = columns.getColumn(SearchTableColumns.COUNT_IDX);
    if (SETTINGS.REAL_TIME_SORT.getValue() && TABLE.isColumnVisible(countColumn.getId())) {
        DATA_MODEL.sort(SearchTableColumns.COUNT_IDX); // ascending
        DATA_MODEL.sort(SearchTableColumns.COUNT_IDX); // descending
    }

    MouseListener filterDisplayer = new MouseListener() {
        public void mouseClicked(MouseEvent e) {
            if (e.isConsumed())
                return;
            e.consume();
            SearchMediator.panelSelected(ResultPanel.this);
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }
    };
    // catches around the button area.
    MAIN_PANEL.addMouseListener(filterDisplayer);
    // catches the blank area before results fill in
    SCROLL_PANE.addMouseListener(filterDisplayer);
    // catches selections on the table
    TABLE.addMouseListener(filterDisplayer);
    // catches the table header
    TABLE.getTableHeader().addMouseListener(filterDisplayer);
}

From source file:com.diversityarrays.kdxplore.curate.TraitsAndInstancesPanel2.java

public TraitsAndInstancesPanel2(CurationContext cc, Font smallFont, TIStatsTableModel tistm,
        boolean anyInstanceNumbers, int nInvalidRules, String tAndIpanelLabel,
        CurationMenuProvider curationMenuProvider, Consumer<List<OutlierSelection>> outlierConsumer) {
    super(new BorderLayout());

    this.curationContext = cc;
    this.outlierConsumer = outlierConsumer;
    this.curationMenuProvider = curationMenuProvider;

    this.tiStatsModel = tistm;

    curationContext.addPropertyChangeListener(propertyChangeListener);

    traitInstanceStatsTable = new TraitInstanceStatsTable(tiStatsModel);

    traitInstanceStatsTable.addPropertyChangeListener("rowSorter", rowSorterChangeListener);
    traitInstanceStatsTable.setAutoCreateRowSorter(true);

    traitInstanceStatsTable.addMouseListener(new MouseAdapter() {
        @Override/*from   ww w. j a v  a 2 s . c o m*/
        public void mouseClicked(MouseEvent me) {
            int clickCount = me.getClickCount();

            if (SwingUtilities.isRightMouseButton(me) && 1 == clickCount) {
                me.consume();
                showContextMenu(me);
            } else if (SwingUtilities.isLeftMouseButton(me) && 2 == clickCount) {
                showTraitInstanceInfo(me);
            }
        }
    });

    Map<String, TableColumn[]> tableColumnsByChoice = createInstanceTableColumnsByChoice();
    TableColumnSelectionButton tcsb = new TableColumnSelectionButton(traitInstanceStatsTable,
            tableColumnsByChoice);

    StringCellRenderer scRenderer = new StringCellRenderer();
    scRenderer.setHorizontalAlignment(SwingConstants.CENTER);

    statDetailRenderer.setHorizontalAlignment(SwingConstants.CENTER);

    traitInstanceStatsTable.setDefaultRenderer(String.class, scRenderer);
    Transformer<TraitInstance, String> instanceNameTransformer = new Transformer<TraitInstance, String>() {
        @Override
        public String transform(TraitInstance ti) {
            return curationContext.makeTraitInstanceName(ti);
        }
    };
    TraitInstanceCellRenderer tiRenderer = new TraitInstanceCellRenderer(
            curationContext.getTraitColorProvider(), instanceNameTransformer);
    tiRenderer.setName("FOR-STATS-TABLE"); //$NON-NLS-1$
    traitInstanceStatsTable.setDefaultRenderer(TraitInstance.class, tiRenderer);
    traitInstanceStatsTable.setDefaultRenderer(Comparable.class, statDetailRenderer);

    TableColumnModel tcm = traitInstanceStatsTable.getColumnModel();
    Integer viewColumnIndex = tistm.getViewColumnIndex();
    if (viewColumnIndex != null) {
        TableColumn viewColumn = tcm.getColumn(viewColumnIndex);
        viewColumn.setMaxWidth(40);
        viewColumn.setCellRenderer(new OptionalCheckboxRenderer("No Values"));
    }

    if (nInvalidRules <= 0) {
        // Hide that column!
        int columnIndex = tistm.getValRuleErrorColumnIndex();
        columnIndex = traitInstanceStatsTable.convertColumnIndexToView(columnIndex);
        if (columnIndex >= 0) {
            TableColumn c = tcm.getColumn(columnIndex);
            tcm.removeColumn(c);
        }
    }

    TableColumn dataTypeTableColumn = traitInstanceStatsTable.getColumnModel()
            .getColumn(tistm.getTraitInstanceDatatypeColumnIndex());
    dataTypeTableColumn.setCellRenderer(new TraitDataTypeRenderer());

    Function<JTable, JScrollPane> scrollMaker = new Function<JTable, JScrollPane>() {
        @Override
        public JScrollPane apply(JTable t) {
            return new PromptScrollPane(t, "Select Trait in the Panel: " + tAndIpanelLabel);
        }
    };
    TitledTablePanelWithResizeControls ttp = new TitledTablePanelWithResizeControls("Trait Instances",
            traitInstanceStatsTable, smallFont, scrollMaker);
    ttp.scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    ttp.scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, tcsb);

    new CurationContextOptionsPopup(curationContext, ttp.separator);

    if (anyInstanceNumbers) {
        tcsb.setSelectedColumns(SimpleStatistics.GROUP_BASIC_STATS);
    } else {
        Set<Object> headerValues = new HashSet<>();
        for (TableColumn tc : tableColumnsByChoice.get(SimpleStatistics.GROUP_BASIC_STATS)) {
            headerValues.add(tc.getHeaderValue());
        }
        headerValues.remove(tistm.getInstanceHeading());
        tcsb.initialiseSelectedColumns(new Predicate<Object>() {
            @Override
            public boolean evaluate(Object hvalue) {
                return headerValues.contains(hvalue);
            }
        });
    }

    add(ttp, BorderLayout.CENTER);
}