public interface InputDevice
javax.microedition.key
package is implemented, but not the
javax.microedition.lui package (or another graphics library), then those
devices are always "headless" keypads, button fields or the like.
Otherwise, an input device could also be a display with a keypad, in this case
the display would have to implement this interface.
In case a KeyListener
should be set to a Display
(which would
have to implement this interface in case it supports an input device like
a keyboard) this has to be done the following way:
// Display d = ... // ... if(d instanceof InputDevice) { ((InputDevice)d).setKeyListener(myKeyListener); } // ... |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getId()
Retrieves an implementation-specific Id for this
InputDevice . |
boolean |
isHardwareAssigned()
Checks wether this
InputDevice has access to the
underlying hardware. |
void |
setHardwareAssigned(boolean state)
Allows the application to request that an
InputDevice becomes
assigned or unassigned to the underlying hardware. |
void |
setKeyListener(KeyListener listener)
Sets a
KeyListener for key events to this input device,
replacing any previous KeyListener . |
void setKeyListener(KeyListener listener)
KeyListener
for key events to this input device,
replacing any previous KeyListener
. A null
reference is allowed and has the effect of removing any existing listener.
listener
- the new listener, or null
to remove a listener.java.lang.String getId()
InputDevice
.
This Id can be used by applications to identify a certain input device in
cases where the originally retrived object reference of the
InputDevice
object is not stored by the application for
memory performance reasons.
Note that, if an input device is also a Display
, this method is
implemented by Display.getId()
and therefore the
input device id is also the display id and vice versa.
InputDevice
, MUST NOT be null or emptyboolean isHardwareAssigned()
InputDevice
has access to the
underlying hardware.true
if the InputDevice
has access to
the underlying hardware, false
otherwisevoid setHardwareAssigned(boolean state)
InputDevice
becomes
assigned or unassigned to the underlying hardware. However, a requests to
change the InputDevice
's state is not guaranteed and subject
to the device's application resource sharing management behavior.
A call to setHardwareAssigned(false)
has no effect as long as
the input device isn't unassigned indeed.
A call to setHardwareAssigned(true)
has no effect if the
input device has already been assigned before.
Please note, that - depending on the physical structure of the device -
an input device may have also become unassigned by physical separation
from the device without a call to setHardwareAssigned(false)
.
In this case, after the physical connection has been restored, a call to
setHardwareAssigned(true)
may be necessary in order to
re-assign it (the exact behavior in this case is implementation-dependent).
state
- true
in order to explicitly assign the underlying
hardware, false
otherwiseCopyright (c) 2014, Oracle and/or its affiliates. All rights reserved. Use of this specification is subject to license terms.