> For the complete documentation index, see [llms.txt](https://tanishisherewith.gitbook.io/archived-legacy-dynamichud/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/archived-legacy-dynamichud/moveable-screen/creating-and-using-your-own-moveablescreen-class.md).

# Creating and using your own MoveableScreen class

This page talks about creating your own screen class by extending the AbstractMoveableScreen class

You first need to create a new class and extend `AbstractMoveableScreen`. This will allow you to use the functionality provided by the `AbstractMoveableScreen` class, such as handling mouse dragging, mouse release, and mouse clicks, as well as rendering widgets on the screen.

Here’s an example of a new screen class that extends `AbstractMoveableScreen`:

```java
public class MyScreen extends AbstractMoveableScreen {
    public MyScreen(Text title, DynamicUtil dynamicutil) {
        super(title, dynamicutil);
    }

    @Override
    protected boolean handleRightClickOnWidget(Widget widget) {
        // Handle right-clicks on widgets here such as opening the menu
        /*
        Example:
        int x=widget.getX();
        int y=widget.getY();
        menu(widget,x,y);
        */
        return false;
    }

    @Override
    protected void menu(Widget widget, int x, int y) {
        // Display a context menu for the widget here

    }
}
```

In this example, we create a new class called `MyScreen` that extends `AbstractMoveableScreen`. We override the `handleRightClickOnWidget` and `menu` methods to provide custom behavior for handling right-clicks on widgets and displaying context menus for widgets.

Once you have created your new screen class, you can use it in your Minecraft Fabric mod's main class by creating an instance of it and displaying it on the screen. For example:

{% code overflow="wrap" lineNumbers="true" fullWidth="false" %}

```java
DynamicHUD.setAbstractScreen(new MyScreen(text,dynamicutil));
```

{% endcode %}

This code creates a new instance of the `MyScreen` class with the title “My Screen” and the given dynamicutil instance, and displays it on the screen.

You can also use the different methods provided by the `AbstractMoveableScreen` class in your new screen class. For example, you can override the `render` method to provide custom rendering behavior for your screen:

```java
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    super.render(matrices, mouseX, mouseY, delta);

    // Add custom rendering code here
}
```

In this example, we override the `render` method and call the superclass’s implementation of this method to render the widgets on the screen. Then, we add custom rendering code to draw additional content on the screen.
