You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
package com.tptj.tool.hg.fineui.swing.element; |
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
import javax.swing.*; |
|
import java.awt.event.ActionEvent; |
|
import java.awt.event.ActionListener; |
|
|
|
/** |
|
* @author 秃破天际 |
|
* @version 10.0 |
|
* Created by 秃破天际 on 2021/10/29 |
|
**/ |
|
public class ButtonElement extends AbstractSingleElement<JButton> { |
|
|
|
public ButtonElement() { |
|
super(new JButton()); |
|
getComponent().addActionListener(new ActionListener() { |
|
@Override |
|
public void actionPerformed(ActionEvent e) { |
|
callJsMethod("fireEvent", "EVENT_CHANGE", getComponent().getText()); |
|
} |
|
}); |
|
} |
|
|
|
@Override |
|
public Object getVal() { |
|
return getComponent().getText(); |
|
} |
|
|
|
@Override |
|
public void setVal(Object val) { |
|
super.setVal(val); |
|
getComponent().setText(GeneralUtils.objectToString(val)); |
|
} |
|
|
|
@Override |
|
public void css(String name, String val) { |
|
super.css(name, val); |
|
val = val.toUpperCase(); |
|
if ("text-align".equals(name)) { |
|
if ("LEFT".equals(val)) { |
|
getComponent().setHorizontalAlignment(SwingConstants.LEFT); |
|
} else if ("CENTER".equals(val)) { |
|
getComponent().setHorizontalAlignment(SwingConstants.CENTER); |
|
} else if ("RIGHT".equals(val)) { |
|
getComponent().setHorizontalAlignment(SwingConstants.RIGHT); |
|
} |
|
} |
|
} |
|
}
|
|
|