---

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

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.github.blaxk3.ui.UI` |
| Layer | View (UI) — `UI` extends `javax.swing.JFrame` |
| Module | `ui` (Package: `com.github.blaxk3.ui`) |

## 1. Role

### UI.textField()

The `textField()` method is a private UI factory that constructs a currency-amount input field for the application's graphical interface. It returns a `javax.swing.JTextField` preconfigured with a bold 24-point Arial font and a large 300x100 pixel display area, making it suitable as a prominent input field for monetary values. The method applies a `NumericFilter` document filter to the text field, which restricts user input to digits (0-9) and at most one decimal point — ensuring the field can only ever contain valid numeric currency values. As a component builder, it follows the builder/factory design pattern: it encapsulates all widget creation and configuration logic within the UI class, providing a single callable unit that the parent frame-building method uses to assemble the currency amount entry portion of the screen. It has no conditional branches — it always produces an identically configured text field. Its role in the larger system is as a shared UI component factory within the `UI` view class, called by the frame layout method (which assembles `panelFramePanel1` along with a companion combo box) to render the user-facing input widget.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["textField()"])
    STEP1["Create new JTextField instance"]
    STEP2["Store in instance field textField"]
    STEP3["Set Font: Arial, BOLD, 24px"]
    STEP4["Set PreferredSize: 300x100 pixels"]
    STEP5["Cast textField.getDocument() to PlainDocument"]
    STEP6["Create NumericFilter (digit+decimal filter)"]
    STEP7["Apply DocumentFilter to textField"]
    END_RETURN["Return textField as Component"]

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> STEP6
    STEP6 --> STEP7
    STEP7 --> END_RETURN
```

The processing flow is linear with no branches:

1. **Instantiate JTextField** — Creates a new empty text input field.
2. **Store in instance field** — Saves the reference in the instance field `this.textField` (declared as `private JTextField textField`), making the widget accessible via getter/setter (`getTextField()` / `setTextField(String)`).
3. **Set font** — Applies a bold Arial font at 24pt size for prominent display.
4. **Set preferred size** — Sets the display area to 300 pixels wide by 100 pixels tall.
5. **Cast and filter** — Casts the text field's `Document` to `PlainDocument`, creates a new `NumericFilter` (an inner class extending `DocumentFilter`), and applies it as the field's document filter. The `NumericFilter` intercepts all text insert and replace operations, validating that the resulting content contains only digits and at most one decimal point.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | The method takes no parameters. It always produces an identically configured currency input field. |

**Instance fields read by this method:**
| Field | Type | Business Description |
|-------|------|---------------------|
| `textField` | `JTextField` | Instance field that stores the constructed text input widget. The method overwrites this field with the newly created component. |

## 4. CRUD Operations / Called Services

This method performs no database or service component operations. It is a pure UI widget factory that configures and returns a Swing component. The only external interaction is the creation of a `NumericFilter` instance and the Swing API calls (`new JTextField()`, `setFont()`, `setPreferredSize()`, `setDocumentFilter()`).

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| — | — | — | — | No database or service calls. Pure UI component construction. |

## 5. Dependency Trace

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

No external screen/batch entry points found. Direct callers found: 1 method (internal to `UI.java`).
Terminal operations from this method: — (no SC/CRUD calls).

This method is **private** and has no external callers outside the `UI` class. It is called internally by the frame-building method (`layoutFrame()` / equivalent) at line 77 within `panelFramePanel1.add(textField())`, where it serves as the left-side input widget in a horizontally-flowing panel that pairs the text field with a currency combo box (`comboBox1()`).

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `UI.layoutFrame()` (internal) | `layoutFrame()` → `panelFramePanel1.add(textField())` [L77] | — (no SC/CRUD) |

## 6. Per-Branch Detail Blocks

This method contains no conditional branches, loops, or try-catch blocks. The entire method is a single linear block:

**Block 1** — [LINEAR EXECUTION] (L149–L156)

> Constructs and returns a preconfigured JTextField with numeric input validation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `textField = new JTextField();` // Create new empty text field [-> L150] |
| 2 | EXEC | `textField.setFont(new Font("Arial", Font.BOLD, 24));` // Set bold 24pt Arial font for prominent display [-> L151] |
| 3 | EXEC | `textField.setPreferredSize(new Dimension(300, 100));` // Set display area to 300x100 pixels [-> L152] |
| 4 | CALL | `((PlainDocument) textField.getDocument()).setDocumentFilter(new NumericFilter());` // Restrict input to digits and at most one decimal point [-> L153] |
| 5 | RETURN | `return textField;` // Return configured field as Component [-> L155] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `textField` | Field | Instance variable holding the currency amount text input component (`JTextField`) within the UI view class |
| `JTextField` | Class | Swing text input widget — a single-line text entry component used for the currency amount |
| `NumericFilter` | Inner Class | A `DocumentFilter` subclass that validates text input in real time, allowing only digit characters (0-9) and at most one decimal point |
| `PlainDocument` | Class | The document model underlying `JTextField`; cast to expose `setDocumentFilter()` |
| `DocumentFilter` | Class | Swing API class that intercepts text modifications before they reach the document, used here to enforce numeric-only input |
| `JFrame` | Class | Swing top-level window container; `UI` extends this to represent the main application window |
| `JPanel` | Class | Swing container panel; the text field is added to `panelFramePanel1` which also holds a currency combo box |
| `Component` | Class | Swing base class; the method returns `textField` cast to `Component` for polymorphic panel addition |

---
