Skip to main content

2 Swing Questions

1 reply [Last post]
leouser
Offline
Joined: 2005-12-12
Points: 0

Hi here is the scenario:
1. THere is a JTable.
2. The JTable has a column that is a JComboBox.
3. The JComboBox(es) when Dropped shows a JTextArea

First Question:
To achieve the JComboBox in the column I had to get the TableColumn and set its repective Editors and Renderers. I tried to do this at start with JTable's 'setCellEditor' but this did nothing. Is there a purpose to 'setCellEditor'?

Second Question:
The JComboBox will show a vertical scroll bar when it has a certain amount of entries in it. I am interested in showing a horizontal bar. I cant see a way with the JComboBox to configure this. Is this possible? And if so what is the approach?

Thanks!
(In building this crazy thing, I thought that I could not do this in some Toolkits. If Tk had a table, I cant see myself being able to do all this magical swapping of renderers and editors. Swing, the flexibility is there when you need, thank you :) )

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
shan-man
Offline
Joined: 2006-02-17
Points: 0

Hi,

leouser wrote:
> Hi here is the scenario:
> 1. THere is a JTable.
> 2. The JTable has a column that is a JComboBox.
> 3. The JComboBox(es) when Dropped shows a JTextArea
>
> First Question:
> To achieve the JComboBox in the column I had to get
> the TableColumn and set its repective Editors and
> Renderers. I tried to do this at start with JTable's
> 'setCellEditor' but this did nothing. Is there a
> purpose to 'setCellEditor'?

JTable.setCellEditor() is mostly used internally by JTable to set the editor when you start editing a cell. What you need to do instead is either set the cell editor on the column, or use JTable.setDefaultEditor().

>
> Second Question:
> The JComboBox will show a vertical scroll bar when it
> has a certain amount of entries in it. I am
> interested in showing a horizontal bar. I cant see a
> way with the JComboBox to configure this. Is this
> possible? And if so what is the approach?

I'm sure it's possible, but unfortunately don't know what the approach is. Perhaps someone else that's done this can help you.

>
> Thanks!
> (In building this crazy thing, I thought that I could
> not do this in some Toolkits. If Tk had a table, I
> cant see myself being able to do all this magical
> swapping of renderers and editors. Swing, the
> flexibility is there when you need, thank you :) )

Thanks for the comments! :)

Shannon