JComboBox #2

  • Follow


Can anyone point me to example code that allows me to have a
multi-column popup menu for a JComboBox.  For example I want to show
100 items in a 10 column 10 items per column scenario instead of a
single column.  Also I don't want to use a JTable for the component
that would popup when you hit the JComboBox button.

Thanks,

Jonathan
0
Reply jonathanm 6/7/2004 5:16:50 PM

> Can anyone point me to example code that allows me to have a
> multi-column popup menu for a JComboBox.  For example I want to show
> 100 items in a 10 column 10 items per column scenario instead of a
> single column.  Also I don't want to use a JTable for the component
> that would popup when you hit the JComboBox button.

you should implement custom ListCellRenderer.
Extend DefaultListCellRenderer and use JLabels to render columns.

-- 
http://uio.dev.java.net
http://reader.imagero.com


0
Reply ak 6/7/2004 6:04:09 PM


"ak" <spam@imagero.com> wrote in message news:<ca2amp$6qr$1@online.de>...
> > Can anyone point me to example code that allows me to have a
> > multi-column popup menu for a JComboBox.  For example I want to show
> > 100 items in a 10 column 10 items per column scenario instead of a
> > single column.  Also I don't want to use a JTable for the component
> > that would popup when you hit the JComboBox button.
> 
> you should implement custom ListCellRenderer.
> Extend DefaultListCellRenderer and use JLabels to render columns.

Thanks for the tip, but what about displaying the JLabels in a 10x10
view.  How can I tell the popup to display in a multi-column fashion
versus a single column?
0
Reply jonathanm 6/8/2004 6:46:39 PM

> > > Can anyone point me to example code that allows me to have a
> > > multi-column popup menu for a JComboBox.  For example I want to show
> > > 100 items in a 10 column 10 items per column scenario instead of a
> > > single column.  Also I don't want to use a JTable for the component
> > > that would popup when you hit the JComboBox button.
> >
> > you should implement custom ListCellRenderer.
> > Extend DefaultListCellRenderer and use JLabels to render columns.
>
> Thanks for the tip, but what about displaying the JLabels in a 10x10
> view.  How can I tell the popup to display in a multi-column fashion
> versus a single column?

ListCellRenderer has only one method:

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

you return one Container which should contain 10 children!
Values for children you should take from second argument (Object value).

-- 
http://uio.dev.java.net
http://reader.imagero.com


0
Reply ak 6/8/2004 6:57:49 PM

3 Replies
228 Views

(page loaded in 0.066 seconds)

Similiar Articles:













7/25/2012 7:25:06 PM


Reply: