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

下面列出了javax.swing.JTable#setCursor ( ) 实例代码,或者点击链接到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 项目: wandora   文件: UmbelSearchConceptSelector.java
private void updateDataTable() {
    dataTable = new JTable();
    dataTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    if(data != null) {
        dataModel = new UmbelConceptTableModel(data);
        dataTable.setModel(dataModel);
        dataTable.setRowSorter(new TableRowSorter(dataModel));

        dataTable.setColumnSelectionAllowed(false);
        dataTable.setRowSelectionAllowed(true);
        dataTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

        TableColumn column = null;
        for (int i=0; i < dataTable.getColumnCount(); i++) {
            column = dataTable.getColumnModel().getColumn(i);
            column.setPreferredWidth(dataModel.getColumnWidth(i));
        }
        tableScrollPane.setViewportView(dataTable);
    }
}
 
源代码3 项目: RobotBuilder   文件: TableRowTransferHandler.java
@Override
public boolean importData(TransferHandler.TransferSupport info) {
    JTable target = (JTable) info.getComponent();
    JTable.DropLocation dl = (JTable.DropLocation) info.getDropLocation();
    int index = dl.getRow();
    int max = table.getModel().getRowCount();
    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) {
            Vector<Object> rowData = (Vector) getTableModel().getDataVector().get(rowFrom);
            getTableModel().removeRow(rowFrom);
            getTableModel().insertRow(index, rowData);
            if (index > rowFrom) {
                index--;
            }
            target.getSelectionModel().addSelectionInterval(index, index);
            return true;
        }
    } catch (UnsupportedFlavorException | IOException e) {
        e.printStackTrace();
    }
    return false;
}
 
源代码4 项目: wandora   文件: MaianaImportPanel.java
public void setTopicMapsList() {
    if(getApiKey() != null) {
        try {
            JSONObject list = MaianaUtils.listAvailableTopicMaps(getApiEndPoint(), getApiKey());
            if(list.has("msg")) {
                WandoraOptionPane.showMessageDialog(window, list.getString("msg"), "API says", WandoraOptionPane.WARNING_MESSAGE);
                //System.out.println("REPLY:"+list.toString());
            }

            if(list.has("data")) {
                mapTable = new JTable();
                mapTable.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                if(list != null) {
                    JSONArray datas = list.getJSONArray("data");
                    TopicMapsTableModel myModel = new TopicMapsTableModel(datas);
                    mapTable.setModel(myModel);
                    mapTable.setRowSorter(new TableRowSorter(myModel));

                    mapTable.setColumnSelectionAllowed(false);
                    mapTable.setRowSelectionAllowed(true);
                    mapTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                    
                    TableColumn column = null;
                    for (int i=0; i < mapTable.getColumnCount(); i++) {
                        column = mapTable.getColumnModel().getColumn(i);
                        column.setPreferredWidth(myModel.getColumnWidth(i));
                    }
                    tableScrollPane.setViewportView(mapTable);
                }
            }
        }
        catch(Exception e) {
            Wandora.getWandora().displayException("Exception '"+e.getMessage()+"' occurred while getting the list of topic maps.", e);
        }
    }


}
 
源代码5 项目: littleluck   文件: HyperlinkCellRenderer.java
@Override
public void mouseMoved(MouseEvent event) {
    // This should only be called if underlineOnRollover is true
    JTable table = (JTable) event.getSource();

    // Locate the table cell under the event location
    int oldHitColumnIndex = hitColumnIndex;
    int oldHitRowIndex = hitRowIndex;

    checkIfPointInsideHyperlink(event.getPoint());

    if (hitRowIndex != oldHitRowIndex ||
            hitColumnIndex != oldHitColumnIndex) {
        if (hitRowIndex != -1) {
            if (tableCursor == null) {
                tableCursor = table.getCursor();
            }
            table.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        } else {
            table.setCursor(tableCursor);
        }

        // repaint the cells affected by rollover
        Rectangle repaintRect;
        if (hitRowIndex != -1 && hitColumnIndex != -1) {
            // we need to repaint new cell with rollover underline
            // cellRect already contains rect of hit cell
            if (oldHitRowIndex != -1 && oldHitColumnIndex != -1) {
                // we also need to repaint previously underlined hyperlink cell
                // to remove the underline
                repaintRect = cellRect.union(
                        table.getCellRect(oldHitRowIndex, oldHitColumnIndex, false));
            } else {
                // we don't have a previously underlined hyperlink, so just repaint new one'
                repaintRect = table.getCellRect(hitRowIndex, hitColumnIndex, false);
            }
        } else {
            // we just need to repaint previously underlined hyperlink cell
            //to remove the underline
            repaintRect = table.getCellRect(oldHitRowIndex, oldHitColumnIndex, false);
        }
        table.repaint(repaintRect);
    }

}
 
源代码6 项目: beautyeye   文件: HyperlinkCellRenderer.java
@Override
public void mouseMoved(MouseEvent event) {
    // This should only be called if underlineOnRollover is true
    JTable table = (JTable) event.getSource();

    // Locate the table cell under the event location
    int oldHitColumnIndex = hitColumnIndex;
    int oldHitRowIndex = hitRowIndex;

    checkIfPointInsideHyperlink(event.getPoint());

    if (hitRowIndex != oldHitRowIndex ||
            hitColumnIndex != oldHitColumnIndex) {
        if (hitRowIndex != -1) {
            if (tableCursor == null) {
                tableCursor = table.getCursor();
            }
            table.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        } else {
            table.setCursor(tableCursor);
        }

        // repaint the cells affected by rollover
        Rectangle repaintRect;
        if (hitRowIndex != -1 && hitColumnIndex != -1) {
            // we need to repaint new cell with rollover underline
            // cellRect already contains rect of hit cell
            if (oldHitRowIndex != -1 && oldHitColumnIndex != -1) {
                // we also need to repaint previously underlined hyperlink cell
                // to remove the underline
                repaintRect = cellRect.union(
                        table.getCellRect(oldHitRowIndex, oldHitColumnIndex, false));
            } else {
                // we don't have a previously underlined hyperlink, so just repaint new one'
                repaintRect = table.getCellRect(hitRowIndex, hitColumnIndex, false);
            }
        } else {
            // we just need to repaint previously underlined hyperlink cell
            //to remove the underline
            repaintRect = table.getCellRect(oldHitRowIndex, oldHitColumnIndex, false);
        }
        table.repaint(repaintRect);
    }

}
 
 方法所在类
 同类方法