本文整理匯總了Java中com.codename1.components.SpanButton類的典型用法代碼示例。如果您正苦於以下問題:Java SpanButton類的具體用法?Java SpanButton怎麽用?Java SpanButton使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SpanButton類屬於com.codename1.components包,在下文中一共展示了SpanButton類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addActionListener
import com.codename1.components.SpanButton; //導入依賴的package包/類
/**
* Adds action listener to applicable components in found set. Currently this will apply to
* Buttons, Lists, Sliders, TextAreas, OnOffSwitches, SpanButtons, and subclasses thereof.
* @param l
* @return
*/
public ComponentSelector addActionListener(ActionListener l) {
for (Component c : this) {
if (c instanceof Button) {
((Button)c).addActionListener(l);
} else if (c instanceof com.codename1.ui.List) {
((com.codename1.ui.List)c).addActionListener(l);
} else if (c instanceof Slider) {
((Slider)c).addActionListener(l);
} else if (c instanceof TextArea) {
((TextArea)c).addActionListener(l);
} else if (c instanceof OnOffSwitch) {
((OnOffSwitch)c).addActionListener(l);
} else if (c instanceof SpanButton) {
((SpanButton)c).addActionListener(l);
}
}
return this;
}
示例2: createNode
import com.codename1.components.SpanButton; //導入依賴的package包/類
/**
* Creates a node within the tree, this method is protected allowing tree to be
* subclassed to replace the rendering logic of individual tree buttons.
*
* @param node the node object from the model to display on the button
* @param depth the depth within the tree (normally represented by indenting the entry)
* @return a button representing the node within the tree
*/
protected Component createNode(Object node, int depth) {
if(multilineMode) {
SpanButton cmp = new SpanButton(childToDisplayLabel(node));
cmp.setUIID("TreeNode");
cmp.setTextUIID("TreeNode");
if(model.isLeaf(node)) {
cmp.setIcon(nodeImage);
} else {
cmp.setIcon(folder);
}
updateNodeComponentStyle(cmp.getSelectedStyle(), depth);
updateNodeComponentStyle(cmp.getUnselectedStyle(), depth);
updateNodeComponentStyle(cmp.getPressedStyle(), depth);
return cmp;
}
return createNodeComponent(node, depth);
}
示例3: setMaterialIcon
import com.codename1.components.SpanButton; //導入依賴的package包/類
/**
* Helper method that generalizes icon setting code for various component types
* @param cmp the component, currently supports Labels, MultiButton & SpanButton. If the type isn't supported
* this method return false
* @param icon the material icon
* @param size the size of the icon
* @return false if the type isn't supported
*/
public static boolean setMaterialIcon(Component cmp, char icon, float size) {
if(cmp instanceof Label) {
setMaterialIcon((Label)cmp, icon, size);
return true;
}
if(cmp instanceof MultiButton) {
setMaterialIcon((MultiButton)cmp, icon, size);
return true;
}
if(cmp instanceof SpanButton) {
setMaterialIcon((SpanButton)cmp, icon, size);
return true;
}
return false;
}
示例4: respond
import com.codename1.components.SpanButton; //導入依賴的package包/類
private void respond(Message m) {
String clientId = (String)Display.getInstance().getCurrent().getClientProperty("cid");
EncodedImage rounded = getRoundedFriendImage(m.getSenderId(), m.getPicture());
if(clientId == null || !clientId.equals(m.getSenderId())) {
// show toast, we aren't in the chat form...
InteractionDialog toast = new InteractionDialog();
toast.setUIID("Container");
toast.setLayout(new BorderLayout());
SpanButton messageButton = new SpanButton(m.getMessage());
messageButton.setIcon(rounded);
toast.addComponent(BorderLayout.CENTER, messageButton);
int h = toast.getPreferredH();
toast.show(Display.getInstance().getDisplayHeight() - h - 10, 10, 10, 10);
UITimer uit = new UITimer(() -> {
toast.dispose();
});
uit.schedule(3000, false, Display.getInstance().getCurrent());
messageButton.addActionListener((e) -> {
uit.cancel();
toast.dispose();
showChatForm(getContactById(m.getSenderId()), Display.getInstance().getCurrent());
});
} else {
Container chatArea = getChatArea(Display.getInstance().getCurrent().getContentPane());
respond(chatArea, m.getMessage(), rounded);
}
}
示例5: setText
import com.codename1.components.SpanButton; //導入依賴的package包/類
/**
* Sets the text on all components in found set that support this. Currently this works with
* Label, TextArea, SpanLabel, and SpanButtons, and subclasses thereof.
* @param text The text to set in the componnet.
* @return
*/
public ComponentSelector setText(String text) {
for (Component c : this) {
if (c instanceof Label) {
((Label)c).setText(text);
} else if (c instanceof TextArea) {
((TextArea)c).setText(text);
} else if (c instanceof SpanLabel) {
((SpanLabel)c).setText(text);
} else if (c instanceof SpanButton) {
((SpanButton)c).setText(text);
}
}
return this;
}
示例6: getText
import com.codename1.components.SpanButton; //導入依賴的package包/類
/**
* Gets the text on the first component in this set that supports this property. Currently this works with
* Label, TextArea, SpanLabel, and SpanButtons, and subclasses thereof.
* @return
*/
public String getText() {
for (Component c : this) {
if (c instanceof Label) {
return ((Label)c).getText();
} else if (c instanceof TextArea) {
return ((TextArea)c).getText();
} else if (c instanceof SpanLabel) {
return ((SpanLabel)c).getText();
} else if (c instanceof SpanButton) {
return ((SpanButton)c).getText();
}
}
return null;
}
示例7: setIcon
import com.codename1.components.SpanButton; //導入依賴的package包/類
/**
* Sets the icon for components in found set. Only relevant to Labels, SpanLabels, and SpanButtons, and subclasses thereof.
* @param icon
* @return
*/
public ComponentSelector setIcon(Image icon) {
for (Component c : this) {
if (c instanceof Label) {
((Label)c).setIcon(icon);
} else if (c instanceof SpanLabel) {
((SpanLabel)c).setIcon(icon);
} else if (c instanceof SpanButton) {
((SpanButton)c).setIcon(icon);
}
}
return this;
}
示例8: bindNodeListener
import com.codename1.components.SpanButton; //導入依賴的package包/類
/**
* Since a node may be any component type developers should override this method to
* add support for binding the click listener to the given component.
* @param l listener interface
* @param node node component returned by createNode
*/
protected void bindNodeListener(ActionListener l, Component node) {
if(node instanceof Button) {
((Button)node).addActionListener(l);
return;
}
((SpanButton)node).addActionListener(l);
}
示例9: setNodeIcon
import com.codename1.components.SpanButton; //導入依賴的package包/類
/**
* Sets the icon for the given node similar in scope to bindNodeListener
* @param icon the icon for the node
* @param node the node instance
*/
protected void setNodeIcon(Image icon, Component node) {
if(node instanceof Button) {
((Button)node).setIcon(icon);
return;
}
((SpanButton)node).setIcon(icon);
}