1 /* 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 /* 26 @test 27 @bug 7146572 28 @summary Check if 'enableInputMethods' works properly for TextArea and TextField on Linux platform 29 @author a.stepanov 30 @run applet/manual=yesno InputMethodsTest.html 31 */ 32 33 34 import java.applet.Applet; 35 import java.awt.*; 36 import javax.swing.*; 37 import java.awt.event.*; 38 39 40 public class InputMethodsTest extends Applet { 41 42 TextArea txtArea = null; 43 TextField txtField = null; 44 JButton btnIM = null; 45 boolean inputMethodsEnabled = true; 46 47 public void init() { 48 this.setLayout(new BorderLayout()); 49 } 50 51 public void start() { 52 53 setSize(350, 200); 54 55 JPanel panel = new JPanel(); 56 panel.setLayout(new GridLayout(2, 1)); 57 58 txtArea = new TextArea(); 59 panel.add(txtArea); 60 61 txtField = new TextField(); 62 panel.add(txtField); 63 64 add(panel, BorderLayout.CENTER); 65 66 btnIM = new JButton(); 67 setBtnText(); 68 69 btnIM.addActionListener(new ActionListener() { 70 @Override 71 public void actionPerformed(ActionEvent e) { 72 inputMethodsEnabled = !inputMethodsEnabled; 73 setBtnText(); 74 txtArea.enableInputMethods(inputMethodsEnabled); 75 txtField.enableInputMethods(inputMethodsEnabled); 76 } 77 }); 78 79 add(btnIM, BorderLayout.SOUTH); 80 81 validate(); 82 setVisible(true); 83 } 84 85 private void setBtnText() { 86 String s = inputMethodsEnabled ? "Disable" : "Enable"; 87 btnIM.setText(s + " Input Methods"); 88 } 89 } 90