# (DD03) Business Logic — UI.textField() [8 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.github.blaxk3.ui.UI` |
| Layer | Utility / Presentation Component |
| Module | `ui` (Package: `com.github.blaxk3.ui`) |

## 1. Role

### UI.textField()

This method constructs and configures the primary amount-entry control used by the currency converter screen. It creates a fresh `JTextField`, applies the application's standard typography, and assigns a fixed display size so the input area is visually consistent with the rest of the form layout. The method also enforces input-quality control by attaching the `NumericFilter`, which restricts user entry to numeric characters and a single decimal separator, ensuring the downstream conversion flow receives a parseable amount.

From a business perspective, this is the user-facing validation boundary for currency amount capture. It supports the converter's core transaction flow by preventing non-numeric values before the Convert action is executed, reducing avoidable runtime errors and invalid requests to the exchange-rate service. The method follows a lightweight builder/configurator pattern: it instantiates the component, applies presentation rules, applies behavioral rules, and returns the prepared UI element for composition in the parent panel.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["textField()"])
    NEW_FIELD["Create JTextField instance"]
    SET_FONT["Set font Arial Bold 24"]
    SET_SIZE["Set preferred size 300x100"]
    GET_DOC["Get text field document"]
    CAST_DOC["Cast to PlainDocument"]
    SET_FILTER["Set NumericFilter on document"]
    RETURN_NODE["Return textField component"]
    START --> NEW_FIELD
    NEW_FIELD --> SET_FONT
    SET_FONT --> SET_SIZE
    SET_SIZE --> GET_DOC
    GET_DOC --> CAST_DOC
    CAST_DOC --> SET_FILTER
    SET_FILTER --> RETURN_NODE
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | - |

This method has no parameters. Instead, it relies on the instance field `textField`, which becomes the shared UI control used later by the Convert, Swap, and Clear actions. The method also reads no external business state; its behavior is entirely determined by static UI styling and the attached document filter.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `getDocument()` | - | Swing document model | Reads the editable document backing the text field so the input filter can be attached |
| U | `setDocumentFilter(new NumericFilter())` | - | Swing document model | Updates the document behavior to accept only numeric input and one decimal point |

The method does not invoke domain services or database access layers. Its only called behavior is local UI/document configuration.

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: -

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:UI | `UI.panel()` -> `UI.textField()` | `setDocumentFilter(new NumericFilter()) [U] Swing document model` |

`textField()` is invoked internally by `panel()` when the form is assembled. The method is therefore a construction-time dependency rather than a runtime business-service dependency, and its effect is to prepare the reusable input component before the UI is displayed.

## 6. Per-Branch Detail Blocks

**Block 1** — [SEQUENTIAL] (L149-L156)

> Builds the amount-entry field, applies presentation settings, and installs numeric validation before returning the component.

| # | Type | Code |
|---|------|------|
| 1 | SET | `textField = new JTextField();` // create the input component |
| 2 | EXEC | `textField.setFont(new Font("Arial", Font.BOLD, 24));` // apply standard bold display style |
| 3 | EXEC | `textField.setPreferredSize(new Dimension(300, 100));` // enforce fixed input area size |
| 4 | EXEC | `textField.getDocument();` // obtain the backing document model |
| 5 | EXEC | `((javax.swing.text.PlainDocument) textField.getDocument()).setDocumentFilter(new NumericFilter());` // restrict input to numeric values and a single decimal separator |
| 6 | RETURN | `return textField;` // provide the configured component to the caller |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `textField` | Field | The amount-entry input control where the user types the source currency value to convert |
| `NumericFilter` | Class | Input validator that allows only numeric characters and one decimal point in the amount field |
| `PlainDocument` | Technical term | Swing text document implementation that stores and manages editable text for the input field |
| `DocumentFilter` | Technical term | Swing extension point used to control and validate text edits before they are applied |
| `JTextField` | Technical term | Single-line text entry control used for amount input |
| `Font.BOLD` | Technical term | Font style constant indicating bold text rendering |
| `Arial` | Technical term | Typeface chosen for consistent UI presentation |
| `Dimension(300, 100)` | Technical term | Fixed component size used to align the input field with the screen layout |
| `Currency Converter` | Business term | The application domain supported by this UI, converting an entered amount from one currency to another |
