-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
beta
-
x86
-
windows_2000
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2116782 | 5.0u3 | Alexander Potochkin | P4 | Closed | Won't Fix |
Name: sv35042 Date: 10/09/2002
FULL PRODUCT VERSION :
java version "1.4.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
The class JComboBox.KeySelectionManager
interprets the pressing of the shift or Caps Lock key as
char '?'
instead of ignoring it
I am writing a class that accepts > 1 char so that if the
user enters 2 chars in quick succession the frist two
letters of an item are used for selection
see topic in forum
http://forum.java.sun.com/thread.jsp?
forum=57&thread=258502&start=0&range=50#970607
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Create a JComboBox
2.add a custom JComboBox.KeySelectionManager that is the
same but just prints out the key typed
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected Result.
Nothing is printed each time the user presses Shift or Caps
Lock
Actual Result.
'?' is printed each time the user presses Shift or Caps Lock
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
/**
* This Class creates a KeySelectionManager for a JComboBox, so when the
JComboBox is selected it zooms to the that accepts more than one char, as long
as they are entered within the alotted time (Default 2 seconds), so it matches
the first part of the ComboBox Item.
**/
public class ExtendedKeySelectionManager implements
JComboBox.KeySelectionManager{
protected String prefix;
protected long lastCharTime;
protected long pauseTime;
/**
* This Constructor creates a ExtendedKeySelectionManager with the default
amount of max time between key types, of 2000 MilliSeconds, for previous keys
to also be taken into account.
**/
public ExtendedKeySelectionManager(){
this(2000);
}
/**
* This Constructor creates a ExtendedKeySelectionManager with a given amount
of max time between key types, for previous keys to also be taken into account.
* @param pauseTime The max time between key types for previous keys to be
taken into account.
**/
public ExtendedKeySelectionManager(long pauseTime){
this.pauseTime = pauseTime;
}
/**
* Given aKey and the model, returns the row that should become selected.
Return -1 if no match was found.
* @param ch - A char value, usually indicating a keyboard key that was pressed
* @param model - A ComboBoxModel -- the component's data model, containing the
list of selectable items
* @return int: An int equal to the selected row, where 0 is the first item
and -1 is none.
**/
public int selectionForKey(char ch, ComboBoxModel model){
char lowerCaseInput = Character.toLowerCase(ch);
if(System.currentTimeMillis() - lastCharTime > pauseTime){
prefix = String.valueOf(lowerCaseInput);
}else{
prefix += lowerCaseInput;
}
lastCharTime = System.currentTimeMillis();
String value;
System.out.println(prefix);
for(int idx = 0; idx < model.getSize(); idx++){
value = model.getElementAt(idx).toString().toLowerCase
();
if(value.startsWith(prefix)){
return idx;
}
}
return -1;
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Just ignore all '?' chars
(Review ID: 147010)
======================================================================
- backported by
-
JDK-2116782 JComboBox.KeySelectionManager should not register a shift key
-
- Closed
-