|
|
|
@ -3,8 +3,7 @@ package com.fr.design.gui.ibutton;
|
|
|
|
|
import javax.swing.Icon; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
import java.util.function.Consumer; |
|
|
|
|
|
|
|
|
|
import static com.fine.theme.utils.FineClientProperties.BUTTON_BORDER; |
|
|
|
@ -33,8 +32,8 @@ public class UICombinationButton extends JPanel {
|
|
|
|
|
protected UIButton rightButton; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Consumer<MouseEvent> leftClickLister; |
|
|
|
|
private Consumer<MouseEvent> rightClickLister; |
|
|
|
|
private Consumer<ActionEvent> leftClickLister; |
|
|
|
|
private Consumer<ActionEvent> rightClickLister; |
|
|
|
|
|
|
|
|
|
protected void leftButtonClickEvent() { |
|
|
|
|
// 左边按钮点击事件
|
|
|
|
@ -54,7 +53,7 @@ public class UICombinationButton extends JPanel {
|
|
|
|
|
* |
|
|
|
|
* @param lister 监听 |
|
|
|
|
*/ |
|
|
|
|
public void addLeftClickLister(Consumer<MouseEvent> lister) { |
|
|
|
|
public void addLeftActionListener(Consumer<ActionEvent> lister) { |
|
|
|
|
this.leftClickLister = lister; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -63,7 +62,7 @@ public class UICombinationButton extends JPanel {
|
|
|
|
|
* |
|
|
|
|
* @param lister 监听 |
|
|
|
|
*/ |
|
|
|
|
public void addRightClickLister(Consumer<MouseEvent> lister) { |
|
|
|
|
public void addRightActionListener(Consumer<ActionEvent> lister) { |
|
|
|
|
this.rightClickLister = lister; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -73,25 +72,18 @@ public class UICombinationButton extends JPanel {
|
|
|
|
|
leftButton.putClientProperty(BUTTON_BORDER, BUTTON_BORDER_LEFT_ROUND_RECT); |
|
|
|
|
rightButton = right; |
|
|
|
|
rightButton.putClientProperty(BUTTON_BORDER, BUTTON_BORDER_RIGHT_ROUND_RECT); |
|
|
|
|
leftButton.addMouseListener(new MouseAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
if (leftClickLister != null) { |
|
|
|
|
leftClickLister.accept(e); |
|
|
|
|
} else { |
|
|
|
|
leftButtonClickEvent(); |
|
|
|
|
} |
|
|
|
|
leftButton.addActionListener(e -> { |
|
|
|
|
if (leftClickLister != null) { |
|
|
|
|
leftClickLister.accept(e); |
|
|
|
|
} else { |
|
|
|
|
leftButtonClickEvent(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
rightButton.addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
if (rightClickLister != null) { |
|
|
|
|
rightClickLister.accept(e); |
|
|
|
|
} else { |
|
|
|
|
rightButtonClickEvent(); |
|
|
|
|
} |
|
|
|
|
rightButton.addActionListener(e -> { |
|
|
|
|
if (rightClickLister != null) { |
|
|
|
|
rightClickLister.accept(e); |
|
|
|
|
} else { |
|
|
|
|
rightButtonClickEvent(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|