yangbc的专栏

出来混,迟早要烦的

JTable中怎样获取鼠标所在位置的行数

table=new JTable(cells,columnNames);

table.addMouseListener(new java.awt.event.MouseAdapter()
             {
                 public void mouseClicked(java.awt.event.MouseEvent e)
                 {
                     System.out.println("mouseClicked()"); // TODO Auto-generated
                                                           // Event stub
                                                           // mouseClicked()
                    
                     System.out.println("row numbers is :"+table.getRowCount());//获取表格的总行数
                    
                     //获取鼠标点击的行的位置(及行数)
                     Point mousepoint;                    
                     mousepoint =e.getPoint();
                     System.out.println(table.rowAtPoint(mousepoint)+1);
                    
                 }
             });

阅读更多
文章标签: numbers table
个人分类: java相关
上一篇用了12个小时完成一个计算器小作业
下一篇程序员如何防止脑疲劳:下午补充一些干果
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭