Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2966

Re: Using JComboBox as a

From "lisaspamster" <lisaspamster@THRWHITE.remove-dii-this>
Subject Re: Using JComboBox as a
Message-ID <17934ffb-7880-4e1d-940a-cc20d6aada07@e23g2000prf.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
References <Xns9A0391360923Cndt601946x@61.9.191.5>
Date 2011-04-27 15:42 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
On Dec 10 2007, 10:16 pm, Tom N <t...@tom.n> wrote:
> I have working combo boxes in a table.  My code looks like yours but I
> don't set the cell renderer.
>
> If you omit setting the cell renderer it will work.  The cell will look
> like a string except when you are editing it.  Nothing wrong with that.  
> You have to click in the cell to see that it is a drop down list.
>
> I thought it would be interesting to see if your cell editor is ever
> invoked.  I added your code for MyComboBoxRenderer with an added action
> listener, plus an action listener on the combo box used as a cell editor.  
> I found that when you change the value using the mouse, the cell editor
> combo box action listener is invoked once but the cell renderer combo box
> action listener is invoked multiple times.
>
> I found that when you change the value using the mouse, all the other rows
> that have not been set with the mouse change also.  All the other rows that
> have been set at least once with the mouse behave as desired.  Once all
> rows have been set with the mouse, it works as desired.  You could possibly
> exploit this to get the behaviour you want but it would be a hack and would
> probably break in the future.
>
> I have some suggestions.
>
> 1. don't set the cell renderer.
>
> 2. render the cell to look like a combo box but not actually *be* a combo
> box (using the default renderer which is a JLabel iirc).
>
> 3. make the rendering combo box uneditable.  Might work.  Perhaps you could
> change the rendering combo box to all ignore all mouse clicks or reroute
> them to editing combo box.
>
> I tried the following without success (but they might be made to work).
> a. overriding validate, revalidate, repaint, and firePropertyChange (as
> DefaultTableCellRenderer does) in the rendering combo box to be no-ops (see
> javadoc for DefaultTableCellRenderer).
>
> b. make the renderer to be a DefaultTableCellRenderer and override paint to
> call paint on a combo box.

I have the same problem.  I took out the renderer and it works as
desired.  However I would like to implement you option #2.  My user
needs to know that there is an option there.  How would I go about
making the cell look like a comboBox but not be a comboBox?  Thanks
for the help.

~Clark

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Using JComboBoxes in a JT "marcussilfver" <marcussilfver@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000
  Re: Using JComboBoxes in "RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000
  Re: Using JComboBox as a "Tom N" <tom.n@THRWHITE.remove-dii-this> - 2011-04-27 15:41 +0000
    Re: Using JComboBox as a "lisaspamster" <lisaspamster@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000
      Re: Using JComboBox as a "Tom N" <tom.n@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000

csiph-web