javax.swing.JTable#DropLocation ( )源码实例Demo

下面列出了javax.swing.JTable#DropLocation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PyramidShader   文件: TableRowTransferHandler.java
@Override
public boolean importData(TransferHandler.TransferSupport info) {
    JTable target = (JTable) info.getComponent();
    JTable.DropLocation dl = (JTable.DropLocation) info.getDropLocation();
    int dropIndex = dl.getRow();
    int max = table.getModel().getRowCount();
    if (dropIndex < 0 || dropIndex > max) {
        dropIndex = max;
    }
    target.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    try {
        Integer rowFrom = (Integer) info.getTransferable().getTransferData(localObjectFlavor);
        if (rowFrom != -1 && rowFrom != dropIndex) {
            ((Reorderable)table.getModel()).reorder(rowFrom, dropIndex);
            if (dropIndex > rowFrom) {
                dropIndex--;
            }
            target.getSelectionModel().addSelectionInterval(dropIndex, dropIndex);
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
源代码2 项目: finalspeed-91yun   文件: MapRuleRender.java
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
		boolean isSelected, boolean hasFocus, int row, int column) {
	Color fg = null;
	Color bg = null;
	JTable.DropLocation dropLocation = table.getDropLocation();
	if (dropLocation != null
			&& !dropLocation.isInsertRow()
			&& !dropLocation.isInsertColumn()
			&& dropLocation.getRow() == row
			&& dropLocation.getColumn() == column) {

		fg = DefaultLookup.getColor(this, ui, "Table.dropCellForeground");
		bg = DefaultLookup.getColor(this, ui, "Table.dropCellBackground");
		isSelected = true;
	}
	if (isSelected) {
		setBackground(DefaultLookup.getColor(this, ui, "Table.dropCellBackground"));
	} else {
		setBackground( DefaultLookup.getColor(this, ui, "Table.alternateRowColor"));
	}
	MapRule rule=(MapRule)value;
	update(rule,table,row);
	return this;
}
 
源代码3 项目: openjdk-8-source   文件: SynthTableUI.java
private Rectangle getHDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertRow()) {
        return null;
    }

    int row = loc.getRow();
    int col = loc.getColumn();
    if (col >= table.getColumnCount()) {
        col--;
    }

    Rectangle rect = table.getCellRect(row, col, true);

    if (row >= table.getRowCount()) {
        row--;
        Rectangle prevRect = table.getCellRect(row, col, true);
        rect.y = prevRect.y + prevRect.height;
    }

    if (rect.y == 0) {
        rect.y = -1;
    } else {
        rect.y -= 2;
    }

    rect.height = 3;

    return rect;
}
 
源代码4 项目: jdk8u-dev-jdk   文件: SynthTableUI.java
private Rectangle getVDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertColumn()) {
        return null;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();
    int col = loc.getColumn();
    Rectangle rect = table.getCellRect(loc.getRow(), col, true);

    if (col >= table.getColumnCount()) {
        col--;
        rect = table.getCellRect(loc.getRow(), col, true);
        if (ltr) {
            rect.x = rect.x + rect.width;
        }
    } else if (!ltr) {
        rect.x = rect.x + rect.width;
    }

    if (rect.x == 0) {
        rect.x = -1;
    } else {
        rect.x -= 2;
    }

    rect.width = 3;

    return rect;
}
 
源代码5 项目: jdk8u_jdk   文件: SynthTableUI.java
private Rectangle getVDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertColumn()) {
        return null;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();
    int col = loc.getColumn();
    Rectangle rect = table.getCellRect(loc.getRow(), col, true);

    if (col >= table.getColumnCount()) {
        col--;
        rect = table.getCellRect(loc.getRow(), col, true);
        if (ltr) {
            rect.x = rect.x + rect.width;
        }
    } else if (!ltr) {
        rect.x = rect.x + rect.width;
    }

    if (rect.x == 0) {
        rect.x = -1;
    } else {
        rect.x -= 2;
    }

    rect.width = 3;

    return rect;
}
 
源代码6 项目: openjdk-8   文件: SynthTableUI.java
private Rectangle getVDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertColumn()) {
        return null;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();
    int col = loc.getColumn();
    Rectangle rect = table.getCellRect(loc.getRow(), col, true);

    if (col >= table.getColumnCount()) {
        col--;
        rect = table.getCellRect(loc.getRow(), col, true);
        if (ltr) {
            rect.x = rect.x + rect.width;
        }
    } else if (!ltr) {
        rect.x = rect.x + rect.width;
    }

    if (rect.x == 0) {
        rect.x = -1;
    } else {
        rect.x -= 2;
    }

    rect.width = 3;

    return rect;
}
 
源代码7 项目: hottub   文件: SynthTableUI.java
private Rectangle getHDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertRow()) {
        return null;
    }

    int row = loc.getRow();
    int col = loc.getColumn();
    if (col >= table.getColumnCount()) {
        col--;
    }

    Rectangle rect = table.getCellRect(row, col, true);

    if (row >= table.getRowCount()) {
        row--;
        Rectangle prevRect = table.getCellRect(row, col, true);
        rect.y = prevRect.y + prevRect.height;
    }

    if (rect.y == 0) {
        rect.y = -1;
    } else {
        rect.y -= 2;
    }

    rect.height = 3;

    return rect;
}
 
源代码8 项目: jdk8u60   文件: SynthTableUI.java
private Rectangle getHDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertRow()) {
        return null;
    }

    int row = loc.getRow();
    int col = loc.getColumn();
    if (col >= table.getColumnCount()) {
        col--;
    }

    Rectangle rect = table.getCellRect(row, col, true);

    if (row >= table.getRowCount()) {
        row--;
        Rectangle prevRect = table.getCellRect(row, col, true);
        rect.y = prevRect.y + prevRect.height;
    }

    if (rect.y == 0) {
        rect.y = -1;
    } else {
        rect.y -= 2;
    }

    rect.height = 3;

    return rect;
}
 
源代码9 项目: jdk8u60   文件: SynthTableUI.java
private Rectangle getVDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertColumn()) {
        return null;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();
    int col = loc.getColumn();
    Rectangle rect = table.getCellRect(loc.getRow(), col, true);

    if (col >= table.getColumnCount()) {
        col--;
        rect = table.getCellRect(loc.getRow(), col, true);
        if (ltr) {
            rect.x = rect.x + rect.width;
        }
    } else if (!ltr) {
        rect.x = rect.x + rect.width;
    }

    if (rect.x == 0) {
        rect.x = -1;
    } else {
        rect.x -= 2;
    }

    rect.width = 3;

    return rect;
}
 
源代码10 项目: JDKSourceCode1.8   文件: SynthTableUI.java
private Rectangle getHDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertRow()) {
        return null;
    }

    int row = loc.getRow();
    int col = loc.getColumn();
    if (col >= table.getColumnCount()) {
        col--;
    }

    Rectangle rect = table.getCellRect(row, col, true);

    if (row >= table.getRowCount()) {
        row--;
        Rectangle prevRect = table.getCellRect(row, col, true);
        rect.y = prevRect.y + prevRect.height;
    }

    if (rect.y == 0) {
        rect.y = -1;
    } else {
        rect.y -= 2;
    }

    rect.height = 3;

    return rect;
}
 
源代码11 项目: JDKSourceCode1.8   文件: SynthTableUI.java
private Rectangle getVDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertColumn()) {
        return null;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();
    int col = loc.getColumn();
    Rectangle rect = table.getCellRect(loc.getRow(), col, true);

    if (col >= table.getColumnCount()) {
        col--;
        rect = table.getCellRect(loc.getRow(), col, true);
        if (ltr) {
            rect.x = rect.x + rect.width;
        }
    } else if (!ltr) {
        rect.x = rect.x + rect.width;
    }

    if (rect.x == 0) {
        rect.x = -1;
    } else {
        rect.x -= 2;
    }

    rect.width = 3;

    return rect;
}
 
源代码12 项目: openjdk-jdk8u   文件: SynthTableUI.java
private Rectangle getHDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertRow()) {
        return null;
    }

    int row = loc.getRow();
    int col = loc.getColumn();
    if (col >= table.getColumnCount()) {
        col--;
    }

    Rectangle rect = table.getCellRect(row, col, true);

    if (row >= table.getRowCount()) {
        row--;
        Rectangle prevRect = table.getCellRect(row, col, true);
        rect.y = prevRect.y + prevRect.height;
    }

    if (rect.y == 0) {
        rect.y = -1;
    } else {
        rect.y -= 2;
    }

    rect.height = 3;

    return rect;
}
 
源代码13 项目: openjdk-jdk8u   文件: SynthTableUI.java
private Rectangle getVDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertColumn()) {
        return null;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();
    int col = loc.getColumn();
    Rectangle rect = table.getCellRect(loc.getRow(), col, true);

    if (col >= table.getColumnCount()) {
        col--;
        rect = table.getCellRect(loc.getRow(), col, true);
        if (ltr) {
            rect.x = rect.x + rect.width;
        }
    } else if (!ltr) {
        rect.x = rect.x + rect.width;
    }

    if (rect.x == 0) {
        rect.x = -1;
    } else {
        rect.x -= 2;
    }

    rect.width = 3;

    return rect;
}
 
源代码14 项目: Java8CN   文件: SynthTableUI.java
private Rectangle getHDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertRow()) {
        return null;
    }

    int row = loc.getRow();
    int col = loc.getColumn();
    if (col >= table.getColumnCount()) {
        col--;
    }

    Rectangle rect = table.getCellRect(row, col, true);

    if (row >= table.getRowCount()) {
        row--;
        Rectangle prevRect = table.getCellRect(row, col, true);
        rect.y = prevRect.y + prevRect.height;
    }

    if (rect.y == 0) {
        rect.y = -1;
    } else {
        rect.y -= 2;
    }

    rect.height = 3;

    return rect;
}
 
源代码15 项目: xtunnel   文件: MapRuleRender.java
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
		boolean isSelected, boolean hasFocus, int row, int column) {

	Color fg = null;
	Color bg = null;

	JTable.DropLocation dropLocation = table.getDropLocation();
	if (dropLocation != null
			&& !dropLocation.isInsertRow()
			&& !dropLocation.isInsertColumn()
			&& dropLocation.getRow() == row
			&& dropLocation.getColumn() == column) {

		fg = DefaultLookup.getColor(this, ui, "Table.dropCellForeground");
		bg = DefaultLookup.getColor(this, ui, "Table.dropCellBackground");

		isSelected = true;
	}

	if (isSelected) {
		setBackground(DefaultLookup.getColor(this, ui, "Table.dropCellBackground"));
	} else {
		setBackground( DefaultLookup.getColor(this, ui, "Table.alternateRowColor"));
	}

	MapRule rule=(MapRule)value;
	update(rule,table,row);
	return this;
}
 
源代码16 项目: Java8CN   文件: SynthTableUI.java
private Rectangle getVDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertColumn()) {
        return null;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();
    int col = loc.getColumn();
    Rectangle rect = table.getCellRect(loc.getRow(), col, true);

    if (col >= table.getColumnCount()) {
        col--;
        rect = table.getCellRect(loc.getRow(), col, true);
        if (ltr) {
            rect.x = rect.x + rect.width;
        }
    } else if (!ltr) {
        rect.x = rect.x + rect.width;
    }

    if (rect.x == 0) {
        rect.x = -1;
    } else {
        rect.x -= 2;
    }

    rect.width = 3;

    return rect;
}
 
源代码17 项目: Bytecoder   文件: SynthTableUI.java
private Rectangle getVDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertColumn()) {
        return null;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();
    int col = loc.getColumn();
    Rectangle rect = table.getCellRect(loc.getRow(), col, true);

    if (col >= table.getColumnCount()) {
        col--;
        rect = table.getCellRect(loc.getRow(), col, true);
        if (ltr) {
            rect.x = rect.x + rect.width;
        }
    } else if (!ltr) {
        rect.x = rect.x + rect.width;
    }

    if (rect.x == 0) {
        rect.x = -1;
    } else {
        rect.x -= 2;
    }

    rect.width = 3;

    return rect;
}
 
源代码18 项目: hottub   文件: SynthTableUI.java
private Rectangle getVDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertColumn()) {
        return null;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();
    int col = loc.getColumn();
    Rectangle rect = table.getCellRect(loc.getRow(), col, true);

    if (col >= table.getColumnCount()) {
        col--;
        rect = table.getCellRect(loc.getRow(), col, true);
        if (ltr) {
            rect.x = rect.x + rect.width;
        }
    } else if (!ltr) {
        rect.x = rect.x + rect.width;
    }

    if (rect.x == 0) {
        rect.x = -1;
    } else {
        rect.x -= 2;
    }

    rect.width = 3;

    return rect;
}
 
源代码19 项目: jdk8u-jdk   文件: SynthTableUI.java
private Rectangle getVDropLineRect(JTable.DropLocation loc) {
    if (!loc.isInsertColumn()) {
        return null;
    }

    boolean ltr = table.getComponentOrientation().isLeftToRight();
    int col = loc.getColumn();
    Rectangle rect = table.getCellRect(loc.getRow(), col, true);

    if (col >= table.getColumnCount()) {
        col--;
        rect = table.getCellRect(loc.getRow(), col, true);
        if (ltr) {
            rect.x = rect.x + rect.width;
        }
    } else if (!ltr) {
        rect.x = rect.x + rect.width;
    }

    if (rect.x == 0) {
        rect.x = -1;
    } else {
        rect.x -= 2;
    }

    rect.width = 3;

    return rect;
}
 
源代码20 项目: pcgen   文件: EquipInfoTab.java
@Override
public boolean importData(TransferSupport support)
{
	if (!canImport(support) || !support.isDrop())
	{
		return false;
	}

	JTable.DropLocation location = (JTable.DropLocation) support.getDropLocation();
	int row = location.getRow();
	EquipNode node = (EquipNode) equipmentSetTable.getValueAt(row, 0);
	EquipNode beforeNode = null;
	if (location.isInsertRow())
	{
		beforeNode = node;
		node = node.getParent();
	}
	EquipmentSetFacade equipSet = character.getEquipmentSetRef().get();

	if (support.isDataFlavorSupported(EQUIP_NODE_ARRAY_FLAVOR))
	{
		EquipNode[] equipNodeArray = getEquipNodeArray(support);
		if (equipNodeArray == null)
		{
			return false;
		}
		for (EquipNode equipNode : equipNodeArray)
		{
			int quantity = equipSet.getQuantity(equipNode);
			equipSet.removeEquipment(equipNode, quantity);
			equipSet.addEquipment(node, equipNode.getEquipment(), quantity, beforeNode);
		}
	}
	else if (support.isDataFlavorSupported(EQUIPMENT_ARRAY_FLAVOR))
	{
		EquipmentFacade[] equipmentArray = getEquipmentArray(support);
		if (equipmentArray == null)
		{
			return false;
		}
		for (EquipmentFacade equipmentFacade : equipmentArray)
		{
			equipSet.addEquipment(node, equipmentFacade, 1, beforeNode);
		}
	}
	return true;
}
 
 方法所在类
 同类方法