dragListener = new LineDragListener(); addMouseListener(dragListener); addMouseMotionListener(dragListener);
dragListener = new LineDragListener(); addMouseListener(dragListener); addMouseMotionListener(dragListener);
public void focusLost(FocusEvent fe) { if ((dragListener != null) && dragListener.isDragging()) { dragListener.abortDrag();
public void focusLost(FocusEvent fe) { if ((dragListener != null) && dragListener.isDragging()) { dragListener.abortDrag();
/** Creates a new instance of BaseTable. */ public BaseTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm) { super(dm, cm, sm); //set single selection mode getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setSurrendersFocusOnKeystroke(true); setCellSelectionEnabled(false); setRowSelectionAllowed(true); setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); //See the sources for JTable for what these do putClientProperty("JTable.autoStartsEdit", Boolean.FALSE); //NOI18N putClientProperty("terminateEditOnFocusLost", PropUtils.psCommitOnFocusLoss ? Boolean.FALSE : Boolean.TRUE); //NOI18N //create a listener for dragging the grid center line to resize columns dragListener = new LineDragListener(); addMouseListener(dragListener); addMouseMotionListener(dragListener); //If we are not focus cycle root, when an editor is removed, focus //will get set to a random component which is usually not the property //sheet setFocusCycleRoot(true); enableEvents(AWTEvent.FOCUS_EVENT_MASK); //JDK 1.5 if (getClass() != SheetTable.class) { throw new NoClassDefFoundError("Only SheetTable may subclass BaseTable, for good reasons"); //NOI18N } }
public void mouseDragged(MouseEvent e) { if (!armed && !dragging) return; int newPos = e.getPoint().x; TableColumn c0 = getColumnModel().getColumn(0); TableColumn c1 = getColumnModel().getColumn(1); int min = Math.max(c0.getMinWidth(), getWidth() - c1.getMaxWidth()); int max = Math.min(c0.getMaxWidth(), getWidth() - c1.getMinWidth()); if ((newPos >= min) && (newPos <= max)) { pos = newPos; update(); } }
public void mouseMoved(MouseEvent e) { setArmed(!isEditing() && onCenterLine(e)); }
/** Overridden to not change the selection if the user is currently * dragging the center line */ public void changeSelection(int row, int column, boolean toggle, boolean extend) { //DragListener can be null, because changeSelection is called in //superclass constructor if (dragListener != null && dragListener.isArmed()) { return; } if (PropUtils.isLoggable(BaseTable.class)) { PropUtils.log(BaseTable.class, "ChangeSelection to " + row + "," + column); //NOI18N } super.changeSelection(row, column, toggle, extend); fireChange(); }
public void focusLost(FocusEvent fe) { if ((dragListener != null) && dragListener.isDragging()) { dragListener.abortDrag(); } PropUtils.log(BaseTable.class, fe); //Ignore temporary focus changes, so sloppy focus middle mouse button //cut/paste can work if (fe.isTemporary()) { return; } Component opposite = fe.getOppositeComponent(); if (!isKnownComponent(opposite)) { doFocusLost(opposite); } }
public void mouseExited(MouseEvent e) { setArmed(false); }
public void mouseMoved(MouseEvent e) { setArmed(!isEditing() && onCenterLine(e)); }
public void mouseDragged(MouseEvent e) { if (!armed && !dragging) { return; } int newPos = e.getPoint().x; TableColumn c0 = getColumnModel().getColumn(0); TableColumn c1 = getColumnModel().getColumn(1); int min = Math.max(c0.getMinWidth(), getWidth() - c1.getMaxWidth()); int max = Math.min(c0.getMaxWidth(), getWidth() - c1.getMinWidth()); if ((newPos >= min) && (newPos <= max)) { pos = newPos; update(); } }
public void mouseMoved(MouseEvent e) { setArmed(!isEditing() && onCenterLine(e)); }
public void mouseExited(MouseEvent e) { setArmed(false); }
/** Overridden to not change the selection if the user is currently * dragging the center line */ public void changeSelection(int row, int column, boolean toggle, boolean extend) { //DragListener can be null, because changeSelection is called in //superclass constructor if ((dragListener != null) && dragListener.isArmed()) { return; } if (PropUtils.isLoggable(BaseTable.class)) { PropUtils.log(BaseTable.class, "ChangeSelection to " + row + "," + column); //NOI18N } super.changeSelection(row, column, toggle, extend); fireChange(); }
public void mouseDragged(MouseEvent e) { if (!armed && !dragging) return; int newPos = e.getPoint().x; TableColumn c0 = getColumnModel().getColumn(0); TableColumn c1 = getColumnModel().getColumn(1); int min = Math.max(c0.getMinWidth(), getWidth() - c1.getMaxWidth()); int max = Math.min(c0.getMaxWidth(), getWidth() - c1.getMinWidth()); if ((newPos >= min) && (newPos <= max)) { pos = newPos; update(); } }