1 /*
2 * Copyright (c) 2003, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
524 JTextComponent comp = getComponent();
525
526 UIDefaults uidefaults = XToolkit.getUIDefaults();
527
528 String prefix = getPropertyPrefix();
529
530 InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");
531
532 if (map != null) {
533 SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
534 map);
535 }
536 }
537
538 @Override
539 protected Caret createCaret() {
540 return new XTextAreaPeer.XAWTCaret();
541 }
542 }
543
544 final class XAWTTextField extends JPasswordField
545 implements ActionListener, DocumentListener {
546
547 private boolean isFocused = false;
548 private final XComponentPeer peer;
549
550 XAWTTextField(String text, XComponentPeer peer, Container parent) {
551 super(text);
552 this.peer = peer;
553 setDoubleBuffered(true);
554 setFocusable(false);
555 AWTAccessor.getComponentAccessor().setParent(this,parent);
556 setBackground(peer.getPeerBackground());
557 setForeground(peer.getPeerForeground());
558 setFont(peer.getPeerFont());
559 setCaretPosition(0);
560 addActionListener(this);
561 addNotify();
562
563 }
|
1 /*
2 * Copyright (c) 2003, 2014, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
524 JTextComponent comp = getComponent();
525
526 UIDefaults uidefaults = XToolkit.getUIDefaults();
527
528 String prefix = getPropertyPrefix();
529
530 InputMap map = (InputMap)uidefaults.get(prefix + ".focusInputMap");
531
532 if (map != null) {
533 SwingUtilities.replaceUIInputMap(comp, JComponent.WHEN_FOCUSED,
534 map);
535 }
536 }
537
538 @Override
539 protected Caret createCaret() {
540 return new XTextAreaPeer.XAWTCaret();
541 }
542 }
543
544 @SuppressWarnings("serial") // JDK-implementation class
545 final class XAWTTextField extends JPasswordField
546 implements ActionListener, DocumentListener {
547
548 private boolean isFocused = false;
549 private final XComponentPeer peer;
550
551 XAWTTextField(String text, XComponentPeer peer, Container parent) {
552 super(text);
553 this.peer = peer;
554 setDoubleBuffered(true);
555 setFocusable(false);
556 AWTAccessor.getComponentAccessor().setParent(this,parent);
557 setBackground(peer.getPeerBackground());
558 setForeground(peer.getPeerForeground());
559 setFont(peer.getPeerFont());
560 setCaretPosition(0);
561 addActionListener(this);
562 addNotify();
563
564 }
|