[英]add jbutton over jtable
How can I add a jbutton over the cell area? 如何在单元格区域上方添加jbutton? this is the cleansheets app and I have to add a jbutton over the cell area( not inside of the cell) and I have no ideia how to do this. 这是cleansheets应用程序,我必须在单元格区域上方(而不是单元格内部)添加一个jbutton,我对此没有任何想法。 I tried to play with JLayeredPane but with no luck so far 我尝试过与JLayeredPane一起玩,但到目前为止还没有运气
All Swing components extend from Container
, so you can add any component to the JTable. 所有Swing组件都从Container
扩展而来,因此您可以将任何组件添加到JTable中。 The key is to set the bounds of the component. 关键是设置组件的边界。 Something like: 就像是:
Rectangle cell = table.getCellRect(....);
JButton button = new JButton(...);
button.setBounds( cell );
table.add( button );
table.repaint();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.