Are you a spammer

Please note, that the first 3 posts you make, will need to be approved by a forum Administrator or Moderator before they are publicly viewable.
Each application to join this forum is checked at the Stop Forum Spam website. If the email or IP address appears there when checked, you will not be allowed to join this forum.
If you get past this check and post spam on this forum, your posts will be immediately deleted and your account inactivated.You will then be banned and your IP will be submitted to your ISP, notifying them of your spamming. So your spam links will only be seen for an hour or two at most. In other words, don't waste your time and ours.

This forum is for the use and enjoyment of the members and visitors looking to learn about and share information regarding the topics listed. It is not a free-for-all advertising venue. Your time would be better spent pursuing legitimate avenues of promoting your websites.

Problem with rendering of cells in JTable in Netbeans

Source code I have written openly published for your viewing pleasure.


Problem with rendering of cells in JTable in Netbeans

Postby avalon18 » Tue Aug 02, 2011 3:44 am

Greetings to all members of this great project. It's amazing that evolution had this for so long.

I need your help and would be more than grateful if you could give me, first of all, sorry for my English, I translated it with google translator :P

I am doing a project in java netbeans, but I was stuck. :(

I have to load a list of records in a JTable, these records are obtained from 3 different searches and are inserted into the table through a model using DefaultTableModel, even here there are not any problems, but also need, the rows of records of the JTable to be painted. I know this is done via a subclass of TableCellRenderer or DefaultTableCellRenderer, but I could not make even rows or cells to be painted.

the conditions for adding color to the cells or rows are given by a control column added to the insertion of records is called "Tipo" or the code is implemented through filas2 [6], if 1 is paint it green, if it is 2 yellow and 3 red.

I have reviewed quite a few pages and all mentioned the creation of the DefaultTableCellRenderer class, and how to implement it with setDefaultRenderer, I have implemented both but I failed to change the background color.

I'm not sure if implemented poorly or not call the render, so I ask for help, if you could show me my mistake or could explain step by step how to implement this, I would be grateful with all my heart.

Annex class in which I am using the JTable and the render code.

caducidad.txt
this is the class of the jtable
(13.22 KiB) Downloaded 270 times
avalon18
U.E. Newbie
U.E. Newbie
 
Posts: 8
Joined: Sat Mar 26, 2011 1:52 am
Operating System: Ultimate Edition 3.0 Lite Gamers



Re: Problem with rendering of cells in JTable in Netbeans

Postby avalon18 » Sat Aug 06, 2011 9:01 pm

If anyone still wondering how to make what was previously mentioned, I simply dont find the way to do it from a JFrame, the custom renderer simply not load, no matter what I did.

The solution was to create an applet and load the table from him, and fill the table with the DefaultTableModel, then render, previously created, it automatically applies.

The problem with this is that according to information I found on the web is that this method uses appletviewer or a browser to load, and this is only found in newer versions of the Java platform.

I implement it through a JFrame that contained the applet and then calls the frame created to so use the applet as an application, remember that if implemented this way, you have to destroy the objects created within the applet when you close the window otherwise they will be splicing new objects created under the old.

If you have any questions, comments, recommendations or suggestions, please let me know that I will be happy to listen.
avalon18
U.E. Newbie
U.E. Newbie
 
Posts: 8
Joined: Sat Mar 26, 2011 1:52 am
Operating System: Ultimate Edition 3.0 Lite Gamers


Return to Programming

Who is online

Users browsing this forum: No registered users and 6 guests