Link to home
Start Free TrialLog in
Avatar of pavan_k_goyal
pavan_k_goyal

asked on

Need one MultiColumnList component

Hi,

I need one component similar to JList but with multicolumn.

JList is list with only one column.

Any body has any idea.

pavan.
Avatar of Mick Barry
Mick Barry
Flag of Australia image

how about a JTable
Avatar of pavan_k_goyal
pavan_k_goyal

ASKER

No I don't want JTable....


Any thing else ?

Pavan

use multiple JList's.
If you are using JDK 1.4 and above, this feature is allready implemented. You can use'it like this:

JList list = new JList();
list.setLayoutOrientation(JList.VERTICAL_WRAP);
list.setFixedCellWidth(300);

This piece of code will create a list and wrap the data inside in multiple columns.
>> No I don't want JTable....
Any particular reason?
Ok. If I use JTable and set following selection mode

table.setRowSelectionAllowed(true);
and I click on one row in table, it select entire row but it keeps unselected the cell column under
the mouse pointer. and If I double click the mouse, Ican  change the content of cell , that I don't want.

How to prevent this ???


Pavan
maker your table model uneditable by having isCellEditable() return false.
Thanks, that worked fine.
Here I've some more problems.

JTable is drawing only as many lines as no of records(I'm passing at then time of table creation).
I have screen that has got one button and one text box and one Table.
Initially when I open that screen, I don't have any data to add to table.
User is supposed to enter some text in text box and click button... java program will fetch the data from database and retried data needs to be populated in Table.

I  want following things.

1. When I open the screen, (since I don't have any data) JTable should display blank lines.
2. I should be able to populate data n JTable Dyanamically based on the query results.
3. Currently Foreground colour for text in JTable is black. When I select a record, it's color should change to white(beacuse I need selec tion color to be black).


Pavan
Fill your table with empty rows, and when populating instead of adding new rows fill in the empty ones.
Use table.setSelectionForeground(Color.white) to change the selected foreground colour.
I have to use this Table in many screens... and I can not hardcode blank numbers of rows.

Any other solution ?

Pavan.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial