-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0, 6
-
b72
-
generic, sparc
-
generic, solaris_2.6
Name: mgC56079 Date: 11/10/99
Documentation for javax.swing.plaf.basic.BasicArrowButton.getMinimumSize() should be updated to meet the implementation.
Current documentation states:
-------------------------------------------------------
public Dimension getMinimumSize()
Description copied from class: JComponent
If the minimum size has been set to a non-null value just returns it. If the UI delegate's
getMinimumSize() method returns a non-null value then return that; otherwise defer to the
component's layout manager.
Overrides:
getMinimumSize in class JComponent
Following copied from class: javax.swing.JComponent
Returns:
the value of the minimumSize property
-------------------------------------------------------
Source code :
-------------------------------------------------------
public Dimension getMinimumSize() {
return new Dimension(5, 5);
}
-------------------------------------------------------
Documentation for javax.swing.plaf.basic.BasicArrowButton.getMaximumSize() should be updated to meet the implementation.
Current documentation states:
-------------------------------------------------------
public Dimension getMaximumSize()
Description copied from class: JComponent
If the maximum size has been set to a non-null value just returns it. If the UI delegate's
getMaximumSize() method returns a non null value then return that; otherwise defer to the
component's layout manager.
Overrides:
getMaximumSize in class JComponent
Following copied from class: javax.swing.JComponent
Returns:
the value of the maximumSize property.
-------------------------------------------------------
Source code :
-------------------------------------------------------
public Dimension getMaximumSize() {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
-------------------------------------------------------
Documentation for javax.swing.plaf.basic.BasicArrowButton.getPreferredSize() should be updated to meet the implementation.
Current documentation states:
-------------------------------------------------------
public Dimension getPreferredSize()
Description copied from class: JComponent
If the preferredSize has been set to a non-null value just returns it. If the UI delegate's
getPreferredSize() method returns a non null value then return that; otherwise defer to the
component's layout manager.
Overrides:
getPreferredSize in class JComponent
Following copied from class: javax.swing.JComponent
Returns:
the value of the preferredSize property
-------------------------------------------------------
Source code :
-------------------------------------------------------
public Dimension getPreferredSize() {
return new Dimension(16, 16);
}
-------------------------------------------------------
Documentation for javax.swing.plaf.basic.BasicArrowButton.isFocusTraversable() should be updated to meet the implementation.
Current documentation states:
-------------------------------------------------------
public boolean isFocusTraversable()
Description copied from class: AbstractButton
Identifies whether or not this component can receive the focus.
Overrides:
isFocusTraversable in class AbstractButton
Following copied from class: javax.swing.AbstractButton
Returns:
true if this component can receive the focus
-------------------------------------------------------
Source code :
-------------------------------------------------------
public boolean isFocusTraversable() {
return false;
}
-------------------------------------------------------
======================================================================
Suggested fix from java.net member leouser:
A DESCRIPTION OF THE FIX :
BUGID: 4289842
FILES AFFECTED: java.swing.plaf.basic.BasicArrowButton
JDK: jdk-6-rc-bin-b64-linux-i586-15_dec_2005.bin
Discussion(embeded in test case comments):
/**
* BUGID: 4289842 the doc for javax.swing.plaf.basic.BasicArrowButton should be updated.
* The javadoc for BasicArrowButton is clearly incorrect when compared to the
* source code. I have correspondingly altered the javadoc to indicate that
* they do return constants in a sense. This report was issued in 1999, 7 years
* ago. The code has not changed in this time, it appears to be cemented in place.
* Because of this I have chosen to put in javadoc the Dimension the user
* should expect from calling the various getSize methods. I have contemplated
* making them constants in the BasicArrowButton interface, but Dimension
* does exposes its internals to public view making it simple for any attacker
* to alter their value at runtime. Therfore there is not a good way to do
* a final Dimension. I would have done that instead of explicitly stating
* in the javadoc what it returns. I could have stated: returns the value
* of the MAXSIZE constant. Since that isn't viable we fall back to this.
*
* ANTI-RATIONALE: there isn't one. Wrong javadoc is bad, very bad. Must be
* fixed.
*
* TESTING STRATEGY: prove via method calls that the getters are returning
* their expected "constant" values.
*
* A NOTE ON WARNINGS: this class tossed a couple of warnings when compiling.
* One is the serialVersionID. I find myself wondering if setting this is
* a bad idea. It states in many if not all Swing javadocs that these classes
* are not going to be compatible with future releases. What the heck does that
* mean? Is it talking just about serialization support? If it is, I can't
* see implementing this field as breaking that statement.
*
* FURTHER THOUGHTS: maybe looking at the rest of the plaf.basic classes
* would be a good idea. Its possible that their javadoc may be as bad as
* this classes was.
*
* JDK VERSION:
* jdk-6-rc-bin-b64-linux-i586-15_dec_2005.bin
*
* FILE AFFECTED: javax.swing.plaf.basic.BasicArrowButton.
* test ran succesfully on a SUSE 7.3 Linux distribution
*
* Brian Harry
* ###@###.###
* Thu Jan 11, 2006
*
*/
UNIFIED DIFF:
--- /home/nstuff/java6/jdk1.6.0/javax/swing/plaf/basic/BasicArrowButton.java Thu Dec 15 02:17:42 2005
+++ /home/javarefs/javax/swing/plaf/basic/BasicArrowButton.java Wed Jan 11 15:53:07 2006
@@ -30,6 +30,7 @@
*/
public class BasicArrowButton extends JButton implements SwingConstants
{
+ static final long serialVersionUID = -7886072972145880601L;
protected int direction;
private Color shadow;
@@ -51,11 +52,29 @@
this(direction, UIManager.getColor("control"), UIManager.getColor("controlShadow"),
UIManager.getColor("controlDkShadow"), UIManager.getColor("controlLtHighlight"));
}
-
+
+ /**
+ * This method returns the direction property.
+ *
+ * @return int the direction property.
+ * @see #setDirection
+ */
public int getDirection() { return direction; }
-
+
+ /**
+ * This method takes one of four values:
+ * SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST
+ * or SwingConstants.WEST. A side effect of setting this value
+ * is that the Arrow is drawn in the direction indicated by
+ * the dir parameter.
+ *
+ * @param dir an int that is equal to one of four values all
+ * taken from the SwingConstants interface:
+ * NORTH, SOUTH, EAST or WEST.
+ */
public void setDirection(int dir) { direction = dir; }
+ @Override
public void paint(Graphics g) {
Color origColor;
boolean isPressed, isEnabled;
@@ -117,22 +136,66 @@
g.setColor(origColor);
}
-
+ /**
+ * This method returns a Dimension whose value is equal
+ * to the Dimension constructed by this call:
+ * new Dimension(16,16);
+ *
+ * @return Dimension a Dimension which has a width
+ * and height == to 16.
+ */
+ @Override
public Dimension getPreferredSize() {
return new Dimension(16, 16);
}
-
+ /**
+ * This method returns a Dimension whose value is equal
+ * to the Dimension constructed by this call:
+ * new Dimension(5,5);
+ *
+ * @return Dimension a Dimension which has a width
+ * and height == to 5.
+ */
+ @Override
public Dimension getMinimumSize() {
return new Dimension(5, 5);
}
-
+
+ /**
+ * This method returns a Dimension whose value is equal
+ * to the Dimension constructed by this call:
+ * new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)
+ *
+ * @return Dimension a Dimension which has a width
+ * and height == to Integer.MAX_VALUE.
+ */
+ @Override
public Dimension getMaximumSize() {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
-
+
+ /**
+ * BasicArrowButton is not focusable, hence this
+ * method will always return false.
+ *
+ * @return boolean this value is always false.
+ */
+ @Deprecated
+ @Override
public boolean isFocusTraversable() {
- return false;
+ return false;
}
+
+ /**
+ * BasicArrowButton is not focusable, hence this
+ * method will always return false.
+ *
+ * @return boolean this value is always false.
+ */
+ @Override
+ public boolean isFocusable(){
+ return false;
+ }
public void paintTriangle(Graphics g, int x, int y, int size,
int direction, boolean isEnabled) {
JUnit TESTCASE :
import junit.framework.TestCase;
import junit.textui.TestRunner;
import static java.lang.System.out;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.*;
import java.awt.Dimension;
/**
* BUGID: 4289842 the doc for javax.swing.plaf.basic.BasicArrowButton should be updated.
* The javadoc for BasicArrowButton is clearly incorrect when compared to the
* source code. I have correspondingly altered the javadoc to indicate that
* they do return constants in a sense. This report was issued in 1999, 7 years
* ago. The code has not changed in this time, it appears to be cemented in place.
* Because of this I have chosen to put in javadoc the Dimension the user
* should expect from calling the various getSize methods. I have contemplated
* making them constants in the BasicArrowButton interface, but Dimension
* does exposes its internals to public view making it simple for any attacker
* to alter their value at runtime. Therfore there is not a good way to do
* a final Dimension. I would have done that instead of explicitly stating
* in the javadoc what it returns. I could have stated: returns the value
* of the MAXSIZE constant. Since that isn't viable we fall back to this.
*
* ANTI-RATIONALE: there isn't one. Wrong javadoc is bad, very bad. Must be
* fixed.
*
* TESTING STRATEGY: prove via method calls that the getters are returning
* their expected "constant" values.
*
* A NOTE ON WARNINGS: this class tossed a couple of warnings when compiling.
* One is the serialVersionID. I find myself wondering if setting this is
* a bad idea. It states in many if not all Swing javadocs that these classes
* are not going to be compatible with future releases. What the heck does that
* mean? Is it talking just about serialization support? If it is, I can't
* see implementing this field as breaking that statement.
*
* FURTHER THOUGHTS: maybe looking at the rest of the plaf.basic classes
* would be a good idea. Its possible that their javadoc may be as bad as
* this classes was.
*
* JDK VERSION:
* jdk-6-rc-bin-b64-linux-i586-15_dec_2005.bin
*
* FILE AFFECTED: javax.swing.plaf.basic.BasicArrowButton.
* test ran succesfully on a SUSE 7.3 Linux distribution
*
* Brian Harry
* ###@###.###
* Thu Jan 11, 2006
*
*/
public class TestBArrow extends TestCase{
public TestBArrow(String method){
super(method);
}
public void testBArrow(){
out.println();
out.println("Testing getters... and isers... :D");
BasicArrowButton bab = new BasicArrowButton(SwingConstants.NORTH);
assertEquals(bab.isFocusable(), false);
assertEquals(new Dimension(5,5), bab.getMinimumSize());
assertEquals(new Dimension(16,16), bab.getPreferredSize());
assertEquals(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE),
bab.getMaximumSize());
assertEquals(SwingConstants.NORTH, bab.getDirection());
out.println("passed 5 asserts... things look good...");
}
public static void main(String ... args){
TestCase tc = new TestBArrow("testBArrow");
TestRunner.run(tc);
}
}
FIX FOR BUG NUMBER:
4289842
Documentation for javax.swing.plaf.basic.BasicArrowButton.getMinimumSize() should be updated to meet the implementation.
Current documentation states:
-------------------------------------------------------
public Dimension getMinimumSize()
Description copied from class: JComponent
If the minimum size has been set to a non-null value just returns it. If the UI delegate's
getMinimumSize() method returns a non-null value then return that; otherwise defer to the
component's layout manager.
Overrides:
getMinimumSize in class JComponent
Following copied from class: javax.swing.JComponent
Returns:
the value of the minimumSize property
-------------------------------------------------------
Source code :
-------------------------------------------------------
public Dimension getMinimumSize() {
return new Dimension(5, 5);
}
-------------------------------------------------------
Documentation for javax.swing.plaf.basic.BasicArrowButton.getMaximumSize() should be updated to meet the implementation.
Current documentation states:
-------------------------------------------------------
public Dimension getMaximumSize()
Description copied from class: JComponent
If the maximum size has been set to a non-null value just returns it. If the UI delegate's
getMaximumSize() method returns a non null value then return that; otherwise defer to the
component's layout manager.
Overrides:
getMaximumSize in class JComponent
Following copied from class: javax.swing.JComponent
Returns:
the value of the maximumSize property.
-------------------------------------------------------
Source code :
-------------------------------------------------------
public Dimension getMaximumSize() {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
-------------------------------------------------------
Documentation for javax.swing.plaf.basic.BasicArrowButton.getPreferredSize() should be updated to meet the implementation.
Current documentation states:
-------------------------------------------------------
public Dimension getPreferredSize()
Description copied from class: JComponent
If the preferredSize has been set to a non-null value just returns it. If the UI delegate's
getPreferredSize() method returns a non null value then return that; otherwise defer to the
component's layout manager.
Overrides:
getPreferredSize in class JComponent
Following copied from class: javax.swing.JComponent
Returns:
the value of the preferredSize property
-------------------------------------------------------
Source code :
-------------------------------------------------------
public Dimension getPreferredSize() {
return new Dimension(16, 16);
}
-------------------------------------------------------
Documentation for javax.swing.plaf.basic.BasicArrowButton.isFocusTraversable() should be updated to meet the implementation.
Current documentation states:
-------------------------------------------------------
public boolean isFocusTraversable()
Description copied from class: AbstractButton
Identifies whether or not this component can receive the focus.
Overrides:
isFocusTraversable in class AbstractButton
Following copied from class: javax.swing.AbstractButton
Returns:
true if this component can receive the focus
-------------------------------------------------------
Source code :
-------------------------------------------------------
public boolean isFocusTraversable() {
return false;
}
-------------------------------------------------------
======================================================================
Suggested fix from java.net member leouser:
A DESCRIPTION OF THE FIX :
BUGID: 4289842
FILES AFFECTED: java.swing.plaf.basic.BasicArrowButton
JDK: jdk-6-rc-bin-b64-linux-i586-15_dec_2005.bin
Discussion(embeded in test case comments):
/**
* BUGID: 4289842 the doc for javax.swing.plaf.basic.BasicArrowButton should be updated.
* The javadoc for BasicArrowButton is clearly incorrect when compared to the
* source code. I have correspondingly altered the javadoc to indicate that
* they do return constants in a sense. This report was issued in 1999, 7 years
* ago. The code has not changed in this time, it appears to be cemented in place.
* Because of this I have chosen to put in javadoc the Dimension the user
* should expect from calling the various getSize methods. I have contemplated
* making them constants in the BasicArrowButton interface, but Dimension
* does exposes its internals to public view making it simple for any attacker
* to alter their value at runtime. Therfore there is not a good way to do
* a final Dimension. I would have done that instead of explicitly stating
* in the javadoc what it returns. I could have stated: returns the value
* of the MAXSIZE constant. Since that isn't viable we fall back to this.
*
* ANTI-RATIONALE: there isn't one. Wrong javadoc is bad, very bad. Must be
* fixed.
*
* TESTING STRATEGY: prove via method calls that the getters are returning
* their expected "constant" values.
*
* A NOTE ON WARNINGS: this class tossed a couple of warnings when compiling.
* One is the serialVersionID. I find myself wondering if setting this is
* a bad idea. It states in many if not all Swing javadocs that these classes
* are not going to be compatible with future releases. What the heck does that
* mean? Is it talking just about serialization support? If it is, I can't
* see implementing this field as breaking that statement.
*
* FURTHER THOUGHTS: maybe looking at the rest of the plaf.basic classes
* would be a good idea. Its possible that their javadoc may be as bad as
* this classes was.
*
* JDK VERSION:
* jdk-6-rc-bin-b64-linux-i586-15_dec_2005.bin
*
* FILE AFFECTED: javax.swing.plaf.basic.BasicArrowButton.
* test ran succesfully on a SUSE 7.3 Linux distribution
*
* Brian Harry
* ###@###.###
* Thu Jan 11, 2006
*
*/
UNIFIED DIFF:
--- /home/nstuff/java6/jdk1.6.0/javax/swing/plaf/basic/BasicArrowButton.java Thu Dec 15 02:17:42 2005
+++ /home/javarefs/javax/swing/plaf/basic/BasicArrowButton.java Wed Jan 11 15:53:07 2006
@@ -30,6 +30,7 @@
*/
public class BasicArrowButton extends JButton implements SwingConstants
{
+ static final long serialVersionUID = -7886072972145880601L;
protected int direction;
private Color shadow;
@@ -51,11 +52,29 @@
this(direction, UIManager.getColor("control"), UIManager.getColor("controlShadow"),
UIManager.getColor("controlDkShadow"), UIManager.getColor("controlLtHighlight"));
}
-
+
+ /**
+ * This method returns the direction property.
+ *
+ * @return int the direction property.
+ * @see #setDirection
+ */
public int getDirection() { return direction; }
-
+
+ /**
+ * This method takes one of four values:
+ * SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST
+ * or SwingConstants.WEST. A side effect of setting this value
+ * is that the Arrow is drawn in the direction indicated by
+ * the dir parameter.
+ *
+ * @param dir an int that is equal to one of four values all
+ * taken from the SwingConstants interface:
+ * NORTH, SOUTH, EAST or WEST.
+ */
public void setDirection(int dir) { direction = dir; }
+ @Override
public void paint(Graphics g) {
Color origColor;
boolean isPressed, isEnabled;
@@ -117,22 +136,66 @@
g.setColor(origColor);
}
-
+ /**
+ * This method returns a Dimension whose value is equal
+ * to the Dimension constructed by this call:
+ * new Dimension(16,16);
+ *
+ * @return Dimension a Dimension which has a width
+ * and height == to 16.
+ */
+ @Override
public Dimension getPreferredSize() {
return new Dimension(16, 16);
}
-
+ /**
+ * This method returns a Dimension whose value is equal
+ * to the Dimension constructed by this call:
+ * new Dimension(5,5);
+ *
+ * @return Dimension a Dimension which has a width
+ * and height == to 5.
+ */
+ @Override
public Dimension getMinimumSize() {
return new Dimension(5, 5);
}
-
+
+ /**
+ * This method returns a Dimension whose value is equal
+ * to the Dimension constructed by this call:
+ * new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)
+ *
+ * @return Dimension a Dimension which has a width
+ * and height == to Integer.MAX_VALUE.
+ */
+ @Override
public Dimension getMaximumSize() {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
-
+
+ /**
+ * BasicArrowButton is not focusable, hence this
+ * method will always return false.
+ *
+ * @return boolean this value is always false.
+ */
+ @Deprecated
+ @Override
public boolean isFocusTraversable() {
- return false;
+ return false;
}
+
+ /**
+ * BasicArrowButton is not focusable, hence this
+ * method will always return false.
+ *
+ * @return boolean this value is always false.
+ */
+ @Override
+ public boolean isFocusable(){
+ return false;
+ }
public void paintTriangle(Graphics g, int x, int y, int size,
int direction, boolean isEnabled) {
JUnit TESTCASE :
import junit.framework.TestCase;
import junit.textui.TestRunner;
import static java.lang.System.out;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.*;
import java.awt.Dimension;
/**
* BUGID: 4289842 the doc for javax.swing.plaf.basic.BasicArrowButton should be updated.
* The javadoc for BasicArrowButton is clearly incorrect when compared to the
* source code. I have correspondingly altered the javadoc to indicate that
* they do return constants in a sense. This report was issued in 1999, 7 years
* ago. The code has not changed in this time, it appears to be cemented in place.
* Because of this I have chosen to put in javadoc the Dimension the user
* should expect from calling the various getSize methods. I have contemplated
* making them constants in the BasicArrowButton interface, but Dimension
* does exposes its internals to public view making it simple for any attacker
* to alter their value at runtime. Therfore there is not a good way to do
* a final Dimension. I would have done that instead of explicitly stating
* in the javadoc what it returns. I could have stated: returns the value
* of the MAXSIZE constant. Since that isn't viable we fall back to this.
*
* ANTI-RATIONALE: there isn't one. Wrong javadoc is bad, very bad. Must be
* fixed.
*
* TESTING STRATEGY: prove via method calls that the getters are returning
* their expected "constant" values.
*
* A NOTE ON WARNINGS: this class tossed a couple of warnings when compiling.
* One is the serialVersionID. I find myself wondering if setting this is
* a bad idea. It states in many if not all Swing javadocs that these classes
* are not going to be compatible with future releases. What the heck does that
* mean? Is it talking just about serialization support? If it is, I can't
* see implementing this field as breaking that statement.
*
* FURTHER THOUGHTS: maybe looking at the rest of the plaf.basic classes
* would be a good idea. Its possible that their javadoc may be as bad as
* this classes was.
*
* JDK VERSION:
* jdk-6-rc-bin-b64-linux-i586-15_dec_2005.bin
*
* FILE AFFECTED: javax.swing.plaf.basic.BasicArrowButton.
* test ran succesfully on a SUSE 7.3 Linux distribution
*
* Brian Harry
* ###@###.###
* Thu Jan 11, 2006
*
*/
public class TestBArrow extends TestCase{
public TestBArrow(String method){
super(method);
}
public void testBArrow(){
out.println();
out.println("Testing getters... and isers... :D");
BasicArrowButton bab = new BasicArrowButton(SwingConstants.NORTH);
assertEquals(bab.isFocusable(), false);
assertEquals(new Dimension(5,5), bab.getMinimumSize());
assertEquals(new Dimension(16,16), bab.getPreferredSize());
assertEquals(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE),
bab.getMaximumSize());
assertEquals(SwingConstants.NORTH, bab.getDirection());
out.println("passed 5 asserts... things look good...");
}
public static void main(String ... args){
TestCase tc = new TestBArrow("testBArrow");
TestRunner.run(tc);
}
}
FIX FOR BUG NUMBER:
4289842