1 /*
2 * Copyright (c) 1997, 2006, 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
83 *
84 * @param g the graphics context
85 */
86 protected void paintBackground(Graphics g) {
87 super.paintBackground(g);
88 }
89
90 /**
91 * Creates the caret for a field.
92 *
93 * @return the caret
94 */
95 protected Caret createCaret() {
96 return new WindowsFieldCaret();
97 }
98
99 /**
100 * WindowsFieldCaret has different scrolling behavior than
101 * DefaultCaret.
102 */
103 static class WindowsFieldCaret extends DefaultCaret implements UIResource {
104
105 public WindowsFieldCaret() {
106 super();
107 }
108
109 /**
110 * Adjusts the visibility of the caret according to
111 * the windows feel which seems to be to move the
112 * caret out into the field by about a quarter of
113 * a field length if not visible.
114 */
115 protected void adjustVisibility(Rectangle r) {
116 SwingUtilities.invokeLater(new SafeScroller(r));
117 }
118
119 /**
120 * Gets the painter for the Highlighter.
121 *
122 * @return the painter
|
1 /*
2 * Copyright (c) 1997, 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
83 *
84 * @param g the graphics context
85 */
86 protected void paintBackground(Graphics g) {
87 super.paintBackground(g);
88 }
89
90 /**
91 * Creates the caret for a field.
92 *
93 * @return the caret
94 */
95 protected Caret createCaret() {
96 return new WindowsFieldCaret();
97 }
98
99 /**
100 * WindowsFieldCaret has different scrolling behavior than
101 * DefaultCaret.
102 */
103 @SuppressWarnings("serial") // Superclass is not serializable across versions
104 static class WindowsFieldCaret extends DefaultCaret implements UIResource {
105
106 public WindowsFieldCaret() {
107 super();
108 }
109
110 /**
111 * Adjusts the visibility of the caret according to
112 * the windows feel which seems to be to move the
113 * caret out into the field by about a quarter of
114 * a field length if not visible.
115 */
116 protected void adjustVisibility(Rectangle r) {
117 SwingUtilities.invokeLater(new SafeScroller(r));
118 }
119
120 /**
121 * Gets the painter for the Highlighter.
122 *
123 * @return the painter
|