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 / General / January 2006

Tip: Looking for answers? Try searching our database.

jtable, jtextboxrenderer's grey border...

Thread view: 
tiewknvc9 - 04 Jan 2006 19:43 GMT
Hi!

I have created a cellrenderer for my jtable that obviously renders a
jtextbox in the cell.

The issue I am having is that it has a dark grey border around those
cells now.  This is likely due to the fact that jtextbox has a border,
and this is... acceptable, if required.  However when the user is
tabbing through the table, they cannot tell which cell they are on!

So my question is what can I do either get rid of this extra grey box,
or at least make it more clear that the user has tabbed onto that cell.

Thanks
zero - 04 Jan 2006 19:57 GMT
"tiewknvc9" <aotemp@hotmail.com> wrote in news:1136403815.801650.293660
@z14g2000cwz.googlegroups.com:

> Hi!
>
[quoted text clipped - 10 lines]
>
> Thanks

There is no JTextBox class in the standard Java API.  Do you mean
JTextField?

I'm a little puzzled on why you want to use a JTextBox as renderer.  The
purpose of JTextBox is to *edit* data.  If you only want to show it, JLabel
is the way to go - and this is btw the default cell renderer(1).  Using
JTextBox as cell editor makes more sense.

JComponent has a setBorder method which may help.  But without seeing code
I can't be sure.  Posting a short, complete(2) example may help.

(1) to be correct, it's a subclass of JLabel
(2) meaning it has all the classes needed to compile.  See
http://mindprod.com/jgloss/sscce.html

Signature

Beware the False Authority Syndrome

tiewknvc9 - 04 Jan 2006 20:29 GMT
ok, I changed the renderer to extend jlabel instead or jtextfield.
This did work for setting the default value as well as getting rid of
the terrible grey box issue.

However, now the cells with the jlabel no longer are highlighted...  I
would like to be able to keep a highlighted row to show which row the
user is working with, as well as alternate row colors.

would the jlabel renderer allow me to do this?  ANy idea on the method
to use?

Thanks again
Chris Smith - 04 Jan 2006 20:57 GMT
> ok, I changed the renderer to extend jlabel instead or jtextfield.
> This did work for setting the default value as well as getting rid of
[quoted text clipped - 3 lines]
> would like to be able to keep a highlighted row to show which row the
> user is working with, as well as alternate row colors.

I get the feeling you're making things more difficult than needed.  
DefaultTableCellRenderer already extends JLabel.  Just subclass it, and
override getTableCellRendererComponent to first call the superclass, and
then make your changes.  Then if you don't want to override the color of
a selected component, just don't change the color when isSelected is
false.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

tiewknvc9 - 04 Jan 2006 21:07 GMT
thanks worked like a charm!


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.