JDK-4093819 : setCursor(WAIT_CURSOR) on an applet doesn't affect textfields
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1,1.1.4,1.1.5,1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS:
    generic,solaris_2.5.1,solaris_2.6,windows_nt generic,solaris_2.5.1,solaris_2.6,windows_nt
  • CPU: generic,other,x86
  • Submitted: 1997-11-18
  • Updated: 2018-04-28
  • Resolved: 2018-04-28
Related Reports
Duplicate :  
Duplicate :  
Description
Name: rm29839			Date: 11/18/97


Executing the following code demonstrates the
problem.  The cursor is set to the stop watch
(WAIT_CURSOR) for the applet and for the
components other than the text field.  The
textfield cursor should change as well.

import java.applet.*;
import java.awt.*;

public class CursorBug extends Applet {

    public void init() {
	TextField tf;
	add(tf = new TextField(20));
	add(new Checkbox("Debug", true));
	add(new Button("Submit"));

	Cursor busy = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
	setCursor(busy);
    }
}
(Review ID: 20009)
======================================================================

Comments
No plans to address this.
28-04-2018

WORK AROUND Name: rm29839 Date: 11/18/97 Adding the line tf.setCursor(busy) is a workaround, but it is not helpful when there are dozens of textfields. ====================================================================== isa.hashim@Eng 1998-08-14 ------------------------- Another workaround is - right after creating the textfield, immediately set it's cursor to the default: tf = new TextField(20); tf.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); After this, whenever the containing Panel/Applet's cursor is changed, the textfield will inherit it.
17-09-2004

PUBLIC COMMENTS setCursor(WAIT_CURSOR) on an applet doesn't affect textfields
17-09-2004

EVALUATION brian.stuart@eng 1998-07-22 Name: rrT76497 Date: 07/23/98 22 Jul 98/ Padmajaya/ SIPTech The Bug is a valid bug and it reproduces in all of the platforms (Solaris and Win32) under both versions of jdk1.1.7 and jdk1.2beta4 The reason could be because the textfield is already having a predefined cursor set and this check is made in WComponentPeer.java before setting the cursor. When explicitly TextField.setCursor is given then the cursor gets set to the TextField without any problem. ====================================================================== isa.hashim@Eng 1998-08-14 ------------------------- As far as I know, on Solaris/X Windows, you can set the cursor of a window by doing: valuemask = CWCursor; attributes.cursor = c; XChangeWindowAttributes(awt_display, XtWindow(w), valuemask, &attributes); One of the valid types of cursors is the value 'None'. If this value is used, the parent's cursor value is used when the pointer is in the window. This is how/why every cursor in a Panel/Applet changes when you call setCursor() on it. Every child of the Applet will 'inherit' the new cursor set on the Applet. We get this for free from X Windows. However, any child component that has a cursor explicitly set on it will *not* inherit it's parent cursor. This is exactly the TextField's case. In TextComponent.java: ======================================================================================== 1 /* 2 * @(#)TextComponent.java 1.34 98/07/01 3 * ... 74 /** 75 * Constructs a new text component initialized with the 76 * specified text. Sets the value of the cursor to 77 * <code>Cursor.TEXT_CURSOR</code>. 78 * @param text the initial text that the component presents. 79 * @see java.awt.Cursor 80 * @since JDK1.0 81 */ 82 TextComponent(String text) { 83 this.text = text; 84 setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); 85 } 86 ... ======================================================================================== A cursor is set on the TextComponent (the I-beam cursor), which makes the TextComponent *not* inherit it's parent's cursor. Just to be sure, I commented out line 84 above and the problem goes away. Another workaround is - right after creating the textfield, immediately set it's cursor to the default: tf = new TextField(20); tf.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); This sets the cursor for the textfield back to None (making inheritance possible). The trade off here is that you lose the insert pointer on your textfield (the cursor still appears to be the insert cursor). I'm not exactly sure why TextComponent explicitly sets its cursor to the TEXT_CURSOR. I'm guessing it was to match the textfield on Windows. Even if this did work on Solaris, what should be the correct behaviour: When we call Component.setCursor(WAIT_CURSOR), everything in the component (ie it's children) should show the stopwatch cursor. Now, when we call Component.setCursor(DEFAULT_CURSOR), should all the components show the system default cursor or should they show the cursor they had before ? AWT currently has the notion of a *system wide* default cursor, not a per component default cursor. To resolve the above issue, it might be necessary to add new APIs to support default cursors for specific components. Also, I can't see a way of AWT avoiding traversing the component hierarchy looking for children that need their cursors set to resolve this problem - I don't think it is a good idea to do that (performance). Having to do that just because TextComponent's choose to have a special cursor and *still* want to inherit from their parent's is not really justifiable. My take on this bug given the time and situation is: - TextComponent is the culprit here. Component.setCursor() behaves correctly. If we delete the setCursor() call in TextComponent the problem is gone. We can't do this now obviously for compatibility reasons. - We can't really fix this bug (at least I don't know how) without potentially changing behaviour and/or adding new APIs to AWT. - Please try my workaround. Having to explicitly change all the textfield cursors in the app everytime you want to show busy feedback is a bit inconvenient. The other workaround I'm providing here needs to be done only once at textfield create time. Remember the trade off: you lose the insert pointer Many fixes for this bug have gone into review. It has been decided that this bug should not be fixed in a dot dot release because to correct this problem correctly would require API changes. So I am mremoving this from the commit list for 1.1.8. lara.bunni@Eng 1999-01-12 --------- 4/11/2000 kevin.ryan@eng -- still an issue as of kestrel-rc3 (1.3.0rc3-Z) on both win32 and Solaris. ===== We will need an API change to resolve this issue. There are two open proposals. One is Amy Fowler's "busy" property proposal, described at http://javaweb.eng/~aim/enabling.html. The other is my more generic override cursor proposal, described at http://javaweb.eng/~dpm/cursor.txt. david.mendenhall@eng 2000-06-14
14-06-2000