Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2004

Tip: Looking for answers? Try searching our database.

JTable selection issues

Thread view: 
Alexander Ames - 12 Sep 2004 16:23 GMT
I've been playing around with the JTable selection options and can't
seem to get what I want.

If I disable the showing of grid lines and set the selection to row
only, when I click on a cell within a row the whole row is selected,
but there is also a distinct outline around the individual cell,
darker than the normal selection colour. Is there any way to get rid
of this?

Is it possible to enable selection only for the cells within one
column but to disable it for all the other columns?
Babu Kalakrishnan - 13 Sep 2004 16:11 GMT
> I've been playing around with the JTable selection options and can't
> seem to get what I want.
[quoted text clipped - 4 lines]
> darker than the normal selection colour. Is there any way to get rid
> of this?

Use a custom renderer that does not paint the focus border. e.g.

TableCellRenderer nofocusRenderer = new DefaultTableCellRenderer()
{
    public Component getTableCellRendererComponent(JTable table,
                                               Object value,
                                               boolean isSelected,
                                               boolean hasFocus,
                                               int row,
                                               int column)

    {
        return super.getTableCellRendererComponent(table,
                        value,
                        isSelected,
                        false,
                        row,
                        column);
    }
}

> Is it possible to enable selection only for the cells within one
> column but to disable it for all the other columns?

If it is only for display purpose (i.e only one column to be shown with the
"selected" background/foreground), you could do it using a custom renderer.
(very similar to the above code : pass the "isSelected" parameter passed to the
super call only for the column for which you want the selection shown -
otherwise pass the value as "false"). Another option is to use a custom
ListSelectionModel to your tableColumnModel that allows selection of only one
column.

Note that if you use the renderer approach, the "column" parameter passed to you
is the column number in the view - not the model.

BK
Alexander Ames - 13 Sep 2004 23:04 GMT
>> I've been playing around with the JTable selection options and can't
>> seem to get what I want.
[quoted text clipped - 41 lines]
>
>BK

Thanks a lot!
K.H - 20 Oct 2004 10:26 GMT
Hi

I am a netbeans user. I have this problem.
I want through netbeans put a JSlider into a JTable cell.
I have read how to code it, but how do I do that through Netbeans?

I use netbeans 3.6 and 4.0 beta 2.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.