net.yura.mobile.gui.components
Class TextArea
java.lang.Object
net.yura.mobile.gui.components.Component
net.yura.mobile.gui.components.TextComponent
net.yura.mobile.gui.components.TextArea
- All Implemented Interfaces:
- javax.microedition.lcdui.CommandListener, ActionListener
public class TextArea
- extends TextComponent
what happens with sizes:
- set some text
- size is calculated right away (if the text is wraped then a defualt width is used)
- if wrap is turned on later, the size is recalculated
- when revalidate is called somewhere
- (if its inside a Panel, then the default size is used, just like swing, this can sometimes look strange)
- if its inside a ScrollPane, then workoutSize() is called from ScrollPane.doLayout() (the ScrollPane knows its correct size at this time)
- if wrap is TRUE the width is set to the ViewPort width of the ScrollPane (taking into account that it already has the rightish size, so can find out if scrollbars are needed on the ScrollPane)
- if the width or height is less then the ViewPort, the ScrollPane will streach the size
- Author:
- Yura Mamyrin
- See Also:
JTextArea
Field Summary |
protected int[] |
lines
|
Fields inherited from class net.yura.mobile.gui.components.TextComponent |
ANY, caretPosition, CONSTRAINT_MASK, DECIMAL, EMAILADDR, font, INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD, MODE_123, MODE_abc, MODE_Abc, MODE_ABC, NON_PREDICTIVE, NUMERIC, padding, PASSWORD, PHONENUMBER, SENSITIVE, showCaret, text, tmpChar, UNEDITABLE, URL |
Fields inherited from class net.yura.mobile.gui.components.Component |
background, empty, FOCUS_GAINED, FOCUS_LOST, focusable, foreground, height, parent, posX, posY, preferredHeight, preferredWidth, state, theme, width |
Method Summary |
void |
append(String a)
|
protected void |
changedUpdate(int offset,
int length)
|
String |
getDefaultName()
|
int |
getLineOfOffset(int offset)
|
int[] |
getLines(String str,
Font f,
int startPos,
int w)
|
int[] |
getLines(String str,
Font f,
int startPos,
int startW,
int w)
If w == Integer.MAX_VALUE, then it wont wrap on words |
int |
getLineSpacing()
Get the line spacing |
boolean |
getLineWrap()
|
int |
getStringCharOffset(String text,
Font font,
int xPixelOffset)
|
int |
getStringWidth(Font f,
String s)
|
void |
paintComponent(Graphics2D g)
|
boolean |
processKeyEvent(KeyEvent keyEvent)
|
void |
processMouseEvent(int type,
int x,
int y,
KeyEvent keys)
|
void |
setCaretPosition(int a)
|
void |
setLineSpacing(int lineSpacing)
Set's the line spacing |
void |
setLineWrap(boolean w)
|
void |
setSize(int wi,
int h)
|
void |
workoutMinimumSize()
This sets the width and height of this component
to the MINIMUM that is needed for this component |
Methods inherited from class net.yura.mobile.gui.components.TextComponent |
actionPerformed, allowChar, animate, autoAccept, closeNativeEditor, commandAction, focusGained, focusLost, getCaretPosition, getConstraints, getDisplayString, getFont, getLength, getMaxSize, getText, getValue, openNativeEditor, searchStringCharOffset, setConstraints, setFont, setMaxSize, setMode, setText, setTitle, setValue, toString, updateUI |
Methods inherited from class net.yura.mobile.gui.components.Component |
add, add, add, addFocusListener, addImpl, clip, consumesMotionEvents, getBackground, getBorder, getCurrentState, getDesktopPane, getFocusListeners, getForeground, getHeight, getHeightWithBorder, getInsets, getName, getParent, getPreferredHeight, getPreferredWidth, getState, getToolTipLocationX, getToolTipLocationY, getToolTipText, getWidth, getWidthWithBorder, getWindow, getX, getXOnScreen, getXWithBorder, getY, getYOnScreen, getYWithBorder, insert, insert, isComponentVisible, isFocusable, isFocusOwner, isOpaque, isRectVisible, isShowing, isVisible, makeVisible, paint, paintBorder, processMultitouchEvent, removeFocusListener, removeParent, repaint, requestFocusInWindow, revalidate, scrollRectToVisible, scrollUpDown, setBackground, setBorder, setBounds, setBoundsWithBorder, setFocusable, setForeground, setLocation, setName, setPreferredSize, setState, setToolTipText, setupState, setVisible, transferFocus, validate, wait, workoutSize |
lines
protected int[] lines
TextArea
public TextArea()
TextArea
public TextArea(String text)
append
public void append(String a)
- Parameters:
a
- The text to append- See Also:
JTextArea.append
changedUpdate
protected void changedUpdate(int offset,
int length)
- Overrides:
changedUpdate
in class TextComponent
- See Also:
DocumentListener.changedUpdate
getDefaultName
public String getDefaultName()
- Specified by:
getDefaultName
in class Component
getLineOfOffset
public int getLineOfOffset(int offset)
- See Also:
JTextArea.getLineOfOffset
getLines
public int[] getLines(String str,
Font f,
int startPos,
int w)
getLines
public int[] getLines(String str,
Font f,
int startPos,
int startW,
int w)
- If w == Integer.MAX_VALUE, then it wont wrap on words
getLineSpacing
public int getLineSpacing()
- Get the line spacing
- See Also:
StyleConstants.getLineSpacing
getLineWrap
public boolean getLineWrap()
- See Also:
JTextArea.getLineWrap
getStringCharOffset
public int getStringCharOffset(String text,
Font font,
int xPixelOffset)
getStringWidth
public int getStringWidth(Font f,
String s)
paintComponent
public void paintComponent(Graphics2D g)
- Specified by:
paintComponent
in class Component
- Parameters:
g
- The Graphics object- See Also:
JComponent.paintComponent
processKeyEvent
public boolean processKeyEvent(KeyEvent keyEvent)
- Overrides:
processKeyEvent
in class TextComponent
- See Also:
JComponent.processKeyEvent
processMouseEvent
public void processMouseEvent(int type,
int x,
int y,
KeyEvent keys)
- Overrides:
processMouseEvent
in class TextComponent
- See Also:
Component.processMouseEvent
setCaretPosition
public void setCaretPosition(int a)
- Overrides:
setCaretPosition
in class TextComponent
- Parameters:
a
- position in the text- See Also:
JTextComponent.setCaretPosition
setLineSpacing
public void setLineSpacing(int lineSpacing)
- Set's the line spacing
- Parameters:
lineSpacing
- spacing between lines- See Also:
StyleConstants.setLineSpacing
setLineWrap
public void setLineWrap(boolean w)
- See Also:
JTextArea.setLineWrap
setSize
public void setSize(int wi,
int h)
- Overrides:
setSize
in class Component
- See Also:
Component.setSize
workoutMinimumSize
public void workoutMinimumSize()
- Description copied from class:
Component
- This sets the width and height of this component
to the MINIMUM that is needed for this component
- Specified by:
workoutMinimumSize
in class Component
- See Also:
JComponent.getMinimumSize