File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do you format the a particular cell of a JTable to accept different datatypes ?!!

 
Meghna ks
Ranch Hand
Posts: 122
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, Here's my question. Typically, I've observed that a particular column of a JTable can be rendered and made to accept a particular data type or a combobox to show up or a textbox to show up etc. How do I get a particular column of a JTable to accept different data types and components . i.e for eg. the second column of a Table can have an Integer, a string , a boolean(checkbox must show up), a Date/Time(a combobox should show up) .. How can this be done ?!!
Thanks
Meghna
 
suri
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.javaworld.com/javaworld/javatips/jw-javatip102.html
this link may be helpful to you.
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Meghna, There are several examples of this in chapter 18 freely available here:
http://www.spindoczine.com/sbe
In particular I would take a look at the expense report example.
-Matt
------------------
Matthew Robinson
matt@mattrobinson.com
co-author of "Swing" (1999, Manning Publications). Freely available at http://www.spindoczine.com/sbe
 
Meghna ks
Ranch Hand
Posts: 122
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Matt
I did go through the expense report example and its very well explained. But, I've seen Tables having same type of data for a particular column , i.e 1st column - Date, 2nd column - Time,
3rd column - combobox and so on. What I was wondering was if it is possible to fit it multiple data types in a single column !!
For eg :
------------------------
First Column
------------------------
Date
Time
Checkbox(Boolean)
Combobox(List of Values)
IPAddress
-------------------------
Have you come across any examples of this type in JTables ?!! Please let me know if you come up with any ideas ?!!
Thanks
Meghna
 
Swamy Vatti
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this...
Sure u'll have a solution
http://eos.dk/archive/swing/frm05136.html
 
Matt Robinson
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way is to override your table's getCellRenderer and getCellEditor methods check the row and column and return the renderer or editor you'd like to use for that particular cell
------------------
Matthew Robinson co-author of "Swing" (1999, Manning Publications). Freely available at http://www.spindoczine.com/sbe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic