Question : Java swing: AbstractButton

I have some extracted codes from AbstractButton:

View view = (View) AbstractButton.this.getClientProperty("html");

Where is the key "html" from? Or what does it mean? Is it already defined in somewhere?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
/**
	 * Given a point in local coordinates, return the zero-based index
	 * of the character under that Point.  If the point is invalid,
	 * this method returns -1.
	 *
         * Note: the AbstractButton must have a valid size (e.g. have
         * been added to a parent container whose ancestor container
         * is a valid top-level window) for this method to be able
         * to return a meaningful value.
	 *
	 * @param p the Point in local coordinates
	 * @return the zero-based index of the character under Point p; if 
	 * Point is invalid returns -1.
	 * @since 1.3
	 */
	public int getIndexAtPoint(Point p) {
	    View view = (View) AbstractButton.this.getClientProperty("html");
	    if (view != null) {
		Rectangle r = getTextRectangle();
		if (r == null) {
		    return -1;
		}
		Rectangle2D.Float shape = 
		    new Rectangle2D.Float(r.x, r.y, r.width, r.height);
		Position.Bias bias[] = new Position.Bias[1];
		return view.viewToModel(p.x, p.y, shape, bias);
	    } else {
		return -1;
	    }
	}

Answer : Java swing: AbstractButton

Hi learningunix,

the line checks if the left-most byte of 'num' is '1'.

'&num' is a pointer to the memory address where the first byte of 'num' resides. The '(char*)' casts this pointer '&num' (which is a pointer to int) to a pointer to char. Since char is a one byte data type accessing that 'pointer to char' with '*' accesses the first byte of the int. In little endian this byte has to be '1' for and 'int' which is '1' - in big endian the first byte would be '0' since the least significant byte is the most right one ...

Hope that helps,

ZOPPO

Random Solutions  
 
programming4us programming4us