Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setFont of JTable Editor  RSS feed

 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to set the font of the editor as the same for the renderer of JTable. I am just a bit confused on how to do this. I don't want any code but maybe a walkthrough on what to do. Here is my abstract table model if it helps.....Thank You in advance

 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swing uses MVC design.

The "Model" is responsible for holding the data and notifying the "View" when the data changes. So the Model has nothing to do with the rendering or editing of the data.

The "View" is responsible for displaying the data. So the View will be responsible for the Font. In the case of a JTable it uses renderers to display the data and editors to edit the data.

The editor used by any given cell is determined by the value return from the getColumnClass(...) method. Unless you override this method, the Object class is used.

I believe, the renderer uses the Font of the table. So, to override the default Font of the default editor you should be able to do something like:


 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:Swing uses MVC design.

The "Model" is responsible for holding the data and notifying the "View" when the data changes. So the Model has nothing to do with the rendering or editing of the data.

The "View" is responsible for displaying the data. So the View will be responsible for the Font. In the case of a JTable it uses renderers to display the data and editors to edit the data.

The editor used by any given cell is determined by the value return from the getColumnClass(...) method. Unless you override this method, the Object class is used.

I believe, the renderer uses the Font of the table. So, to override the default Font of the default editor you should be able to do something like:




Thank You Rob with the detailed explanation....that does help a lot and makes a lot more sense....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!