简体   繁体   中英

add jbutton over jtable

How can I add a jbutton over the cell area? 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. I tried to play with JLayeredPane but with no luck so far

http://imgur.com/V0c3jSD

All Swing components extend from Container , so you can add any component to the 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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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