简体   繁体   English

单击JTable中的JButton时不显示动画

[英]JButton in JTable doesnt display animation when clicked

Ive don everything using this guide http://www.cordinc.com/blog/2010/01/jbuttons-in-a-jtable.html 我使用此指南不做任何事情http://www.cordinc.com/blog/2010/01/jbuttons-in-a-jtable.html

So one little problem remains. 因此,仍然存在一个小问题。 While when i click on the button event is fired and method is executed. 当我单击按钮事件时,将触发事件并执行方法。 The buttons animation does not work providing no visual feedback. 按钮动画无法正常工作,无法提供视觉反馈。 Im guessing its due to fact that in order to repaint JTable you need to call the models fireTableDataChanged() method. 我猜测是由于事实,为了重新绘制JTable,您需要调用模型fireTableDataChanged()方法。

表格按钮列显示了另一种方法。

The example cited is less than satisfactory because TableCellRenderer shows a JButton , but the MouseListener ignores the button's ButtonModel . 引用示例并不令人满意,因为TableCellRenderer 显示JButton ,但是MouseListener忽略了按钮的ButtonModel Implementing TableCellEditor , as shown here , is a the better approach. 实现TableCellEditor ,如图所示这里 ,是一个更好的办法。 For animation convenience, you may want to look at the DefaultCellEditor , shown here , with a JComboBox having a single entry. 为了动画的方便,您可能希望查看此处显示的DefaultCellEditor ,其中JComboBox具有单个条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM