Issue Details (XML | Word | Printable)

Key: SWINGX-1451
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: rah003
Reporter: zonski
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
swingx

Add common interface for base methods on SwingX Components

Created: 25/May/11 06:47 PM   Updated: 25/May/11 06:47 PM
Component/s: JXHeader, JXLabel, Misc Component
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Tags:
Participants: rah003 and zonski


 Description  « Hide

It would be nice if there was a common interface (or set of interfaces) for methods that are common to multiple SwingX components.

For example, the background painter and paint border insets method are common to most SwingX Components (it would be great if they were common to all). Also the foreground painter, and highlighter methods are common to a few components.

This could be in the form of a 'Has' interface, e.g. 'HasBackgroundPainter' or 'HasForegroundPainter', or it could be an aggregate interface (or set of interfaces) such as 'JXComponent' or 'JXTextComponent' with the common methods bundled into logical groups.

This would be useful to avoid stuff like the following (which occurs when you try to share a common background painter across multiple components in a general way - possibly not that common, but it's come up for me):

if (comp instanceof JXButton)
{
   ((JXButton)comp).setBackgroundPainter(p);
}
else if (comp instanceof JXLabel)
{
   ((JXLabel)comp).setBackgroundPainter(p);
}
else if (comp instanceof JXPanel)
{
   ((JXPanel)comp).setBackgroundPainter(p);
}
else ...

Instead we could do something like this:

if (comp instanceof HasBackgroundPainter)
{
   ((HasBackgroundPainter)comp).setBackgroundPainter(p);
}


There are no comments yet on this issue.