use of com.codename1.ui.events.ActionListener in project CodenameOne by codenameone.
the class MultiButton method setCheckBox.
/**
* Turns the multi-button into a checkbox multi-button
*
* @param b true for a checkbox multi-button
*/
public void setCheckBox(boolean b) {
if (b != isCheckBox()) {
Container par = emblem.getParent();
Button old = emblem;
if (b) {
emblem = new CheckBox();
} else {
emblem = new Button();
}
emblem.setUIID(old.getUIID());
emblem.setName(old.getName());
java.util.List actionListeners = (java.util.List) old.getListeners();
if (actionListeners != null) {
for (int iter = 0; iter < actionListeners.size(); iter++) {
emblem.addActionListener((ActionListener) actionListeners.get(iter));
}
}
if (old.getCommand() != null) {
Image img = old.getIcon();
emblem.setCommand(old.getCommand());
emblem.setText("");
emblem.setIcon(img);
} else {
emblem.setText(old.getText());
if (old.getIcon() != null) {
emblem.setIcon(old.getIcon());
}
}
par.replace(old, emblem, null);
setLeadComponent(emblem);
}
}
use of com.codename1.ui.events.ActionListener in project CodenameOne by codenameone.
the class MultiButton method setRadioButton.
/**
* Turns the multi-button into a radio multi-button
*
* @param b true for a radio multi-button
*/
public void setRadioButton(boolean b) {
if (b != isRadioButton()) {
Container par = emblem.getParent();
Button old = emblem;
if (b) {
emblem = new RadioButton();
if (group != null) {
((RadioButton) emblem).setGroup(group);
}
} else {
emblem = new Button();
}
emblem.setName(old.getName());
emblem.setUIID(old.getUIID());
java.util.List actionListeners = (java.util.List) old.getListeners();
if (actionListeners != null) {
for (int iter = 0; iter < actionListeners.size(); iter++) {
emblem.addActionListener((ActionListener) actionListeners.get(iter));
}
}
if (old.getCommand() != null) {
Image img = old.getIcon();
emblem.setCommand(old.getCommand());
emblem.setText("");
emblem.setIcon(img);
}
par.replace(old, emblem, null);
setLeadComponent(emblem);
emblem.setShowEvenIfBlank(true);
}
}
use of com.codename1.ui.events.ActionListener in project CodenameOne by codenameone.
the class OnOffSwitch method initialize.
private void initialize() {
iosMode = UIManager.getInstance().isThemeConstant("onOffIOSModeBool", false);
removeAll();
setFocusable(true);
if (iosMode) {
button = null;
switchMaskImage = UIManager.getInstance().getThemeImageConstant("switchMaskImage");
switchOnImage = UIManager.getInstance().getThemeImageConstant("switchOnImage");
switchOffImage = UIManager.getInstance().getThemeImageConstant("switchOffImage");
noTextMode = UIManager.getInstance().isThemeConstant("noTextModeBool", false);
} else {
setLayout(new BoxLayout(BoxLayout.Y_AXIS));
button = new CheckBox(on);
button.setToggle(true);
button.setUIID("Button");
button.setEndsWith3Points(false);
button.getUnselectedStyle().setFont(getUnselectedStyle().getFont());
button.getSelectedStyle().setFont(getSelectedStyle().getFont());
button.getPressedStyle().setFont(getSelectedStyle().getFont());
Dimension d = button.getPreferredSize();
button.setText(off);
int pw = button.getPreferredW();
d.setWidth(Math.max(pw, d.getWidth()));
// prevents the button from growing/shrinking as its states flip
button.setPreferredSize(d);
buttonWidth = button.getPreferredW();
button.setFocusable(false);
updateButton();
addComponent(button);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
flip();
}
});
}
}
use of com.codename1.ui.events.ActionListener in project CodenameOne by codenameone.
the class Ads method setAd.
/**
* HTML ad received from the server
* @param ad the ad to set
*/
public void setAd(String ad) {
HTMLComponent html = new HTMLComponent(new AsyncDocumentRequestHandlerImpl() {
protected ConnectionRequest createConnectionRequest(DocumentInfo docInfo, IOCallback callback, Object[] response) {
ConnectionRequest req = super.createConnectionRequest(docInfo, callback, response);
req.setFailSilently(true);
req.addResponseCodeListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// do nothing, just make sure the html won't throw an error
}
});
return req;
}
});
html.setSupressExceptions(true);
html.setHTMLCallback(this);
html.setBodyText("<html><body><div align='center'>" + ad + "</div></body></html>");
replace(getComponentAt(0), html, null);
revalidate();
html.setPageUIID("Container");
html.getStyle().setBgTransparency(0);
}
use of com.codename1.ui.events.ActionListener in project CodenameOne by codenameone.
the class FloatingActionButton method released.
@Override
public void released(int x, int y) {
super.released(x, y);
if (current != null) {
current.dispose();
current = null;
}
// if this fab has sub fab's display them
if (subMenu != null) {
final Container con = createPopupContent(subMenu);
Dialog d = new Dialog();
d.setDialogUIID("Container");
d.getContentPane().setUIID("Container");
d.setLayout(new BorderLayout());
d.add(BorderLayout.CENTER, con);
for (FloatingActionButton next : subMenu) {
next.current = d;
}
d.setTransitionInAnimator(CommonTransitions.createEmpty());
d.setTransitionOutAnimator(CommonTransitions.createEmpty());
for (Component c : con) {
c.setVisible(false);
}
Form f = getComponentForm();
int oldTint = f.getTintColor();
f.setTintColor(0);
d.setBlurBackgroundRadius(-1);
d.addShowListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
for (Component c : con) {
c.setY(con.getHeight());
c.setVisible(true);
}
con.animateLayout(200);
}
});
showPopupDialog(d);
f.setTintColor(oldTint);
for (FloatingActionButton next : subMenu) {
next.remove();
}
con.removeAll();
}
}
Aggregations