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

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

## 1. Role

### UI.textField()

This method constructs and configures the primary input component used by the currency converter screen for entering the amount to be converted. It creates a fresh `JTextField`, applies the visual styling needed by the UI theme, and constrains the component to accept only numeric-style input through a `DocumentFilter`. In business terms, it is the amount-entry control for the conversion workflow, ensuring the user can provide a valid numeric value before any conversion request is executed.

The method does not branch by business service type; instead, it performs a single presentation-layer responsibility: initialize and return a reusable form field with validation behavior attached. It follows a builder-like initialization pattern, where a component is created, decorated, and then handed back to the parent panel assembly code. As part of the larger system, this method is a shared UI factory helper used by the screen assembly logic so the amount field can be inserted into the converter layout with consistent formatting and input restrictions.

A key part of its role is defensive input control. By attaching `NumericFilter`, the method prevents invalid characters from being entered into the amount field, which reduces downstream conversion errors and avoids invalid API calls from the business flow triggered elsewhere in `UI`. The method therefore acts as an early validation gate in the user interaction path rather than a business processor itself.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["textField()"])
    CREATE(["Create new JTextField"])
    FONT(["Set font Arial Bold 24"])
    SIZE(["Set preferred size 300x100"])
    DOC(["Get PlainDocument from text field"])
    FILTER(["Set NumericFilter document filter"])
    RETURN_NODE(["Return textField component"])
    
    START --> CREATE
    CREATE --> FONT
    FONT --> SIZE
    SIZE --> DOC
    DOC --> FILTER
    FILTER --> RETURN_NODE
```

**CRITICAL — Constant Resolution:**
No application constants are referenced in this method. The method uses only literal UI values and locally defined classes.

## 3. Parameter Analysis

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

This method does not accept parameters. It relies on the enclosing `UI` instance state only to assign the newly created component to the `textField` field before returning it.

External state read by the method:
- `textField` instance field is assigned and then returned

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `UI.textField` | UI | - | Calls `textField` in `UI` |

This method does not perform database CRUD operations and does not invoke any SC/CBS business service. It only initializes Swing UI objects and attaches a local input filter.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JTextField` | - | - | Creates the amount input control for the converter screen |
| - | `NumericFilter` | - | - | Attaches local digit validation to the field document |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 2 methods.
Terminal operations from this method: `textField` [-], `textField` [-], `textField` [-]

The caller search found one source file with multiple references to `textField(`, all inside `UI.java`. The visible direct usage is the panel assembly path, which inserts the returned component into the upper input panel. Because the method is private and UI-local, the dependency trace remains internal to the same class rather than propagating to an external screen or batch entry point.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:UI | `UI.panel()` -> `UI.textField()` | `textField [ - ] -` |
| 2 | Screen:UI | `UI.panel()` -> `UI.textField()` | `textField [ - ] -` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SEQUENTIAL INIT] `(create and configure field)` (L149-L155)

> Builds the amount-entry component with fixed visual sizing and numeric-only input protection.

| # | Type | Code |
|---|------|------|
| 1 | SET | `textField = new JTextField();` // create the amount input control |
| 2 | EXEC | `textField.setFont(new Font("Arial", Font.BOLD, 24));` // apply prominent display styling |
| 3 | EXEC | `textField.setPreferredSize(new Dimension(300, 100));` // reserve the required input area |
| 4 | EXEC | `((javax.swing.text.PlainDocument) textField.getDocument()).setDocumentFilter(new NumericFilter());` // enforce numeric input rules |

**Block 2** — [RETURN] `(return configured component)` (L156)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return textField;` // hand the configured input component back to the caller |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `textField` | Field | Amount input field used by the currency converter screen for entering the value to be converted |
| `JTextField` | Technical term | Swing text-entry component used for free-form user input |
| `DocumentFilter` | Technical term | Swing document-level validator that controls what text can be inserted or replaced |
| `PlainDocument` | Technical term | Swing document implementation used by the text field to store its text content |
| `NumericFilter` | Class | Local input filter that allows only numeric characters and a single decimal point |
| `Font.BOLD` | Technical term | Font style constant used to render the field in bold text |
| `Currency Converter` | Business term | The application domain handled by the UI, converting one currency amount to another |
| `amount` | Business term | The numeric value entered by the user for conversion |
| `UI` | Class | Main Swing window class that assembles the converter interface |
| `panel()` | Method | UI assembly method that places the text field and other controls into the screen layout |
| `comboBox1` | Field | Source-currency selector used with the entered amount |
| `comboBox2` | Field | Target-currency selector used with the entered amount |
| `label` | Field | Output display area for the converted result |
