Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vincenzopalazzo/def019b7c1eaee426cea6a7bab995d14 to your computer and use it in GitHub Desktop.
Save vincenzopalazzo/def019b7c1eaee426cea6a7bab995d14 to your computer and use it in GitHub Desktop.
Material-UI-Swing pre-release 6.0 description with material table style restored to version 1.1.1_beta.

Material-UI-Swing pre-release 6.0

Introduction

This version includes the complete refactoring to JButton and restored all change inside the JTable (the code of the table UI is equal to code the version 1.1.1_beta material-ui-swing version).

MaterialButtonUI Refactoring

The old version of MaterialButtonUI had a bad code inside the implementation and this caused the bad performance with a complex client application, how JMars, an example mouse hover event on Jbutton worked bad or ware very slow. The version 1.1.1 pre-release 6.0 (over to have an ugly name 😄) introduce a big refactoring inside the component UI, and change/simplifies the API of JButton if you want to create a personal UI.

as well as to disabled the mouse hovers on the Jbutton, you can disable the focus (borders dashed) and the button pressed effect.

With order.

Disabled mouse hover with personalUI

to paint the button with no mouse hover effect you can use this code, described in vincenzopalazzo/material-ui-swing issues.

Disabled borders dashed

to disabled border dashed there are two possible methods, like:

  • set the button not focusable or with button.setFocusable(false);
  • create a personal implementation of the method paintFoucs, like the following code
 @Override
    protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
        paintBorderButton(g, b);
        
    }

Disable button pressed effect

To disabled button pressed effect you can override inside the personal UI component the method called paintButtonPressed with code like the following:

@Override
    protected void paintButtonPressed(Graphics g, AbstractButton b) {
        g.setColor(background);
        g.fillRoundRect(0, 0, b.getWidth(), b.getHeight(), arch, arch);
        paintBorderButton(g, b);
    }

Conclusion

Now the implementation of JButton is a lot of personalizable but it is possible to increase the modularization of the component MaterialButtonUI. For the moment the version remains this, because another refactoring can introduce a few bugs inside the component behavior

Other changes is described inside the CHANGELOG file

License

Sponsors this work

To support my work in this version you can use

Donation Custom badge

or

Github donations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment