本文整理汇总了Java中javax.swing.JTable.DropLocation方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.DropLocation方法的具体用法?Java JTable.DropLocation怎么用?Java JTable.DropLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.DropLocation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canImport
import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public boolean canImport(TransferHandler.TransferSupport support) {
if (!support.isDrop()) {
return false;
}
JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation();
if (dl.getColumn() < 1) {
return false;
}
try {
if (support.isDataFlavorSupported(ProjectDnD.TESTCASE_FLAVOR)) {
dropObject = support.getTransferable().getTransferData(ProjectDnD.TESTCASE_FLAVOR);
return true;
} else {
return false;
}
} catch (UnsupportedFlavorException | IOException ex) {
Logger.getLogger(ScenarioDnD.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
}
示例2: importData
import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public boolean importData(TransferHandler.TransferSupport support) {
if (!canImport(support)) {
return false;
}
JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation();
JTable table = (JTable) support.getComponent();
int row = dl.getRow();
int tcRow = dl.getColumn() - 1;
if (row == -1) {
return false;
}
Scenario scenario = (Scenario) table.getModel();
TestCase testCase = scenario.getTestCaseByName(
table.getValueAt(row, 0).toString());
if (dropObject instanceof TestCaseDnD) {
putReusables(testCase, tcRow);
} else {
return false;
}
return super.importData(support);
}
示例3: getTableCellRendererComponent
import javax.swing.JTable; //导入方法依赖的package包/类
@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;
}
示例4: importData
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* Called for drop and paste operations
*/
@Override
public boolean importData(TransferHandler.TransferSupport support)
{
try
{
JTable target = (JTable)support.getComponent();
EntryModel model = (EntryModel)target.getModel();
if (support.isDrop())
{
JTable.DropLocation dl = (JTable.DropLocation)support.getDropLocation();
model.moveRow(rowsidx[0], rowsidx[rowsidx.length-1], dl.getRow());
target.clearSelection();
}
return true;
}
catch (Exception e) { log.warning("\bGeneral error during driver drag:" + e); }
return false;
}
示例5: getHDropLineRect
import javax.swing.JTable; //导入方法依赖的package包/类
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;
}
示例6: getVDropLineRect
import javax.swing.JTable; //导入方法依赖的package包/类
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: importData
import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public boolean importData(TransferHandler.TransferSupport support) {
if (!canImport(support)) {
return false;
}
JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation();
JTable table = (JTable) support.getComponent();
int row = dl.getRow();
int column = dl.getColumn();
if (row == -1) {
return false;
}
if (dropObject instanceof ObjectRepDnD) {
switch (column) {
case inputColumn:
putInput(table, row);
break;
case conditionColumn:
putRelativeObject(table, row);
break;
default:
putWebObjects(table, row);
break;
}
} else if (dropObject instanceof TestDataDetail) {
putTestData(table, row);
} else if (dropObject instanceof TestCaseDnD) {
putReusables(table, row);
} else {
return false;
}
return super.importData(support);
}
示例8: importData
import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public boolean importData(TransferHandler.TransferSupport info) {
JTable target = (JTable) info.getComponent();
JTable.DropLocation dl = (JTable.DropLocation) info.getDropLocation();
int index = dl.getRow();
int numSelected = table.getSelectedRowCount();
int max = table.getModel().getRowCount();
if (index + target.getSelectedRowCount() > max) return false;
if (index < 0 || index > max)
index = max;
target.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
try {
Integer rowFrom = (Integer) info.getTransferable().getTransferData(localObjectFlavor);
if (rowFrom != -1 && rowFrom != index) {
((LineSegmentsObject)table.getModel()).reorder(rowFrom, index, numSelected);
}
//update the selected rows
target.clearSelection();
int index1 = index + numSelected - 1;
target.addRowSelectionInterval(index, index1);
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例9: canImport
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* Called to allow drop operations, allow driver drag full range of rows
* except for last (Add driver box).
*/
@Override
public boolean canImport(TransferHandler.TransferSupport support)
{
JTable.DropLocation dl = (JTable.DropLocation)support.getDropLocation();
JTable target = (JTable)support.getComponent();
if (dl.getRow() > target.getRowCount()) return false;
return true;
}