Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create round material button with images instead of text? #192

Closed
omegaui opened this issue Apr 29, 2022 · 8 comments
Closed

How to create round material button with images instead of text? #192

omegaui opened this issue Apr 29, 2022 · 8 comments

Comments

@omegaui
Copy link

omegaui commented Apr 29, 2022

Screenshot from 2022-04-29 16-05-59

I am writing a code editor with materialFX.

I want to create a same control as the filter button in the above image.
Is there some other control than MFXButton to achieve this behaviour?

@omegaui
Copy link
Author

omegaui commented Apr 29, 2022

MaterialFX is really amazing as it gives me the feel of writing flutter applications.

But,
Its actually difficult to understand the library as there are only .fxml files available for example reference, programmers like me who prefer coding instead of using scene builder find it difficult to learn and explore the UI library like this.

@omegaui
Copy link
Author

omegaui commented Apr 29, 2022

Got it!
Actually, I am a beginner in JavaFX

@omegaui omegaui closed this as completed Apr 29, 2022
@M-K-Al
Copy link

M-K-Al commented Apr 29, 2022

Small tip, for the icons i encourage you to use fontawesomefx as it will make your life easier.
To use it, add these to your maven (there are other icons but this will do):

        <dependency>
            <groupId>de.jensd</groupId>
            <artifactId>fontawesomefx-commons</artifactId>
            <version>9.1.2</version>
        </dependency>

        <dependency>
            <groupId>de.jensd</groupId>
            <artifactId>fontawesomefx-materialicons</artifactId>
            <version>2.2.0-9.1.2</version>
        </dependency>

Then

        MaterialIconView icon = new MaterialIconView(MaterialIcon.PERSON, "22"); // 'PERSON' is my icon from fontawesomefx, 22 is the icon size
        
        MFXIconWrapper filterIcon = new MFXIconWrapper(icon, 32).defaultRippleGeneratorBehavior(); // this will create the ripple effect, 32 is the ripple size
        
        NodeUtils.makeRegionCircular(filterIcon); // this will make the ripple circular

Here is the result:
image

@omegaui
Copy link
Author

omegaui commented May 1, 2022

Thanks a lot.
I was using the -fx-background-radius property.
But this seems more appealing to me.

@omegaui
Copy link
Author

omegaui commented May 1, 2022

@M-K-Al
Can you please help me out, I am just starting out with JavaFX?

When using the above code, I am getting the following error ...
Screenshot from 2022-05-01 14-13-23

These are my modules and I am using javafx 17 ...
Screenshot from 2022-05-01 14-12-30

Although this probably points either

  • I am missing some dependency
  • Or The Library utilizes a non-modular version of the JDK.

@M-K-Al
Copy link

M-K-Al commented May 1, 2022

I would love to help you out!
Can you please copy the whole exception?
But from the fist look have you added fontawesomefx? I don't see it in your models list.
P.S., not to force you but using intellij could help you alot.

@omegaui
Copy link
Author

omegaui commented May 1, 2022

Thanks for taking a step to help!

But I figured it out, I switched to icons8.

@omegaui
Copy link
Author

omegaui commented May 1, 2022

My IDE is built different

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants