The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 How to Write a Custom Swing Component
Subject:  Great Article
Date:  2007-02-23 06:57:23
From:  mattnathan


Great article, it took years to realise what you've summerised in a couple of pages, though I would make one suggestion. To follow the standard practices of Swing I would change:
[code]
public void updateUI() {
if (UIManager.get(getUIClassID()) != null) {
setUI((FlexiSliderUI) UIManager.getUI(this));
} else {
setUI(new BasicFlexiSliderUI());
}
}
[/code]
to
[code]
public void updateUI() {
if (UIManager.get(getUIClassID()) != null) {
setUI((FlexiSliderUI) UIManager.getUI(this));
} else {
setUI(BasicFlexiSliderUI.createUI(this));
}
}
[/code]
It doesn't really add much in this case but does follow the standard practices of the rest of swing and allows for singleton delegate creation.

 Feed java.net RSS Feeds