Starryi
3 years ago
5 changed files with 101 additions and 20 deletions
@ -0,0 +1,50 @@ |
|||||||
|
package com.fr.design.mainframe.share.ui.actions; |
||||||
|
|
||||||
|
import com.fr.design.gui.imenu.UIMenuItem; |
||||||
|
import com.fr.design.mainframe.share.ui.constants.ColorConstants; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
|
||||||
|
import javax.swing.Action; |
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.Icon; |
||||||
|
import java.awt.Graphics; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/10/19 |
||||||
|
*/ |
||||||
|
public class LoadingMenuItem extends UIMenuItem { |
||||||
|
private boolean loading = false; |
||||||
|
|
||||||
|
private final Icon profileIcon = IOUtils.readIcon("/com/fr/design/form/images/loading.gif"); |
||||||
|
|
||||||
|
public LoadingMenuItem(Action action) { |
||||||
|
super(action); |
||||||
|
setOpaque(true); |
||||||
|
setBackground(ColorConstants.BACKGROUND); |
||||||
|
setUI(new SharedComponentActionMenuItemUI(false)); |
||||||
|
} |
||||||
|
|
||||||
|
public void startLoading() { |
||||||
|
loading = true; |
||||||
|
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); |
||||||
|
revalidate(); |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
public void stopLoading() { |
||||||
|
loading = false; |
||||||
|
setBorder(BorderFactory.createEmptyBorder()); |
||||||
|
revalidate(); |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void paintBorder(Graphics g) { |
||||||
|
super.paintBorder(g); |
||||||
|
if (loading) { |
||||||
|
profileIcon.paintIcon(this, g, getWidth() - 20, 0); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 3.3 KiB |
Loading…
Reference in new issue