2

Is there anyone who know how to put JTable into JComboBox ? (just like date pickers)

I saw many questions of Put JComboBox into JTable. but I want Opposite.

I tried to change code of "put JComboBox into JTable" questions but I have no idea.

Thanks if anyone can help me.

Harsha
  • 377
  • 1
  • 8
  • 21
  • 2
    By adjusting the renderer, you can put any component into a `JComboBox`. See the [combobox tutorial](http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html#renderer). But not really sure that is what you want to achieve – Robin Oct 18 '14 at 16:56
  • 1
    Your're probably trying to achieve something which shouldn't be done this way. What are you trying to do? – user1803551 Oct 18 '14 at 17:37
  • 1
    There is no standard possibility to do what you want. JIDE extension provides [TableComboBox](http://www.jidesoft.com/javadoc/com/jidesoft/combobox/TableComboBox.html) but it's not a free lib. To do what you want by yourself you have two choices: either you provide a combobox cell renderer which looks like a table row or you simulate combobox using a (non editable) text field, button and popup. – Sergiy Medvynskyy Oct 18 '14 at 18:13
  • @user1803551 hi I got a solution and that's what I want. – Harsha Oct 21 '14 at 05:13

1 Answers1

2

Take a look at one approach here: DetailedComboBox

A typical use would be to show supporting information of a data class. For instance, suppose you have a State class, that has:

String fullName;
String abbreviation;
String capital;

You could use the DetailedComboBox to display the 2-digit abbreviation as a combo, but the drop-down would be a table of all of the data.

Community
  • 1
  • 1
splungebob
  • 5,357
  • 2
  • 22
  • 45