# Floating Button

### Overview

Floating Button is a circular floating button that keeps fixed on its initial position and, usually, is used for the main action of the screen.

<div align="left"><img src="/files/-LaWO8y6A7vRQGrXGtbv" alt=""></div>

### Source Code

{% code title="FloatButton" %}

```java
Image ic = null;
try {
  ic = new Image("images/floatbtn.png");
} catch (IOException e) {
  e.printStackTrace();
} catch (ImageException e) {
  e.printStackTrace();
}
FloatingButton floatbutton = new FloatingButton(ic);
floatbutton.setBackColor(Color.getRGB(109, 156, 232));
floatbutton.setIconSize(30);
add(floatbutton, RIGHT-40, BOTTOM-40);

```

{% endcode %}

{% hint style="warning" %}
Do not forget **to create a folder** called "***images***" inside ***/src/main/resources*** and **save the** [**floatbtn.png**](https://github.com/TotalCross/TCSample/blob/master/src/main/resources/images/floatbtn.png) **image inside it** \[images].
{% endhint %}

### Métodos

| Type            | Name                                  | Description                                                 |
| --------------- | ------------------------------------- | ----------------------------------------------------------- |
| **Constructor** | FloatingButton( )                     | Creates a Floating Button with a predefined icon.           |
| **Constructor** | FloatingButton(Image foregroundImage) | Creates a Floating Button with setting the icon.            |
| **void**        | setIcon(image foregroundImage)        | Sets the Floating Button icon.                              |
| **void**        | setIconSize(int iconsize)             | Sets the Floating Button icon size.                         |
| **Image**       | getIcon( )                            | Returns the Image that represents the Floating Button icon. |
| **int**         | getIconSize( )                        | Returns the size of the Floating Button icon.               |


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.totalcross.com/documentation/components/floating-button.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
