How to add a drop down menu to a JTable cell

18,906
  • use DefaultCellEditor with DefaultTableModel for JTable in the event that all the JComboBoxes will have identical values in the concrete TableColumn

  • if will have not identical values, then to use DefaultCellEditor for JComboBoxes with custom AbstractTableModel

Share:
18,906
Anubis
Author by

Anubis

Updated on June 03, 2022

Comments

  • Anubis
    Anubis about 2 years

    This may be a question asked before. I searched a lot before posting here, but couldn't figure out any acceptable one.

    Can some one show me a way how to do this. I simply need to get a drop down menu when i click on the cell so that I'll have to select a value from that (as a way to restrict the user selection).

    If some one can help with this I believe it will help a lot of people out there. There are a lots of questions similar to this but no any clear answer. Please answer with a bit more details. An example would be much appreciated..

    Thank you!

  • Anubis
    Anubis almost 12 years
    Thanks it works! much better. This is is a correct implementation i guess, isn't it... :p
  • MadProgrammer
    MadProgrammer almost 12 years
    @SumuduLanskara it's the preferred implementation