JCombobox custom Popup  
Author Message
Paolo Ferrari





PostPosted: 2004-4-27 22:24:00 Top

java-programmer, JCombobox custom Popup How can i make a Combo box (JComboBox) display a custom control as
popup. I want to show a Jtable instead of a JList.

Thanks.
Paolo.
 
Chris Smith





PostPosted: 2004-4-27 23:15:00 Top

java-programmer >> JCombobox custom Popup Paolo Ferrari wrote:
> How can i make a Combo box (JComboBox) display a custom control as
> popup. I want to show a Jtable instead of a JList.

You can't do that with a JComboBox. You can, of course, develop such a
component on your own.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
ak





PostPosted: 2004-4-28 4:46:00 Top

java-programmer >> JCombobox custom Popup > How can i make a Combo box (JComboBox) display a custom control as
> popup. I want to show a Jtable instead of a JList.
>
you can't show JTable, but you can easy show data from JTable. What you need
is your own ListCellRenderer.
See JComboBox#getRenderer() and JComboBox#setRenderer(ListCellRenderer lcr);


ListCellRenderer ist simple interface with only one method:

public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus);


You can just extend javax.swing.DefaultListCellRenderer.
or make your own.

____________

http://reader.imagero.com the best java image reader.