Solved

setCellRenderer

Posted on 2006-11-06
2
267 Views
Last Modified: 2011-09-20
Hi,

I have a superclass Maxi that setCellRender(RendererC) for it's List A (a JList). This is the RendererC is declared as a inner class for Maxi

I have extended this superclass Maxi to Class Mini, and wish to retain the functionality of List A, but I would like to change the renderering for List A for Class Mini, so I also declared an inner RendererC for Class Mini, and super.initComponents(), setCellRender for List A to RendererC of Class Mini. But List A continue to retain the outlook of the RendererC in Maxi...

Can I know why this is so, and how can I change it to respond to the class in Mini instead?

0
Comment
Question by:amai
2 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
After calling super.initComponents() change the cell renderer


list.setCellRenderer(rendererC);
0
 
LVL 92

Accepted Solution

by:
objects earned 70 total points
Comment Utility
> Can I know why this is so, and how can I change it to respond to the class in Mini instead?

because you are still creating an instance of Maxi's inner class.

add a createRenderer() method that creates your cell renderer and call that from initComponents().
then override createRenderer() in your subclass.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues undeā€¦
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now