equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
35 import java.awt.peer.TextFieldPeer; |
35 import java.awt.peer.TextFieldPeer; |
36 |
36 |
37 import javax.swing.JPasswordField; |
37 import javax.swing.JPasswordField; |
38 import javax.swing.text.JTextComponent; |
38 import javax.swing.text.JTextComponent; |
39 |
39 |
40 import javax.tools.annotation.GenerateNativeHeader; |
|
41 |
|
42 /* No native methods here, but the constants are needed in the supporting JNI code */ |
|
43 @GenerateNativeHeader |
|
44 final class LWTextFieldPeer |
40 final class LWTextFieldPeer |
45 extends LWTextComponentPeer<TextField, JPasswordField> |
41 extends LWTextComponentPeer<TextField, JPasswordField> |
46 implements TextFieldPeer, ActionListener { |
42 implements TextFieldPeer, ActionListener { |
47 |
|
48 private static final int DEFAULT_COLUMNS = 1; |
|
49 |
43 |
50 LWTextFieldPeer(final TextField target, |
44 LWTextFieldPeer(final TextField target, |
51 final PlatformComponent platformComponent) { |
45 final PlatformComponent platformComponent) { |
52 super(target, platformComponent); |
46 super(target, platformComponent); |
53 } |
47 } |
81 } |
75 } |
82 } |
76 } |
83 |
77 |
84 @Override |
78 @Override |
85 public Dimension getPreferredSize(final int columns) { |
79 public Dimension getPreferredSize(final int columns) { |
86 return getPreferredSize(1, columns); |
80 return getMinimumSize(columns); |
87 } |
81 } |
88 |
82 |
89 @Override |
83 @Override |
90 public Dimension getMinimumSize(final int columns) { |
84 public Dimension getMinimumSize(final int columns) { |
91 return getPreferredSize(columns); |
85 return getMinimumSize(1, columns); |
92 } |
|
93 |
|
94 @Override |
|
95 public Dimension getMinimumSize() { |
|
96 return getMinimumSize(DEFAULT_COLUMNS); |
|
97 } |
86 } |
98 |
87 |
99 @Override |
88 @Override |
100 public void actionPerformed(final ActionEvent e) { |
89 public void actionPerformed(final ActionEvent e) { |
101 postEvent(new ActionEvent(getTarget(), ActionEvent.ACTION_PERFORMED, |
90 postEvent(new ActionEvent(getTarget(), ActionEvent.ACTION_PERFORMED, |