• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rendering  RSS feed

 
Shashidhar Yarabati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody.

Can any body clear cut idea about rendering in swings. What is the purpose inside applications? How should we use that? when should we use that?

Please, if you know any resources also please let me know

Thanks in Advance
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rendering refers to the process of creating a 2D bitmapped image of a graphic scene that's described in terms of objects. E.g., if you have a number of Swing components, then the process of creating a 2D presentation of them that can be shown on a screen might be referred to as rendering. Or the process of creating an image from a 3D scene via raytracing is a form of rendering.
 
Shashidhar Yarabati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to be it is not related to Swings?
Iam thinking about Cell rendering in JTable. What does it mean(Cell Rendering in JTable). Why should we require. How to implement that?
Any resources on that?
Please help me to learn on this?

Thanks in advance
 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rendering in JTables (and JTrees, JLists and JComboBoxes as well) is done through Renderers (TableCellRenderer, TreeCellRenderer, ListCellRenderer). All these interfaces have a default implementation called Default<InterfaceName>.

You must assign these renderers to the control. JTrees, JLists and JComboBoxes have simple getter and setter methods.

JTables work a little differently. First of all, you can explicitly set a renderer for a TableColumn.
However, you can also specify it for a complete set of classes. JTable has methods called getDefaultRenderer and setDefaultRenderer, where you give a TableCellRenderer and a class. When painting the table, it will call the TableModel's getColumnClass method to determine the class of the column. It will then use best matching to find the renderer. Let's say the class is Integer, it will look for Integer first. If it can't find a renderer for that class, it will look for Number next, and finally Object. This works on classes only, not interfaces, so setting the default renderer for let's say a Serializable or Cloneable will make no sense.

Explicit renderers overwrite this behaviour though.
 
Shashidhar Yarabati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any tutorial on this in online. Iam searching in google. But i didn't got.
Please let me know if any?

Thanks for your prompt reply
Shashi
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know that there's a 'one tutorial fits all'

this might be a good place to start
http://java.sun.com/docs/books/tutorial/uiswing/TOC.html

if you click on many of the 'How to use....' links, when the page loads there
is generally another link 'Providing a Custom Renderer', which is specific to that component
 
Shashidhar Yarabati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again!

I got some Idea regarding this. Now what i want I want to implement Tree structure inside JTable.
For that what should I do I need to render TableColumn or Table Row.

Please help me if any body knows

Thanks in advance
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!