atarw / material-ui-swing

A modern, Material Design UI for Java Swing
MIT License
656 stars 87 forks source link

Imported, and set the look and feel, but the components look pretty bland (unlike in the demo) #3

Closed GodIHateThis closed 6 years ago

GodIHateThis commented 6 years ago

Imported these:

import mdlaf.MaterialLookAndFeel;
import mdlaf.MaterialUIMovement;

Tried setting the look and feel both in the start of the constructor and main function:

try
    {
        UIManager.setLookAndFeel(new MaterialLookAndFeel());
    }
catch (UnsupportedLookAndFeelException e)
    {
        e.printStackTrace();
    }

Also did the animate thing and works as intended.

MaterialUIMovement animate2 = new MaterialUIMovement(new Color(34, 167, 240), 5, 1000 / 30);
animate2.add(adminB);

Also tried the demo and the buttons look different ( like they're supposed to look because of the look and feel )

Am i supposed to apply something to the components first? 2018-04-17_13-12-30

PS: don't know if this is the right place to ask questions

atarw commented 6 years ago

hi, i can't seem to reproduce this, can you send a small/simplified project for me to test?

GodIHateThis commented 6 years ago

testlookandfeel.zip

Thought about what could be the cause.

Since i'm using a public pc with w7, and it has a reduced GUI ( looks kinda like w95 mixed with wxp ), maybe that affects how every look and feel looks like, AND it all depends on the users pc.

For example this is how the program look for me without your look and feel applied: 2018-04-19_09-21-11

Edit:Found out that SwingUtilities.updateComponentTreeUI(frame); actually got me closer to your look and feel but the font and the look and feel still glitched out in a few panels. Where should i run this update function?

atarw commented 6 years ago

did a bit of testing, and the error happens because some jcomponents are initialized before the look and feel is set in the main method (e.g. in the constructor, as well as static variables) - once you move all variable instantiation to after the look and feel is applied, everything works fine.

if you don't want to modify your code, putting the updateComponentTreeUI function at the end of your main method seemed to work fine, although you need to recall MaterialUIMovement.add(...) afterwards on any animated components to update the hover effect separately

NOTE: i modified MaterialUIMovement to become purely static so that users don't have to keep instantiating new instances of the class to add animation effects.

now you can just simply use MaterialUIMovement.add(component, color, steps, interval).

i hope this helps!

GodIHateThis commented 6 years ago

The main fault was that before the updateComponentTreeUI, a important constructor was initializing.

You should put SwingUtilities.updateComponentTreeUI(JFrame); in the readme thing just in case