-
Bug
-
Resolution: Fixed
-
P2
-
7
-
b84
-
generic
-
generic
There's an inconsistency between the specification of methods that is inherited and the behavior of the methods. Specification should be updated.
For example in class javax.swing.plaf.synth.SynthButtonUI method paint(Graphics g, JComponent c) is overridden and the spec is inherited:
* This method is invoked from the ComponentUI.update method when the specified component is being painted.
method update(Graphics g, JComponent c) is overridden as well and the spec is also inherited without any changes. In fact the overridden update method doesn't call paint(Graphics, JComponent), but calls paint(SynthContext, Graphics)
This should be clearly specified as for now behavior contradicts the spec.
Please see the following code sample:
-------------------------------------
import javax.swing.*;
import javax.swing.plaf.synth.*;
import java.awt.*;
public class PaintTest {
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
runTest();
}
});
}
private static void runTest() {
try {
UIManager.setLookAndFeel(new SynthLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
throw new RuntimeException(e);
}
JButton button = new JButton("A Button");
button.setUI(new SynthButtonUI() {
@Override
public void update(Graphics g, JComponent c) {
System.out.println("called update(Graphics g, JComponent c)");
super.update(g, c);
}
@Override
public void paint(Graphics g, JComponent c) {
System.out.println("called paint(Graphics g, JComponent c)");
super.paint(g, c);
}
@Override
protected void paint(SynthContext context, Graphics g) {
System.out.println("called paint(SynthContext context, Graphics g)");
super.paint(context, g);
}
});
JFrame jFrame = new JFrame();
jFrame.getContentPane().add(button);
jFrame.pack();
jFrame.setVisible(true);
}
}
-------------------------------------
"called paint(Graphics g, JComponent c)" will never be printed.
For example in class javax.swing.plaf.synth.SynthButtonUI method paint(Graphics g, JComponent c) is overridden and the spec is inherited:
* This method is invoked from the ComponentUI.update method when the specified component is being painted.
method update(Graphics g, JComponent c) is overridden as well and the spec is also inherited without any changes. In fact the overridden update method doesn't call paint(Graphics, JComponent), but calls paint(SynthContext, Graphics)
This should be clearly specified as for now behavior contradicts the spec.
Please see the following code sample:
-------------------------------------
import javax.swing.*;
import javax.swing.plaf.synth.*;
import java.awt.*;
public class PaintTest {
public static void main(String[] args) throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
runTest();
}
});
}
private static void runTest() {
try {
UIManager.setLookAndFeel(new SynthLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
throw new RuntimeException(e);
}
JButton button = new JButton("A Button");
button.setUI(new SynthButtonUI() {
@Override
public void update(Graphics g, JComponent c) {
System.out.println("called update(Graphics g, JComponent c)");
super.update(g, c);
}
@Override
public void paint(Graphics g, JComponent c) {
System.out.println("called paint(Graphics g, JComponent c)");
super.paint(g, c);
}
@Override
protected void paint(SynthContext context, Graphics g) {
System.out.println("called paint(SynthContext context, Graphics g)");
super.paint(context, g);
}
});
JFrame jFrame = new JFrame();
jFrame.getContentPane().add(button);
jFrame.pack();
jFrame.setVisible(true);
}
}
-------------------------------------
"called paint(Graphics g, JComponent c)" will never be printed.
- relates to
-
JDK-6827653 Make Synth UI classes public
- Resolved
-
JDK-6978052 No appropriate CCC request for listed JDK 7 changes in javax.swing.plaf.synth package (b84)
- Closed
-
JDK-6993140 protected constructor in javax.swing.plaf.synth.SynthTabbedPaneUI.SynthTabbedPaneUI is needed
- Closed