Java Drawing DrawTop

Language

JP  US  UK

 

Listener Panel

 H. Jyounishi, Tokyo Japan
 

Frame (Index), No frame                 version:0.3(latest)  

Summary: The LisnerPanel is the extended class of the DrawPanel. The objects implementing the MouseListener and MouseMotionListener interfaces such as the CreateShapeLS, MoveResizeShapeLS, SelectionLS etc. are added to the LisnerPanel. In addition, to support the Japanese Kana-kanji converter, the methods defined by the InputMethodListener, InputMethodRequests interfaces of the Input Method Framework are implemented to the LisnerPanel.
Class on this page: ListenerPanel

1. Overview ∙ The following objects defined by the MouseListener and the MouseMotionListener interfaces are added to the ListenerPanel.

CreateShapeLS, MoveResizeShapeLS, SelectionLS, MousePositionLS, ModifyShapeLS, TextBox


∙ The InputMethodListener and the InputMethodRequests interfaces are implemented to the ListenerPanel to make the Input Method Framework available.
The several methods are defined by the InputMethodListener, the InputMethodRequests and the KeyListener interfaces. The four of those are used in this application as follow.

Method
Description
keyTyped(KeyEvent e)
Gets a alphabetic character from the KeyEvent object.
keyPressed(KeyEvent e)
If the Left, Right, Up or Down key is pressed, then moves the text cursor (caret).
inputMethodTextChanged
(InputMethodEvent event)

Gets the Japanese text converted by kana-kanji converter from the InputMethodEvent object.

getTextLocation(TextHitInfo offset)

Returns the current text input location.
If this method isn't implemented, some error occurs when the window of a candidate list of kana/kanj is displayed.


2. Class ListenerPanel return=>page top
public class ListenerPanel extends DrawPanel implements KeyListener, InputMethodListener, InputMethodRequests

Method
Description
Constructor
public ListenerPanel()
Sets the following settings to make this object operate as ActiveClient.
this.requestFocus();
this.enableInputMethods(true);
this.addInputMethodListener(this);
this.addKeyListener(this);
this.addMouseListener(this);
getMouseListenersInfo
public String getMouseListenersInfo()
Returns the string representing the list of the MouseListener objects registered to this object.
printMouseListeners
public void printMouseListeners()
This method is for debug.
isMouseListener
public boolean isMouseListener(MouseListener listener)
Returns true if the MouseLister object specified by the parameter is registered to this object.
isMouseMotionListener
public boolean isMouseMotionListener(MouseMotionListener listener)
Returns true if the MouseMotionLister object specified by the parameter is registered to this object.
keyTyped
public void keyTyped(KeyEvent event)
This method is defined by the KeyListener.
Performs the following operation for the key in the KeyEvent.
∙ If the key code is an ASCII control code (0x00-0x20), then receives only " \n" (0x0a, line feed), otherwise receives any key.
: The accelerator - ctrl+x: cut, ctrl+c: copy, ctrl+v: paste
The accelerator belongs to ASCII control codes, so if an ASCII control code was accepted, then unclear characters would be inserted to the sentence.
=> Key code in the KeyEvent
∙ Gets an editable TextBox object by the getEditableTextBox method of the ContainerManager . If found, then transfers the KeyEvent object to the keyTyped method of the TextBox.
keyPressed
public void keyPressed(KeyEvent event)
If the key code in the KeyEvent equals Home, End, Up or Down key, then transfers the KeyEvent object to the keyTyped method of the editable TextBox.
=> Key code in the KeyEvent (*5)
keyReleased
public void keyReleased(KeyEvent event)
Nothing is done.
getInputMethodRequests
public InputMethodRequests getInputMethodRequests()
Returns this object.
inputMethodTextChanged
public void inputMethodTextChanged(InputMethodEvent event)
Gets an editable TextBox object by the getEditableTextBox method of the ContainerManager. If it is found, then transfers the InputMethodEvent object to the inputMethodTextChanged method of the TextBox.
caretPositionChanged
public void caretPositionChanged(InputMethodEvent event)
Nothing is done.
getCommittedTextLength
public int getCommittedTextLength()
Nothing is done.
getTextLocation
public Rectangle getTextLocation(TextHitInfo offset)
Returns the current text input location.
Gets an editable TextBox object by the getEditableTextBox method of the ContainerManager. If it is found, then the current text input location by the getTextLocation method of the TextBox.
If this method isn't implemented, some error occurs when the window of a candidate list of kana/kanj is displayed.
getLocationOffset
public TextHitInfo getLocationOffset(int x, int y)
Nothing is done.
getInsertPositionOffset
public int getInsertPositionOffset()
Nothing is done.
getCommittedText
public AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex, Attribute[] attributes)

Nothing is done.
cancelLatestCommitted
Text
public AttributedCharacterIterator cancelLatestCommittedText(Attribute[] attributes)
Nothing is done.
getSelectedText
public AttributedCharacterIterator getSelectedText(Attribute[] attributes)
Nothing is done.
mousePressed
public void mousePressed(MouseEvent e)
Calls the next two steps to activate the ActiveClient of the Input Method Framework.
this.requestFocus();
this.enableInputMethods(true);
mouseClicked
public void mouseClicked(MouseEvent e)
Calls the next two steps to activate the ActiveClient of the Input Method Framework.
this.requestFocus();
this.enableInputMethods(true);
mouseReleased
public void mouseReleased(MouseEvent e)
Nothing is done.
mouseEntered
public void mouseEntered(MouseEvent e)
Nothing is done.
mouseExited
public void mouseExited(MouseEvent e)
Nothing is done.

: Key code in the KeyEvent return=>page top
(*1) keyChar: The display of a keyChar by the System.out.println
char keyChar=event.getKeyChar();
(*2) keyChar Hex: The hex display of a keyChar by the System.out.printl
(*3) keyCode: The display of a keyCode by the System.out.println

int keyCode=event.getKeyCode();
"?": The display by the System.out.println. "-": The keyTyped method or the keyPressed method isn't called.


Key keyTyped
keyPressed
keyChar
(*1)
keyChar Hex
(*2)
keyCode
(*3)

keyChar
(*1)
keyChar Hex
(*2)
keyCode
(*3)

ctrl
-
-
-
?
0xffff
17(VK_CONTROL)
Back space
?
0x08
0
?
0x08
8(VK_BACK_SPACE)
Enter (line feed)
?
0x0a
0
?
0x0a
10(VK_ENTER)
ctrl+C
?
0x03(ctrl+C)
0
?
0x03(ctrl+C)
67(VK_C)
ctrl+X
?
0x18(ctrl+X)
0
?
0x18(ctrl+X)
88(VK_X)
ctrl+V
?
0x16(ctrl+V)
0
?
0x16(ctrl+V)
86(VK_V)
Home (Left arrow)
-
-
-
?
0xffff
37(VK_LEFT)
End (Right arrow)
- - - ?
0xffff
39(VK_RIGHT)
pg Up (Up arrow)
- - - ?
0xffff
38(VK_UP)
pg Dn (Down arrow)
- - - ?
0xffff
40(VK_DOWN)


Copyright (c) 2009-2013
All other trademarks are property of their respective owners.