> For the complete documentation index, see [llms.txt](https://tanishisherewith.gitbook.io/dynamic-hud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tanishisherewith.gitbook.io/dynamic-hud/contextmenu/option-less-than-t-greater-than-class.md).

# Option\<T> class

### Option

The `Option` class is an abstract base class for configurable settings in a context menu. It holds the option’s value, name, and description, and interacts with `SkinRenderer` for rendering and input handling.

**Key Responsibilities**

* **Value Management**: Uses `getter` and `setter` to manage the option’s value.
* **Rendering**: Delegates rendering to its associated `SkinRenderer`.
* **Input Handling**: Provides default input handling, customizable by subclasses.
* **Complexity**: Supports a `Complexity` enum to control visibility based on user expertise.

**Key Methods**

* `get()`: Retrieves the current value.
* `set(T)`: Updates the value.
* `render(DrawContext, int, int, int, int)`: Delegates to the renderer.
* `updateProperties(ContextMenuProperties)`: Sets the renderer based on the skin.
* `shouldRender()`: Determines if the option is visible based on complexity and conditions.
* `description(String)` : is used to set tooltips/descriptions that is rendered by the Skin of the context menu.

**Common Issues**

* **Null Renderer**: If the skin lacks a renderer for the option type, a `RuntimeException` occurs.
  * **Fix**: Ensure the skin registers a renderer for the option class, including built-ins such as [Cycle Option](/dynamic-hud/contextmenu/option-less-than-t-greater-than-class/cycle-option.md).
* **Complexity Mismatch**: Options may not render if the user’s complexity setting is too low.
  * **Fix**: Set appropriate `Complexity`:

    ```java
    option.withComplexity(Option.Complexity.Simple);
    ```

{% hint style="warning" %}
Always provide a valid `getter` and `setter` to avoid null pointer exceptions.
{% endhint %}

### Usage

To use the `Option<T>` class, extend it and implement the abstract `render` method to define the option’s appearance and behavior. Use the `setShouldRender` method to specify conditions under which the option should be displayed.

DynamicHUD ships with built-in options such as `BooleanOption`, `ColorOption`, `DoubleOption`, `CycleOption`, `RunnableOption`, and `SubMenuOption`.

This is an example usage of several options from a widget menu:<br>

{% code title="TextWidget.java" fullWidth="true" %}

```java
Difficulty difficulty = Difficulty.EASY;
String alignment = "Left";
boolean running = false;
boolean subMenuBool = false;

public void createMenu() {
    List<String> alignments = Arrays.asList("Left", "Center", "Right");
    menu = new ContextMenu(getX(), getY(), ContextMenuProperties.builder().build());
    menu.addOption(new BooleanOption("Shadow", () -> this.shadow, value -> this.shadow = value));
    menu.addOption(new BooleanOption("Rainbow", () -> this.rainbow, value -> this.rainbow = value));
    menu.addOption(new ColorOption("TextColor", menu, () -> this.textColor, value -> this.textColor = value));
    menu.addOption(new DoubleOption("RainbowSpeed", 1, 4, 1.0f, () -> (double) this.rainbowSpeed, value -> this.rainbowSpeed = value.intValue(),menu));
    menu.addOption(new CycleOption<>("Difficulty", ()-> difficulty, val -> difficulty = val, Difficulty.values()));
    menu.addOption(new CycleOption<>("Alignment", ()-> alignment, val -> alignment= val, alignments));
    menu.addOption(new RunnableOption("Runnable Test",()->running,val -> running = val, this::printStuff));
    SubMenuOption subMenuOption = new SubMenuOption("SubMenu",menu,()-> subMenuBool ,val -> subMenuBool = val);
    subMenuOption.getSubMenu().addOption(new BooleanOption("Shadows2", () -> this.shadow, value -> this.shadow = value));
    menu.addOption(subMenuOption);
}
public void printStuff(){
    System.out.println("Runnable works");
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://tanishisherewith.gitbook.io/dynamic-hud/contextmenu/option-less-than-t-greater-than-class.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
