Solved

Need one MultiColumnList component

Posted on 2004-10-21
296 Views
Last Modified: 2008-02-01
Hi,

I need one component similar to JList but with multicolumn.

JList is list with only one column.

Any body has any idea.

pavan.
0
Question by:pavan_k_goyal
    11 Comments
     
    LVL 92

    Expert Comment

    by:objects
    how about a JTable
    0
     

    Author Comment

    by:pavan_k_goyal
    No I don't want JTable....


    Any thing else ?

    Pavan

    0
     
    LVL 92

    Expert Comment

    by:objects
    use multiple JList's.
    0
     
    LVL 9

    Expert Comment

    by:Ovi
    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.
    0
     
    LVL 37

    Expert Comment

    by:zzynx
    >> No I don't want JTable....
    Any particular reason?
    0
     

    Author Comment

    by:pavan_k_goyal
    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
    0
     
    LVL 92

    Expert Comment

    by:objects
    maker your table model uneditable by having isCellEditable() return false.
    0
     

    Author Comment

    by:pavan_k_goyal
    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
    0
     
    LVL 92

    Expert Comment

    by:objects
    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.
    0
     

    Author Comment

    by:pavan_k_goyal
    I have to use this Table in many screens... and I can not hardcode blank numbers of rows.

    Any other solution ?

    Pavan.
    0
     
    LVL 92

    Accepted Solution

    by:
    No alternative that I can think of. The table only renders rows that exist in the model, if there are no rows then its not going to paint any.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Lean Six Sigma Project Manager Certification

    There are many schools of thought around successful project management, but few as highly regarded as the Six Sigma and Lean methods. With 37 hours of learning, this training will explain concrete processes for increasing efficiency and limiting wasted time and effort.

    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now