本文整理汇总了Java中com.codename1.ui.Label类的典型用法代码示例。如果您正苦于以下问题:Java Label类的具体用法?Java Label怎么用?Java Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Label类属于com.codename1.ui包,在下文中一共展示了Label类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getComponentRegistry
import com.codename1.ui.Label; //导入依赖的package包/类
static Hashtable getComponentRegistry() {
if(componentRegistry == null) {
componentRegistry = new Hashtable();
componentRegistry.put("Button", Button.class);
componentRegistry.put("Calendar", com.codename1.ui.Calendar.class);
componentRegistry.put("CheckBox", CheckBox.class);
componentRegistry.put("ComboBox", ComboBox.class);
componentRegistry.put("Container", Container.class);
componentRegistry.put("Dialog", Dialog.class);
componentRegistry.put("Form", Form.class);
componentRegistry.put("Label", Label.class);
componentRegistry.put("List", List.class);
componentRegistry.put("RadioButton", RadioButton.class);
componentRegistry.put("Slider", Slider.class);
componentRegistry.put("Tabs", Tabs.class);
componentRegistry.put("TextArea", TextArea.class);
componentRegistry.put("TextField", TextField.class);
componentRegistry.put("EmbeddedContainer", EmbeddedContainer.class);
}
return componentRegistry;
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:UIBuilder.java
示例2: show
import com.codename1.ui.Label; //导入依赖的package包/类
public static void show(String text, final Form f)
{
isVisible = true;
f.getLayeredPane().setLayout(new BorderLayout());
final Label l = new Label(text);
l.setUIID("ToastMessage");
f.getLayeredPane().addComponent(BorderLayout.SOUTH, l);
f.repaint();
Timer exitTimer = new Timer();
exitTimer.schedule(new TimerTask() {
@Override
public void run() {
f.getLayeredPane().removeAll();
f.repaint();
isVisible = false;
}
}, toastTimeOut);
}
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:21,代码来源:ToastView.java
示例3: wrap
import com.codename1.ui.Label; //导入依赖的package包/类
protected Form wrap(String title, Component c){
c.getStyle().setBgColor(0xff0000);
Form f = new Form(title);
f.setLayout(new BorderLayout());
if (isDrawOnMutableImage()) {
int dispW = Display.getInstance().getDisplayWidth();
int dispH = Display.getInstance().getDisplayHeight();
Image img = Image.createImage((int)(dispW * 0.8), (int)(dispH * 0.8), 0x0);
Graphics g = img.getGraphics();
c.setWidth((int)(dispW * 0.8));
c.setHeight((int)(dispH * 0.8));
c.paint(g);
f.addComponent(BorderLayout.CENTER, new Label(img));
} else {
f.addComponent(BorderLayout.CENTER, c);
}
return f;
}
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:20,代码来源:AbstractDemoChart.java
示例4: createImageButton
import com.codename1.ui.Label; //导入依赖的package包/类
Button createImageButton(final long imageId, final Container grid, final int offset) {
final Button btn = new Button(URLImage.createToFileSystem(placeholder, FileSystemStorage.getInstance().getAppHomePath() + "/Thumb_" + imageId, THUMB_URL_PREFIX + imageId, URLImage.RESIZE_SCALE_TO_FILL));
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
imageList.setSelectedIndex(offset);
final Container viewerParent = new Container(new LayeredLayout());
ImageViewer viewer = new ImageViewer(imageList.getItemAt(offset));
viewerParent.addComponent(viewer);
Container parent = new Container(new BorderLayout());
viewerParent.addComponent(parent);
parent.addComponent(BorderLayout.SOUTH, createToolbar(imageId));
likeCount = new Label("");
parent.addComponent(BorderLayout.NORTH, likeCount);
viewer.setImageList(imageList);
grid.getParent().replace(grid, viewerParent, CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 300));
Display.getInstance().getCurrent().setBackCommand(createBackCommand(viewerParent, grid));
}
});
return btn;
}
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:24,代码来源:PhotoShare.java
示例5: createDemo
import com.codename1.ui.Label; //导入依赖的package包/类
public Container createDemo() {
Container input = new Container(new BoxLayout(BoxLayout.Y_AXIS));
input.addComponent(new Label("Text Field"));
input.addComponent(new TextField("Hi World"));
input.addComponent(new Label("Text Field With Hint"));
TextField hint = new TextField();
hint.setHint("Hint");
input.addComponent(hint);
input.addComponent(new Label("Multi-Line Text Field"));
TextField multi = new TextField();
multi.setSingleLineTextArea(false);
multi.setRows(4);
multi.setColumns(20);
input.addComponent(multi);
return input;
}
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:17,代码来源:Input.java
示例6: wrapInShelves
import com.codename1.ui.Label; //导入依赖的package包/类
/**
* This method wraps the layout in a way so the shelves are rendered underneath the
* given component
*/
private Container wrapInShelves(Container c) {
Container layered = new Container(new LayeredLayout());
Container sides = new Container(new BorderLayout());
Label right = new Label(" ");
right.setUIID("Right");
sides.addComponent(BorderLayout.EAST, right);
Label left = new Label(" ");
left.setUIID("Left");
sides.addComponent(BorderLayout.WEST, left);
layered.addComponent(sides);
layered.addComponent(c);
return layered;
}
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:20,代码来源:KitchenSink.java
示例7: getVideoComponent
import com.codename1.ui.Label; //导入依赖的package包/类
@Override
public Component getVideoComponent() {
if (component == null) {
if(uri != null) {
moviePlayerPeer = nativeInstance.createVideoComponent(uri, onCompletionCallbackId);
nativeInstance.setNativeVideoControlsEmbedded(moviePlayerPeer, embedNativeControls);
component = PeerComponent.create(new long[] { nativeInstance.getVideoViewPeer(moviePlayerPeer) });
} else {
try {
byte[] data = toByteArray(stream);
Util.cleanup(stream);
moviePlayerPeer = nativeInstance.createVideoComponent(data, onCompletionCallbackId);
component = PeerComponent.create(new long[] { nativeInstance.getVideoViewPeer(moviePlayerPeer) });
} catch (IOException ex) {
ex.printStackTrace();
return new Label("Error loading video " + ex);
}
}
}
return component;
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:IOSImplementation.java
示例8: assertLabelsActionPerformed
import com.codename1.ui.Label; //导入依赖的package包/类
private void assertLabelsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_assertLabelsActionPerformed
Form f = Display.getInstance().getCurrent();
visitComponents(f.getContentPane(), new ComponentVisitor() {
public void visit(Component c) {
if(c instanceof com.codename1.ui.Label) {
com.codename1.ui.Label lbl = (com.codename1.ui.Label)c;
String labelText = "null";
if(lbl.getText() != null) {
labelText = "\"" + lbl.getText().replace("\n", "\\n") + "\"";
}
if(lbl.getName() != null) {
generatedCode += " assertLabel(" + getPathOrName(lbl) + ", " + labelText + ");\n";
} else {
generatedCode += " assertLabel(" + labelText + ");\n";
}
}
}
});
updateTestCode();
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:21,代码来源:TestRecorder.java
示例9: getPicture
import com.codename1.ui.Label; //导入依赖的package包/类
/**
* Gets the picture of the given facebook object id
*
* @param id the object id to query
* @param label place the image on the given label as an icon
* @param toScale scale the image to the given dimension
* @param tempStorage if true place the image in a temp storage
*/
public void getPicture(String id, final Label label, Dimension toScale, boolean tempStorage) throws IOException {
checkAuthentication();
FacebookRESTService fb = new FacebookRESTService(token, id, FacebookRESTService.PICTURE, false);
if(toScale != null){
fb.addArgument("width", "" + toScale.getWidth());
fb.addArgument("height", "" + toScale.getHeight());
}else{
fb.addArgument("type", "small");
}
String cacheKey = id;
//check if this image is a temporarey resource and it is not saved
//already has a permanent image
if (tempStorage && !Storage.getInstance().exists(id)) {
cacheKey = TEMP_STORAGE + id;
}
ImageDownloadService.createImageToStorage(fb.requestURL(), label, cacheKey, toScale);
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:27,代码来源:FaceBookAccess.java
示例10: getComponentValue
import com.codename1.ui.Label; //导入依赖的package包/类
/**
* Returns the value of the given component, this can be overriden to add support for custom built components
*
* @param cmp the component
* @return the object value
*/
protected Object getComponentValue(Component cmp) {
if(cmp instanceof InputComponent) {
cmp = ((InputComponent)cmp).getEditor();
}
if(cmp instanceof TextArea) {
return ((TextArea)cmp).getText();
}
if(cmp instanceof Picker) {
((Picker)cmp).getValue();
}
if(cmp instanceof RadioButton || cmp instanceof CheckBox) {
if(((Button)cmp).isSelected()) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
if(cmp instanceof Label) {
return ((Label)cmp).getText();
}
if(cmp instanceof List) {
return ((List)cmp).getSelectedItem();
}
return null;
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:31,代码来源:Validator.java
示例11: collapseNode
import com.codename1.ui.Label; //导入依赖的package包/类
private void collapseNode(Component c, Transition t) {
Container lead = c.getParent().getLeadParent();
if(lead != null) {
c = lead;
}
c.putClientProperty(KEY_EXPANDED, null);
setNodeIcon(folder, c);
Container p = c.getParent();
for(int iter = 0 ; iter < p.getComponentCount() ; iter++) {
if(p.getComponentAt(iter) != c) {
Label dummy = new Label();
p.replaceAndWait(p.getComponentAt(iter), dummy, t, true);
p.removeComponent(dummy);
}
}
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:Tree.java
示例12: findComponentsOfInterest
import com.codename1.ui.Label; //导入依赖的package包/类
private void findComponentsOfInterest(Component cmp, ArrayList dest) {
if(cmp instanceof Container) {
Container c = (Container)cmp;
int count = c.getComponentCount();
for(int iter = 0 ; iter < count ; iter++) {
findComponentsOfInterest(c.getComponentAt(iter), dest);
}
return;
}
// performance optimization for fixed images in lists
if(cmp.getName() != null) {
if(cmp instanceof Label) {
Label l = (Label)cmp;
if(l.getName().toLowerCase().endsWith("fixed") && l.getIcon() != null) {
l.getIcon().lock();
}
dest.add(cmp);
return;
}
if(cmp instanceof TextArea) {
dest.add(cmp);
return;
}
}
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:26,代码来源:GenericListCellRenderer.java
示例13: addQuote
import com.codename1.ui.Label; //导入依赖的package包/类
/**
* Adds a quote according to the current quote count
*
* @param quoteElement The quote element (TAG_Q)
* @param curAlign The current horizontal alignment
*/
private void addQuote(HTMLElement quoteElement, int curAlign,boolean isStartTag) {
String quote=null;
int quoteNum=isStartTag?0:1; // 0 is the start tag of primary tag and 1 its closing tag. 2 is the start of secondary tag and 3 the closing tag (Used for CSS_QUOTES)
if (quoteTagCount==0) {
quote="\"";
} else {
quote="'";
quoteNum+=2;
}
if ((FIXED_WIDTH) && (width-x<font.stringWidth(quote))) {
newLine(curAlign);
}
Label quoteLabel=addString(quote, curAlign);
quoteLabel.putClientProperty(CLIENT_PROPERTY_QUOTE, new Integer(quoteNum));
if (loadCSS) {
quoteElement.addAssociatedComponent(quoteLabel);
}
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:26,代码来源:HTMLComponent.java
示例14: setWrapRecursive
import com.codename1.ui.Label; //导入依赖的package包/类
/**
* Sets this element and all children to have wrapped text.
* In cases where text is already wrapped no change will be made.
* This will work only in FIXED_WIDTH mode (Checked before called)
* Technically all this logic can be found in HTMLComponent.showText, but since we don't want to get into
* the context of this element (i.e. what was the indentation, alignment etc.), we use this algorithm.
*
* @param element The element to apply text wrapping on
* @param htmlC The HTMLComponent
*/
private void setWrapRecursive(HTMLElement element,HTMLComponent htmlC) {
if (element.isTextElement()) {
String text=element.getText();
final Vector ui=element.getUi();
if ((text!=null) && (ui!=null) && (ui.size()==1)) { //If it's already wrapped, no need to process
final Vector words=htmlC.getWords(text, Component.LEFT, false);
final Label label=(Label)ui.elementAt(0);
setWrapText(label, words, element,htmlC);
}
}
for(int i=0;i<element.getNumChildren();i++) {
setWrapRecursive((HTMLElement)element.getChildAt(i),htmlC);
}
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:27,代码来源:CSSEngine.java
示例15: setWordSpacingRecursive
import com.codename1.ui.Label; //导入依赖的package包/类
/**
* Sets the given spacing to all words in this component and its children
*
* @param cmp The component to set the spacing on
* @param spacing The spacing in pixels
*/
private void setWordSpacingRecursive(Component cmp,int spacing) {
if (cmp instanceof Container) {
Container cont=(Container)cmp;
for(int i=0;i<cont.getComponentCount();i++) {
setWordSpacingRecursive(cont.getComponentAt(i), spacing);
}
} else if ((cmp instanceof Label) &&
(cmp.getParent().getComponentIndex(cmp)<cmp.getParent().getComponentCount()-1)) { // don't apply to the last word
cmp.getUnselectedStyle().setPadding(Component.RIGHT, spacing);
if (cmp instanceof HTMLLink) {
cmp.getSelectedStyle().setPadding(Component.RIGHT, spacing);
((HTMLLink)cmp).getPressedStyle().setPadding(Component.RIGHT, spacing);
}
}
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:CSSEngine.java
示例16: setLineHeightRecursive
import com.codename1.ui.Label; //导入依赖的package包/类
/**
* Sets the given spacing to all words in this component and its children
*
* @param cmp The component to set the spacing on
* @param halfHeight Half of the line height in pixels (will be added to top and bottom margins to make for a full height)
*/
private void setLineHeightRecursive(Component cmp,int halfHeight) {
if (cmp instanceof Container) {
Container cont=(Container)cmp;
for(int i=0;i<cont.getComponentCount();i++) {
setLineHeightRecursive(cont.getComponentAt(i), halfHeight);
}
} else if (cmp instanceof Label) {
cmp.getUnselectedStyle().setMargin(Component.TOP, halfHeight);
cmp.getUnselectedStyle().setMargin(Component.BOTTOM, halfHeight);
if (cmp instanceof HTMLLink) {
cmp.getSelectedStyle().setPadding(Component.TOP, halfHeight);
cmp.getSelectedStyle().setPadding(Component.BOTTOM, halfHeight);
((HTMLLink)cmp).getPressedStyle().setPadding(Component.TOP, halfHeight);
((HTMLLink)cmp).getPressedStyle().setPadding(Component.BOTTOM, halfHeight);
}
}
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:24,代码来源:CSSEngine.java
示例17: setTextDecorationRecursive
import com.codename1.ui.Label; //导入依赖的package包/类
/**
* Sets the specified decoration to the specified components and all of its Label descendants
*
* @param cmp The component to apply the decoration to
* @param decoration The deocration (One of Style.TEXT_DECORATION_* constants)
* @param selector The selector with the text direction directive
*/
private void setTextDecorationRecursive(Component cmp,int decoration,CSSElement selector) {
if (cmp instanceof Container) {
Container cont=(Container)cmp;
for(int i=0;i<cont.getComponentCount();i++) {
setTextDecorationRecursive(cont.getComponentAt(i), decoration,selector);
}
} else if (cmp instanceof Label) {
int styles=getApplicableStyles(cmp, selector);
if ((styles & STYLE_UNSELECTED)!=0) {
applyDecorationOnStyle(cmp.getUnselectedStyle(),decoration);
}
if ((styles & STYLE_SELECTED)!=0) {
applyDecorationOnStyle(cmp.getSelectedStyle(),decoration);
}
if ((styles & STYLE_PRESSED)!=0) {
applyDecorationOnStyle(((HTMLLink)cmp).getPressedStyle(),decoration);
}
}
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:27,代码来源:CSSEngine.java
示例18: removeTextDecorationRecursive
import com.codename1.ui.Label; //导入依赖的package包/类
/**
* Removes all text decorations from the specified components and its Label descendants
* This will be used for {text-decoration: none}
*
* @param cmp The component to remove decorations from
* @param selector The selector with the text direction directive
*/
private void removeTextDecorationRecursive(Component cmp,CSSElement selector) {
if (cmp instanceof Container) {
Container cont=(Container)cmp;
for(int i=0;i<cont.getComponentCount();i++) {
removeTextDecorationRecursive(cont.getComponentAt(i),selector);
}
} else if (cmp instanceof Label) {
int styles=getApplicableStyles(cmp, selector);
if ((styles & STYLE_UNSELECTED)!=0) {
cmp.getUnselectedStyle().setTextDecoration(Style.TEXT_DECORATION_NONE);
}
if ((styles & STYLE_SELECTED)!=0) {
cmp.getSelectedStyle().setTextDecoration(Style.TEXT_DECORATION_NONE);
}
if ((styles & STYLE_PRESSED)!=0) {
((HTMLLink)cmp).getPressedStyle().setTextDecoration(Style.TEXT_DECORATION_NONE);
}
}
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:27,代码来源:CSSEngine.java
示例19: findLabelText
import com.codename1.ui.Label; //导入依赖的package包/类
/**
* Finds a component with the given name, works even with UI's that weren't created with the GUI builder
* @param text the text of the label/button
* @return the component with the given label text within the tree
*/
private static Label findLabelText(Container root, String text) {
if(verbose) {
log("findLabelText(" + root + ", " + text + ")");
}
int count = root.getComponentCount();
for(int iter = 0 ; iter < count ; iter++) {
Component c = root.getComponentAt(iter);
if(c instanceof Label) {
String n = ((Label)c).getText();
if(n != null && n.equals(text)) {
return (Label)c;
}
continue;
}
if(c instanceof Container) {
Label l = findLabelText((Container)c, text);
if(l != null) {
return l;
}
}
}
return null;
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:29,代码来源:TestUtils.java
示例20: createRendererContainer
import com.codename1.ui.Label; //导入依赖的package包/类
private Container createRendererContainer() {
Container entries = new Container(new BoxLayout(BoxLayout.Y_AXIS));
entries.setUIID("RSSEntry");
Label title = new Label();
title.setName("title");
title.setUIID("RSSTitle");
entries.addComponent(title);
TextArea description = new TextArea(2, 30);
description.setGrowByContent(false);
description.setName("details");
description.setUIID("RSSDescription");
description.setScrollVisible(false);
entries.addComponent(description);
if(iconPlaceholder != null) {
Container wrap = new Container(new BorderLayout());
wrap.addComponent(BorderLayout.CENTER, entries);
Label icon = new Label();
icon.setIcon(iconPlaceholder);
icon.setUIID("RSSIcon");
icon.setName("icon");
wrap.addComponent(BorderLayout.WEST, icon);
entries = wrap;
}
return entries;
}
开发者ID:codenameone,项目名称:CodenameOne,代码行数:26,代码来源:RSSReader.java
注:本文中的com.codename1.ui.Label类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论