Last updated
Last updated
To adapt the component to the style of the application it is often necessary to change its colors.
Make the button the width of the screen.
Modify the button edges.
Change the buttons sizes.
Add an image to the button.
Handling events with addPressListener()
:
Do not forget to create a folder called "images" inside /src/main/resources and save the image inside it [images].
See also our on creating buttons.
See the for more information.
Type
Name
Description
boolean
Button.CENTRALIZE
Center image and text on the button.
Type
Name
Description
Constructor
Button( )
Creates a simple button
Constructor
Button(Image img)
Creates a simple button with the referred image
Constructor
Button(Image img, byte border)
Creates a button with the referreds image and border
Constructor
Button(String text)
Creates a button with the referred text
Constructor
Button(String text, byte border)
Creates a button with the referreds text and border
Constructor
Button(String text, Image img, int textPosition, int gap)
Creates a button with the referred text and image
Image
getImage( )
Return the button image
String
getText( )
Return the button text
Boolean
isPressed( )
Return true if button is pressed
void
press(boolean pressed)
If true, press the button
void
setBorder(byte border)
Set the button border style
void
setImage(Image img)
Set the button image
void
setPressedColor(int newColor)
Return the button text
void
setText(String text)
Set the button text
void
simulatePress( )
Press and depress the button
Buttons are an essential way to interact with and navigate through an app, and should clearly communicate what action will occur after the user taps them