aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Need help in understanding Swing concepts: Renderers,Editors and Model Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Need help in understanding Swing concepts: Renderers,Editors and Model" Watch "Need help in understanding Swing concepts: Renderers,Editors and Model" New topic
Author

Need help in understanding Swing concepts: Renderers,Editors and Model

Prashant Langade
Ranch Hand

Joined: Jul 01, 2009
Posts: 73
Hi All

I am a newbie to Swing. However i need to understand the following concepts from swing.

Renderers,Editors and Model

I have already couple of times gone through the link from oracle. http://docs.oracle.com/javase/tutorial/uiswing/components/table.html

But i am finding it bit difficult to understand it programatically(how the things work).

Can any one help me with any other links/pdf's which are simple to understand for these three concepts?

Thanks
Prashant
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Consider a JTable. It is the "View" component and as such is not aware of any data. It totally relies on the underlying TableModel for the data. Whenever it needs to display any data, it will ask the model internally using the TableModel#getValueAt(int row, int column) Notice this method returns an Object and as such is "raw" data. The table then needs to figure out how to display (or render) it. For this it internally uses the TableModel#getColumnClass()
Now the table has the raw data as well as its class. Then the table will try and decide how to display it using these two values. The default JTable has some built in renderers (e.g. Boolean.class returned from getColumnClass will be rendered as a JCheckBox)
In addition to this, you can provide your own renderers (e.g. if getColumnClass() returns Color.class then the renderer will be a JLabel, colored in that particular color)
If no renderers are found (built in + your custom) then the table will default to plain text (using the value getValueAt().toString()).

Of course this is an over simplified conceptual explanation. If you got any further specific questions, do feel free to ask!


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2226
    
    8
But i am finding it bit difficult to understand it programatically(how the things work).


Then ask a specific question about what you find confusing. We are not mind readers. We can't guess what you find confusing.

The tutorial includes working examples that you can download and play with. What part of the code do you not understand? If we know that then maybe we can answer your question.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help in understanding Swing concepts: Renderers,Editors and Model