Mad*_*mer 18
我没有测试过这个,但基础知识是......
JList#locationToIndex(Point)在指定点来获得元素的索引.JList#getModel#getElementAt(int)).ListCellRenderer使用JList#getCellRenderer.Component表示Point为Components上下文getComponentAt在渲染器上使用......可能,像......
int index = list.locationToIndex(p);
Object value = list.getModel().getElementAt(int);
Component comp = listCellRenderer.getListCellRendererComponent(list, value, index, true, true);
comp.setBounds(list.getCellBounds(index, index));
Point contextPoint = SwingUtilities.convertPoint(list, p, comp);
Component child = comp.getComponentAt(contextPoint);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3301 次 |
| 最近记录: |