-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.0
-
generic
-
windows_95
(1) Run the attachment program.
(2) Input fullwidth kanji character(Input Method Framework is on).
(3) Press Enter-key, then inputted string is displayed on TextArea.
Solaris and Windows95 are the same.
(4) Input ascii character(Input Method Framework is off).
In case of Solaris: Input is impossible.
In case of Windows95: Inputted character is displayed on TextArea at time
inputted. Key type event is handled though Input
Method Framework is off.
-------------------------------------------------------------------------------
Program:
import java.awt.*;
import java.awt.im.*;
import java.awt.font.*;
import java.text.*;
import java.awt.event.*;
import java.util.*;
public class InputMethodTest extends Frame implements ActionListener {
IMTextField textfield;
public InputMethodTest() {
super("Input Method (active client) Test");
this.setLayout(new BorderLayout());
textfield = new IMTextField();
this.add(textfield, BorderLayout.CENTER);
Button btn = new Button("select");
btn.addActionListener(this);
this.add(btn, BorderLayout.SOUTH);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
class IMTextField extends Canvas implements
MouseListener, KeyListener, FocusListener,
InputMethodListener, InputMethodRequests {
StringBuffer text;
Font font = null;
public IMTextField() {
enableInputMethods(true);
addMouseListener(this);
addKeyListener(this);
addFocusListener(this);
addInputMethodListener(this);
setCursor(new Cursor(Cursor.TEXT_CURSOR));
text = new StringBuffer();
font = new Font("Dialog", Font.PLAIN, 20);
}
public InputMethodRequests getInputMethodRequests() {
// System.out.println("getInputMethodRequests");
return this/*null*/;
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
Rectangle rect = getBounds();
g.drawString("Input Japanese", 0, 20);
g.setColor(Color.red);
g.drawString(new String(text), 0, 40);
g.setColor(Color.blue);
g2d.drawString(new String(text), 0.0f, 60.0f);
g.drawLine(0, 150, rect.width, 150);
}
// Interface MouseListener
public void mouseClicked(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
this.requestFocus();
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
// Interface KeyListener
public void keyTyped(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
}
// Interface FocusListener
public void focusGained(FocusEvent e) {
// System.out.println("focusGained");
}
public void focusLost(FocusEvent e) {
// System.out.println("focusLost");
}
/**
* Invoked when the text entered through an input method has changed.
*/
public void inputMethodTextChanged(InputMethodEvent event) {
// System.out.println("inputMethodTextChanged");
// System.out.println("e = "+event);
int nCount = event.getCommittedCharacterCount();
if (nCount > 0/*==InputMethodEvent.ALL_CHARACTERS_COMMITTED*/) {
AttributedCharacterIterator intext = event.getText();
for(char c = intext.first(); c != CharacterIterator.DONE; c = intext.next()) {
text.append( c );
}
repaint();
}
else {
AttributedCharacterIterator intext = event.getText();
if (intext != null) {
Map attrs = intext.getAttributes();
// Set set = intext.getAllAttributeKeys();
System.out.println("AttributeSet = " + attrs);
StringBuffer textBuffer = new StringBuffer();
for(char c = intext.first(); c != CharacterIterator.DONE; c = intext.next()) {
textBuffer.append( c );
}
System.out.println("in = " + textBuffer);
Rectangle rect = getBounds();
Graphics g = getGraphics();
g.clearRect(0, 130, rect.width, 20);
g.setFont(font);
g.drawString(new String(textBuffer), 0, 150);
}
}
}
/**
* Invoked when the caret within composed text has changed.
*/
public void caretPositionChanged(InputMethodEvent event) {
// System.out.println("caretPositionChanged");
}
public Rectangle getTextLocation(TextHitInfo offset) {
//System.out.println("#getOffsetLocation");
return new Rectangle(20, 150, 40, 10);
}
public TextHitInfo getLocationOffset(int x, int y) {
//System.out.println("#getLocationOffset");
return TextHitInfo.leading(0);
}
public int getInsertPositionOffset() {
//System.out.println("#getInsertPositionOffset");
return 0;
}
public AttributedCharacterIterator getCommittedText(int beginIndex,
int endIndex,
java.text.AttributedCharacterIterator.Attribute[] attributeNames) {
//System.out.println("#getCommittedText");
return (AttributedCharacterIterator)null;
}
public int getCommittedTextLength() {
//System.out.println("#getCommittedTextLength");
return 0;
}
public AttributedCharacterIterator cancelLatestCommittedText(
java.text.AttributedCharacterIterator.Attribute[] attributeNames) {
//System.out.println("#cancelLatestCommittedText");
return (AttributedCharacterIterator)null;
}
public AttributedCharacterIterator getSelectedText(
java.text.AttributedCharacterIterator.Attribute[] attributeNames) {
//System.out.println("#getSelectedText");
return (AttributedCharacterIterator)null;
}
}
public void actionPerformed(ActionEvent e) {
InputContext ic = textfield.getInputContext();
System.out.println("InputContext =" + ic);
System.out.println("selectInputMethod =" + ic.selectInputMethod(Locale.JAPANESE));
}
public static void main(String args[]){
InputMethodTest f = new InputMethodTest();
f.setSize(400, 300);
f.setVisible(true);
}
protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
super.processWindowEvent(e);
}
}
--------------------------------------------------------------------------------
(2) Input fullwidth kanji character(Input Method Framework is on).
(3) Press Enter-key, then inputted string is displayed on TextArea.
Solaris and Windows95 are the same.
(4) Input ascii character(Input Method Framework is off).
In case of Solaris: Input is impossible.
In case of Windows95: Inputted character is displayed on TextArea at time
inputted. Key type event is handled though Input
Method Framework is off.
-------------------------------------------------------------------------------
Program:
import java.awt.*;
import java.awt.im.*;
import java.awt.font.*;
import java.text.*;
import java.awt.event.*;
import java.util.*;
public class InputMethodTest extends Frame implements ActionListener {
IMTextField textfield;
public InputMethodTest() {
super("Input Method (active client) Test");
this.setLayout(new BorderLayout());
textfield = new IMTextField();
this.add(textfield, BorderLayout.CENTER);
Button btn = new Button("select");
btn.addActionListener(this);
this.add(btn, BorderLayout.SOUTH);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
class IMTextField extends Canvas implements
MouseListener, KeyListener, FocusListener,
InputMethodListener, InputMethodRequests {
StringBuffer text;
Font font = null;
public IMTextField() {
enableInputMethods(true);
addMouseListener(this);
addKeyListener(this);
addFocusListener(this);
addInputMethodListener(this);
setCursor(new Cursor(Cursor.TEXT_CURSOR));
text = new StringBuffer();
font = new Font("Dialog", Font.PLAIN, 20);
}
public InputMethodRequests getInputMethodRequests() {
// System.out.println("getInputMethodRequests");
return this/*null*/;
}
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
Rectangle rect = getBounds();
g.drawString("Input Japanese", 0, 20);
g.setColor(Color.red);
g.drawString(new String(text), 0, 40);
g.setColor(Color.blue);
g2d.drawString(new String(text), 0.0f, 60.0f);
g.drawLine(0, 150, rect.width, 150);
}
// Interface MouseListener
public void mouseClicked(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
this.requestFocus();
}
public void mouseReleased(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
// Interface KeyListener
public void keyTyped(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
}
// Interface FocusListener
public void focusGained(FocusEvent e) {
// System.out.println("focusGained");
}
public void focusLost(FocusEvent e) {
// System.out.println("focusLost");
}
/**
* Invoked when the text entered through an input method has changed.
*/
public void inputMethodTextChanged(InputMethodEvent event) {
// System.out.println("inputMethodTextChanged");
// System.out.println("e = "+event);
int nCount = event.getCommittedCharacterCount();
if (nCount > 0/*==InputMethodEvent.ALL_CHARACTERS_COMMITTED*/) {
AttributedCharacterIterator intext = event.getText();
for(char c = intext.first(); c != CharacterIterator.DONE; c = intext.next()) {
text.append( c );
}
repaint();
}
else {
AttributedCharacterIterator intext = event.getText();
if (intext != null) {
Map attrs = intext.getAttributes();
// Set set = intext.getAllAttributeKeys();
System.out.println("AttributeSet = " + attrs);
StringBuffer textBuffer = new StringBuffer();
for(char c = intext.first(); c != CharacterIterator.DONE; c = intext.next()) {
textBuffer.append( c );
}
System.out.println("in = " + textBuffer);
Rectangle rect = getBounds();
Graphics g = getGraphics();
g.clearRect(0, 130, rect.width, 20);
g.setFont(font);
g.drawString(new String(textBuffer), 0, 150);
}
}
}
/**
* Invoked when the caret within composed text has changed.
*/
public void caretPositionChanged(InputMethodEvent event) {
// System.out.println("caretPositionChanged");
}
public Rectangle getTextLocation(TextHitInfo offset) {
//System.out.println("#getOffsetLocation");
return new Rectangle(20, 150, 40, 10);
}
public TextHitInfo getLocationOffset(int x, int y) {
//System.out.println("#getLocationOffset");
return TextHitInfo.leading(0);
}
public int getInsertPositionOffset() {
//System.out.println("#getInsertPositionOffset");
return 0;
}
public AttributedCharacterIterator getCommittedText(int beginIndex,
int endIndex,
java.text.AttributedCharacterIterator.Attribute[] attributeNames) {
//System.out.println("#getCommittedText");
return (AttributedCharacterIterator)null;
}
public int getCommittedTextLength() {
//System.out.println("#getCommittedTextLength");
return 0;
}
public AttributedCharacterIterator cancelLatestCommittedText(
java.text.AttributedCharacterIterator.Attribute[] attributeNames) {
//System.out.println("#cancelLatestCommittedText");
return (AttributedCharacterIterator)null;
}
public AttributedCharacterIterator getSelectedText(
java.text.AttributedCharacterIterator.Attribute[] attributeNames) {
//System.out.println("#getSelectedText");
return (AttributedCharacterIterator)null;
}
}
public void actionPerformed(ActionEvent e) {
InputContext ic = textfield.getInputContext();
System.out.println("InputContext =" + ic);
System.out.println("selectInputMethod =" + ic.selectInputMethod(Locale.JAPANESE));
}
public static void main(String args[]){
InputMethodTest f = new InputMethodTest();
f.setSize(400, 300);
f.setVisible(true);
}
protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
super.processWindowEvent(e);
}
}
--------------------------------------------------------------------------------