gnu.java.awt.peer.swing

Class SwingTextFieldPeer

Implemented Interfaces:
ComponentPeer, TextComponentPeer, TextFieldPeer

public class SwingTextFieldPeer
extends SwingComponentPeer
implements TextFieldPeer

A TextFieldPeer based on Swing JTextField.

Field Summary

Fields inherited from class gnu.java.awt.peer.swing.SwingComponentPeer

awtComponent, paintArea, peerFont, swingComponent

Constructor Summary

SwingTextFieldPeer(TextField textField)
Creates a new SwingTextFieldPeer instance for the specified AWT textfield.

Method Summary

long
filterEvents(long filter)
Not used.
int
getCaretPosition()
Returns the current caret position.
Rectangle
getCharacterBounds(int pos)
Returns the bounds of the character at the specified index.
int
getIndexAtPoint(int x, int y)
Returns the index of the character at the specified location.
InputMethodRequests
getInputMethodRequests()
Not used.
Dimension
getMinimumSize(int len)
Returns the minimum size of the textfield.
Dimension
getPreferredSize(int len)
Returns the preferred size of the textfield.
int
getSelectionEnd()
Returns the end index of the current selection.
int
getSelectionStart()
Returns the start index of the current selection.
String
getText()
Returns the current content of the textfield.
Dimension
minimumSize(int len)
Returns the minimum size of the textfield.
Dimension
preferredSize(int len)
Returns the preferred size of the textfield.
void
select(int startPos, int endPos)
Sets the current selection.
void
setCaretPosition(int pos)
Sets the current caret position.
void
setEchoChar(char echoChar)
Sets the echo character.
void
setEchoCharacter(char echoChar)
Sets the echo character.
void
setEditable(boolean editable)
Sets the editable flag of the text field.
void
setText(String text)
Sets the content of the textfield.

Methods inherited from class gnu.java.awt.peer.swing.SwingComponentPeer

canDetermineObscurity, checkImage, coalescePaintEvent, createBuffers, createImage, createImage, createVolatileImage, destroyBuffers, disable, dispose, enable, flip, getBackBuffer, getBounds, getColorModel, getComponent, getFontMetrics, getGraphics, getGraphicsConfiguration, getLocationOnScreen, getMinimumSize, getPreferredSize, getToolkit, handleEvent, handleFocusEvent, handleKeyEvent, handleMouseEvent, handleMouseMotionEvent, handlesWheelScrolling, hide, init, isFocusTraversable, isFocusable, isObscured, isReparentSupported, layout, minimumSize, paint, peerPaint, peerPaintComponent, preferredSize, prepareImage, print, repaint, reparent, requestFocus, requestFocus, requestFocus, reshape, setBackground, setBounds, setBounds, setCursor, setEnabled, setEventMask, setFont, setForeground, setVisible, show, updateCursorImmediately

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

SwingTextFieldPeer

public SwingTextFieldPeer(TextField textField)
Creates a new SwingTextFieldPeer instance for the specified AWT textfield.
Parameters:
textField - the AWT textfield

Method Details

filterEvents

public long filterEvents(long filter)
Not used.
Specified by:
filterEvents in interface TextComponentPeer

getCaretPosition

public int getCaretPosition()
Returns the current caret position.
Specified by:
getCaretPosition in interface TextComponentPeer
Returns:
the current caret position

getCharacterBounds

public Rectangle getCharacterBounds(int pos)
Returns the bounds of the character at the specified index.
Specified by:
getCharacterBounds in interface TextComponentPeer
Parameters:
pos - the index of the character
Returns:
the bounds of the character at the specified index

getIndexAtPoint

public int getIndexAtPoint(int x,
                           int y)
Returns the index of the character at the specified location.
Specified by:
getIndexAtPoint in interface TextComponentPeer
Parameters:
x - the X coordinate of the point to query
y - the Y coordinate of the point to query
Returns:
the index of the character at the specified location

getInputMethodRequests

public InputMethodRequests getInputMethodRequests()
Not used.
Specified by:
getInputMethodRequests in interface TextComponentPeer

getMinimumSize

public Dimension getMinimumSize(int len)
Returns the minimum size of the textfield.
Specified by:
getMinimumSize in interface TextFieldPeer
Parameters:
len - not used here
Returns:
the minimum size of the textfield

getPreferredSize

public Dimension getPreferredSize(int len)
Returns the preferred size of the textfield.
Specified by:
getPreferredSize in interface TextFieldPeer
Parameters:
len - not used here
Returns:
the preferred size of the textfield

getSelectionEnd

public int getSelectionEnd()
Returns the end index of the current selection.
Specified by:
getSelectionEnd in interface TextComponentPeer
Returns:
the end index of the current selection

getSelectionStart

public int getSelectionStart()
Returns the start index of the current selection.
Specified by:
getSelectionStart in interface TextComponentPeer
Returns:
the start index of the current selection

getText

public String getText()
Returns the current content of the textfield.
Specified by:
getText in interface TextComponentPeer
Returns:
the current content of the textfield

minimumSize

public Dimension minimumSize(int len)
Returns the minimum size of the textfield.
Specified by:
minimumSize in interface TextFieldPeer
Parameters:
len - not used here
Returns:
the minimum size of the textfield

preferredSize

public Dimension preferredSize(int len)
Returns the preferred size of the textfield.
Specified by:
preferredSize in interface TextFieldPeer
Parameters:
len - not used here
Returns:
the preferred size of the textfield

select

public void select(int startPos,
                   int endPos)
Sets the current selection.
Specified by:
select in interface TextComponentPeer
Parameters:
startPos - the start index of the selection
endPos - the start index of the selection

setCaretPosition

public void setCaretPosition(int pos)
Sets the current caret position.
Specified by:
setCaretPosition in interface TextComponentPeer
Parameters:
pos - the caret position to set

setEchoChar

public void setEchoChar(char echoChar)
Sets the echo character.
Specified by:
setEchoChar in interface TextFieldPeer
Parameters:
echoChar - the echo character to be set

setEchoCharacter

public void setEchoCharacter(char echoChar)
Sets the echo character.
Specified by:
setEchoCharacter in interface TextFieldPeer
Parameters:
echoChar - the echo character to be set

setEditable

public void setEditable(boolean editable)
Sets the editable flag of the text field.
Specified by:
setEditable in interface TextComponentPeer
Parameters:
editable - true to make the textfield editable, false to make it uneditable

setText

public void setText(String text)
Sets the content of the textfield.
Specified by:
setText in interface TextComponentPeer
Parameters:
text - the text to set

SwingTextFieldPeer.java -- A Swing based peer for AWT textfields Copyright (C) 2006, 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.