47 import javax.swing.JFrame; 48 import javax.swing.JPanel; 49 import javax.swing.border.LineBorder; 50 51 /** 52 * A composition area is used to display text that's being composed 53 * using an input method in its own user interface environment, 54 * typically in a root window. 55 * 56 * @author JavaSoft International 57 */ 58 59 // This class is final due to the 6607310 fix. Refer to the CR for details. 60 public final class CompositionArea extends JPanel implements InputMethodListener { 61 62 private CompositionAreaHandler handler; 63 64 private TextLayout composedTextLayout; 65 private TextHitInfo caret = null; 66 private JFrame compositionWindow; 67 private final static int TEXT_ORIGIN_X = 5; 68 private final static int TEXT_ORIGIN_Y = 15; 69 private final static int PASSIVE_WIDTH = 480; 70 private final static int WIDTH_MARGIN=10; 71 private final static int HEIGHT_MARGIN=3; 72 73 CompositionArea() { 74 // create composition window with localized title 75 String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window"); 76 compositionWindow = 77 (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true); 78 79 setOpaque(true); 80 setBorder(LineBorder.createGrayLineBorder()); 81 setForeground(Color.black); 82 setBackground(Color.white); 83 84 // if we get the focus, we still want to let the client's 85 // input context handle the event 86 enableInputMethods(true); 87 enableEvents(AWTEvent.KEY_EVENT_MASK); 88 89 compositionWindow.getContentPane().add(this); 90 compositionWindow.addWindowListener(new FrameWindowAdapter()); 91 addInputMethodListener(this); | 47 import javax.swing.JFrame; 48 import javax.swing.JPanel; 49 import javax.swing.border.LineBorder; 50 51 /** 52 * A composition area is used to display text that's being composed 53 * using an input method in its own user interface environment, 54 * typically in a root window. 55 * 56 * @author JavaSoft International 57 */ 58 59 // This class is final due to the 6607310 fix. Refer to the CR for details. 60 public final class CompositionArea extends JPanel implements InputMethodListener { 61 62 private CompositionAreaHandler handler; 63 64 private TextLayout composedTextLayout; 65 private TextHitInfo caret = null; 66 private JFrame compositionWindow; 67 private static final int TEXT_ORIGIN_X = 5; 68 private static final int TEXT_ORIGIN_Y = 15; 69 private static final int PASSIVE_WIDTH = 480; 70 private static final int WIDTH_MARGIN=10; 71 private static final int HEIGHT_MARGIN=3; 72 73 CompositionArea() { 74 // create composition window with localized title 75 String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window"); 76 compositionWindow = 77 (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true); 78 79 setOpaque(true); 80 setBorder(LineBorder.createGrayLineBorder()); 81 setForeground(Color.black); 82 setBackground(Color.white); 83 84 // if we get the focus, we still want to let the client's 85 // input context handle the event 86 enableInputMethods(true); 87 enableEvents(AWTEvent.KEY_EVENT_MASK); 88 89 compositionWindow.getContentPane().add(this); 90 compositionWindow.addWindowListener(new FrameWindowAdapter()); 91 addInputMethodListener(this); |