# 텍스트 컴포넌트

* `isEditable()` / `setEditable(boolean)`
* `getDragEnabled()` / `setDragEnabled(boolean)`
* `getDisabledTextColor()` / `setDisabledTextColor(Color)`
* `getMargin()` / `setMargin(Insets)` : 텍스트와 컴포넌트 보더 사이 간격

* `getSelectedText()`
* `select(int,int)` / `selectAll()`
* `getSelectionStart()` / `setSelectionStart(int)` / `getSelectionEnd()` / `setSelectionEnd(int)`
* `getSelectionColor()` / `setSelectionColor(Color)`
* `getSelectedTextColor()` / `setSelectedTextColor(Color)`

* `viewToModel(Point)` / `modelToView(int)`

* `copy()` / `cut()` / `paste()` / `replaceSelection(String)`
* `getActions()`
* `getInputMap()`
* `put(KeyStroke,Object)`

* `getDocument()` / `setDocument(Document)`
* `setDocumentFilter(DocumentFilter)`

* `getCaret()` / `setCaret(Caret)`
* `getCaretColor()` / `setCaretColor(Color)`
* `getCaretPosition()` / `moveCaretPosition(int)` / `setCaretPosition(int)`
* `addCaretListener()` / `removeCaretListener()`

* `setNavigationFilter()`
* `getHighlighter()` / `setHighlighter(Highlighter)`

* `read(Reader, Object)` / `write(Writer)`

* `print()` / `print(MessageFormat,MessageFormat)`
* `getPrintable(MessageFormat,MessageFormat)`

## Document
* `addDocumentListener()` / `removeDocumentListener()`
* `addUndoableEditListener()` / `removeUndoableEditListener()`
* `getLength()`
* `getStartPosition()` / `getEndPosition()`
* `getText(int,int)`
* `getProperty(Object)` / `putProperty(Object,Object)` / `getDocumentProperties()` / `setDocumentProperties(Dictionary)`

## Undo / Redo 구현 - UndoableEditListener
```java
// 언두 매니저를 생성하고, 텍스트 문서에 리스너를 통해 연결한다. 
final UndoManager undoManager = new UndoManager();
textArea.getDocument().addUndoableEditListener(undoableEditEvent -> 
        undoManager.addEdit(undoableEditEvent.getEdit()));

// 버튼을 통해서 액션을 처리한다.
toolBar.add(new AbstractAction("Undo") {
    @Override
    public void actionPerformed(ActionEvent actionEvent) {
        if (undoManager.canUndo()) {
            undoManager.undo();
        }
    }
});
toolBar.add(new AbstractAction("Redo") {
    @Override
    public void actionPerformed(ActionEvent actionEvent) {
        if (undoManager.canRedo()) {
            undoManager.redo();
        }
    }
});
```

## DocumentListener
```java
textArea.getDocument().addDocumentListener(new DocumentListener() {
    @Override
    public void insertUpdate(DocumentEvent documentEvent) {
        Document document = documentEvent.getDocument();
        int changeLength = documentEvent.getLength();
    }

    @Override
    public void removeUpdate(DocumentEvent documentEvent) {

    }

    @Override
    public void changedUpdate(DocumentEvent documentEvent) {

    }
});
```

## CaretListener
```java
textArea.addCaretListener(new CaretListener() {
    @Override
    public void caretUpdate(CaretEvent caretEvent) {
        int dot = caretEvent.getDot();
        int mark = caretEvent.getMark();
    }
});
```










## JTextField

* `getText()` / `setText(String)`
* `isEditable()` / `setEditable(boolean)`
* `getColumns()` / `setColumns(int)` : 화면에 표시될 칼럼 길이

* `selectAll()`

* `getHorizontalAlignment()` / `setHorizontalAlignment(int)` : JTextField.LEADING | CENTER | TRAILING

* `addActionListener()` / `removeActionListener()`

## JPasswordField

* `char[] getPassword()`
* `getEchoChar()` / `setEchoChar(char)`

## JFormattedTextField

* `JFormattedTextField()` / `JFormattedTextField(Format)` / `JFormattedTextField(Formatter)` / `JFormattedTextField(FormatterFactory)`

* `getValue()` / `setValue(Object)`
* `getFormatter()` / `setFormatterFactory()`
* `setFocusLostBehavior(int)` : COMMIT_OR_REVERT | COMMIT | PERSIST | REVERT
* `commitEdit()`
* `isEditValid()`

### Format
* DateFormatter
* NumberFormatter
* InternationalFormatter
* MaskFormatter
* DateFormat
* SimpleDateFormat
* NumberFormat
* DefaultFormatterFactory
* DefaultFormatter

#### DefaultFormatter

* `getCommitsOnValidEdit()` / `setCommitsOnValidEdit(boolean)`
* `getOverwriteMode()` / `setOverwriteMode(boolean)`
* `getAllowsInvalid()` / `setAllowsInvalid(boolean)`

#### MaskFormatter
* `#` 아무 숫자 하나
* `'` 이스케잎문자로 사용됨
* `U` 대문자 하나
* `L` 소문자 하나
* `A` 문자 또는 숫자 하나
* `?` 문자 하나
* `*` 아무거나
* `H` 16진수문자 하나

## JTextArea

* `JTextArea()` / `JTextArea(String)` / `JTextArea(int,int)` / `JTextArea(String,int,int)` : 칼럼 갯수, 열 갯수

* `getText()` / `setText(String)`

* `isEditable()` / `setEditable(boolean)`
* `getColumns()` / `setColumns(int)`
* `getRows()` / `setRows(int)`
* `setTabSize(int)`
* `setLineWrap(boolean)`
* `setWrapStyleWord(boolean)`

* `selectAll()`

* `append(String)`
* `insert(String,int)`
* `replaceRange(String,int,int)`
* `getLineCount()`
* `getLineOfOffset(int)`
* `getLineStartOffset(int)`
* `getLineEndOffset(int)`

## JEditorPane

## JTextPane

