forked from fanruan/design
11 changed files with 151 additions and 66 deletions
@ -0,0 +1,49 @@
|
||||
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 javax.swing.Action; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.Dimension; |
||||
import java.awt.Insets; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2021/10/20 |
||||
*/ |
||||
public class SharedComponentMenuItem extends UIMenuItem { |
||||
public SharedComponentMenuItem(Action action) { |
||||
super(action); |
||||
setBackground(ColorConstants.BACKGROUND); |
||||
setUI(new SharedComponentMenuItemUI()); |
||||
setHorizontalAlignment(SwingConstants.LEFT); |
||||
setVerticalAlignment(SwingConstants.CENTER); |
||||
setBorder(BorderFactory.createEmptyBorder()); |
||||
setIcon(null); |
||||
setIconTextGap(4); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
Dimension dimension = super.getPreferredSize(); |
||||
return new Dimension(dimension.width, dimension.height + 8); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getMinimumSize() { |
||||
return new Dimension(0, 0); |
||||
} |
||||
|
||||
@Override |
||||
public Insets getInsets() { |
||||
return new Insets(0, 0, 0, 0); |
||||
} |
||||
|
||||
@Override |
||||
public String getText() { |
||||
return super.getText().trim(); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.mainframe.share.ui.actions; |
||||
|
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.gui.imenu.UIMenuItem; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2021/10/20 |
||||
*/ |
||||
public abstract class SharedComponentPopupAction extends UpdateAction { |
||||
@Override |
||||
public UIMenuItem createMenuItem() { |
||||
Object object = this.getValue(SharedComponentMenuItem.class.getName()); |
||||
if (object == null) { |
||||
SharedComponentMenuItem menuItem = newSharedComponentMenuItem(); |
||||
// 设置名字用作单元测
|
||||
menuItem.setName(getName()); |
||||
setPressedIcon4Button(menuItem); |
||||
setDisabledIcon4Button(menuItem); |
||||
object = menuItem; |
||||
|
||||
this.putValue(SharedComponentMenuItem.class.getName(), object); |
||||
} |
||||
return (SharedComponentMenuItem) object; |
||||
} |
||||
|
||||
protected SharedComponentMenuItem newSharedComponentMenuItem() { |
||||
return new SharedComponentMenuItem(this); |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.design.mainframe.share.ui.actions; |
||||
|
||||
import com.fr.design.gui.imenu.UIPopupMenu; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import java.awt.Dimension; |
||||
import java.awt.Insets; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 1.0 |
||||
* Created by Starryi on 2021/10/20 |
||||
*/ |
||||
public class SharedComponentPopupMenu extends UIPopupMenu { |
||||
public SharedComponentPopupMenu() { |
||||
setBorder(BorderFactory.createEmptyBorder()); |
||||
setRadius(2); |
||||
} |
||||
|
||||
@Override |
||||
public Insets getInsets() { |
||||
return new Insets(2, 2, 2, 2); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension getMinimumSize() { |
||||
Dimension dimension = super.getMinimumSize(); |
||||
dimension.width = 0; |
||||
dimension.height = 0; |
||||
return dimension; |
||||
} |
||||
} |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 49 KiB |
Loading…
Reference in new issue