---
# (DD06) Business Logic — UI.comboBox2() [7 LOC]

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

## 1. Role

### UI.comboBox2()

This method builds and returns the second combo box used by the UI as a currency selection control. It constructs a fresh `JComboBox<String>`, applies a fixed preferred size of 300 by 30 pixels, and then delegates population of the options to the asynchronous `CurrencyCode` worker. In business terms, the method is responsible for preparing the currency-code selector that the user interacts with when choosing a currency for conversion or display. The method does not contain branching business rules; instead, it follows a simple factory-and-delegation pattern where the UI component is created locally and its option list is loaded from an external source in the background. This makes the method a shared presentation-layer helper that standardizes how the currency selector is instantiated across the screen. The actual business data enrichment happens outside the method, through the worker that fetches and sorts currency codes before inserting them into the combo box.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["comboBox2()"])
    CREATE["Create JComboBox<String> instance"]
    SIZE["Set preferred size to 300 x 30"]
    CALL["new CurrencyCode(comboBox2).execute()"]
    BG["CurrencyCode SwingWorker fetches currency codes asynchronously"]
    RETURN["Return comboBox2 component"]
    START --> CREATE
    CREATE --> SIZE
    SIZE --> CALL
    CALL --> BG
    BG --> RETURN
```

## 3. Parameter Analysis

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

**Instance fields / external state used by this method:** `comboBox2` is assigned and then passed into `CurrencyCode`; the method relies on the enclosing `UI` instance state. No input parameters are accepted.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `CurrencyCode.doInBackground()` | - | CurrencyRateAPI response payload | Reads the list of available currency codes from an external rate API in the background. |
| C | `CurrencyCode.done()` | - | `JComboBox<String>` items | Populates the combo box with the retrieved currency codes after they are sorted. |

The method itself does not directly perform database CRUD. Its business impact is limited to UI component creation and delegation to the worker that fetches currency reference data.

## 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.<init or panel setup>` -> `UI.comboBox2()` | `CurrencyCode.doInBackground [R] CurrencyRateAPI` |

The only direct caller found in the source is the UI panel setup method that adds the component to the frame. This method ultimately delegates to the nested `CurrencyCode` worker, which performs the external currency-code retrieval and then loads the combo-box items.

## 6. Per-Branch Detail Blocks

**Block 1** — [SEQUENTIAL] `(method entry)` (L103)

> Builds the currency selection component and prepares it for asynchronous data binding.

| # | Type | Code |
|---|------|------|
| 1 | SET | `comboBox2 = new JComboBox<>();` // instantiate the currency selector |

**Block 2** — [SEQUENTIAL] `(component sizing)` (L104)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `comboBox2.setPreferredSize(new Dimension(300, 30));` // standardize the UI footprint |

**Block 3** — [SEQUENTIAL] `(async population trigger)` (L105)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `new CurrencyCode(comboBox2).execute();` // start background loading of currency codes |

**Block 3.1** — [TRY-CATCH] `(CurrencyCode.doInBackground / done)` (L214-L232)

> The nested worker retrieves currency codes from the external API and then pushes them into the combo box after sorting.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `new CurrencyRateAPI().getCurrencyCode();` // fetch currency code list from the rate service |
| 2 | EXEC | `Arrays.stream(currencyCodes).sorted().forEach(comboBox::addItem);` // sort and insert each currency code into the combo box |
| 3 | RETURN | `return` // end background work and hand control back to the UI thread |

**Block 4** — [RETURN] `(method exit)` (L107)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return comboBox2;` // provide the prepared component to the caller |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `comboBox2` | UI field / component | The second currency selector shown in the screen, used to choose the target or source currency depending on the UI flow. |
| `CurrencyCode` | Nested class | Background worker that loads currency codes asynchronously so the UI remains responsive. |
| `CurrencyRateAPI` | External service | API client that retrieves available currency codes from the currency-rate service. |
| `SwingWorker` | Technical pattern | Java background execution mechanism used to avoid blocking the UI thread during data retrieval. |
| `JComboBox` | UI component | Drop-down list that presents selectable currency options to the user. |
| `preferred size` | UI layout term | Fixed display size used to keep the component visually consistent in the screen layout. |
| `currency code` | Business term | Standard identifier for a currency, such as USD, EUR, or JPY, used for conversion and display. |
