• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

copy selected data from JTable's cell to clipboard

 
Ranch Hand
Posts: 69
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a jtable that I would like to copy from a cell that I select to clipboard. How could I do these. Do you know some example?
Many thanks and sorry for my english!
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JTable supports copying selected cells to the clipboard out of the box. Try it for yourself - select something and press Ctrl-C. I believe that JTable uses the toString method on objects provided by its table model to obtain the text to put into clipboard (so with the standard objects like strings and numbers you don't need anything to do). Columns are separated by tabs and each row goes on separate line, obviously.
 
Marshal
Posts: 28174
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martin Vajsar wrote:JTable supports copying selected cells to the clipboard out of the box.



That's true -- and when I tried it on a JTable displayed from some of my code I found that Ctrl-C resulted in a whole row being selected. That's because row selection is the default for JTable. It's possible to configure a JTable so that individual cells are selected, but I didn't try doing that.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic