Search…
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.

Source Code

FloatButton
1
Image ic = null;
2
try {
3
ic = new Image("images/floatbtn.png");
4
} catch (IOException e) {
5
e.printStackTrace();
6
} catch (ImageException e) {
7
e.printStackTrace();
8
}
9
FloatingButton floatbutton = new FloatingButton(ic);
10
floatbutton.setBackColor(Color.getRGB(109, 156, 232));
11
floatbutton.setIconSize(30);
12
add(floatbutton, RIGHT-40, BOTTOM-40);
Copied!
Do not forget to create a folder called "images" inside /src/main/resources and save the floatbtn.png image inside it [images].

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.
Last modified 2yr ago