• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

installing JComboBox in JTable

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know how to install the JComboBox in a JTable. However, it install the combobox in the whole column. What I need is to install it in a single cell and not entire column. Anybody can help ?
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

hai,
you can visit this site where you will find some examples
www.gol.com/users/tame/swing/examples.
if you know how to make a row not to be visible dynamically,but latter to be visible??? give me some tip on it.
silva.
 
David Gunawan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi selvas, are you sure about the url path ?
I got an error when tried to connect there......
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,
When you say that you want to "install" a JComboBox in a JTable, I assume you mean that you want to use a JComboBox as a renderer or as an editor for certain cells, but not for all cells in a given column or group of columns. Is that correct?
If so, the easiest way to do this is create a simple JTable subclass that will create an instance of the renderer or editor and return it only for the specific (cells) that you want it used for. For example, the following JTable subclass will only use "myEditor" for the cell in the sixth column of the fourth row:

In other words, it's the JTable's getCellEditor(int, int) method that determines which editor is used for a particular cell, and by overriding this method, you can control which specific cells an editor is used for. Of course, I just used the sixth column / fourth row check as a simple example of how this works, and you should replace it with code that makes sense for your application. However, hopefully this gives you an idea of how to get started doing that.
P.S. You can do essentially the same thing for renderers by overriding the getCellRenderer(int, int) method.
------------------
Brett Spell
Author, Professional Java Programming
 
David Gunawan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to Selvas: I think what you mean with the url is:http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
to Brett:
thank you very much. That is exactly what I am looking for. Short and simple yet elegant.
 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai,
you can look at this site where you will get some useful examples.. http://www2.gol.com/users/tame/swing/examples
around 9 examples are there.
regards,
silva.
 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai,
you can look at this site where you will get some useful examples.. http://www2.gol.com/users/tame/swing/examples
around 9 examples are there.
regards,
silva.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
the link is not working. Need help on adding a JCombobox inside a single cell in JTable.
 
Marshal
Posts: 80874
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rakesh nadig:
hi, the link is not working.

I'm not surprised; you have gone onto a 7 years old thread.

Welcome to the Ranch, but I suggest you delete your original post, using the pencil-and-paper icon, and check some old threads: here, here, here, here, here, here, and here. There are more. If you don't find what you are looking for in those links (there are older links available) you ought to start a new topic altogether.

I hope one of those links will be helpful. People like Brian Cole and Craig Wood have posted; one of Craig's posts gives lots of example code.

If you don't find what you need, ask again. People here are very helpful.

[edit]It is not usually a good idea to resurrect such an old thread. Better to start a new thread if you need new information.[/edit]
[ May 12, 2008: Message edited by: Campbell Ritchie ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic