• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Component类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.codename1.ui.Component的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Component类属于com.codename1.ui包,在下文中一共展示了Component类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: selectListOffset

import com.codename1.ui.Component; //导入依赖的package包/类
private static void selectListOffset(Component c, int offset) {
    assertBool(c != null, "List not found");
    if(c instanceof List) {
        ((List)c).setSelectedIndex(offset);
        return;
    }
    if(c instanceof ContainerList) {
        ((ContainerList)c).setSelectedIndex(offset);
        return;
    }
    if(c instanceof GenericSpinner) {
        ((GenericSpinner)c).getModel().setSelectedIndex(offset);
        return;
    }
    assertBool(false, "Unsupported list type: " + c.getName());
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:TestUtils.java


示例2: calcPreferredValues

import com.codename1.ui.Component; //导入依赖的package包/类
private void calcPreferredValues(Component cmp) {
    if (tmpLaidOut.contains(cmp)) {
        return;
    }
    tmpLaidOut.add(cmp);
    LayeredLayoutConstraint constraint = (LayeredLayoutConstraint) getComponentConstraint(cmp);
    if (constraint != null) {
        constraint.fixDependencies(cmp.getParent());
        for (LayeredLayoutConstraint.Inset inset : constraint.insets) {
            if (inset.referenceComponent != null && inset.referenceComponent.getParent() == cmp.getParent()) {
                calcPreferredValues(inset.referenceComponent);
            }
            inset.calcPreferredValue(cmp.getParent(), cmp);
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:LayeredLayout.java


示例3: setState

import com.codename1.ui.Component; //导入依赖的package包/类
/**
 * Called when the form is created to set the current state.
 */
public void setState(Form f, Map state) {
    List list = getList(f);

    f.putClientProperty(list.getName()+"ScrollY", state.get(list.getName()+"ScrollY"));

    /**
     * On loading the view for the list, it animates a scroll to the selected position.
     * This position will overwrite the previous ScrollY position if the element is out-of-scope.
     *
     * @see UIBuilder.setContainerStateImpl(Container cnt, Hashtable state)
     */
    String cmpName = (String)state.get(StateMachine.FORM_STATE_KEY_FOCUS);
    if(cmpName != null) {
        Component c = ui.findByName(cmpName, f);
        if(c != null) {
            c.requestFocus();
            if(c instanceof List) {
                Integer i = (Integer)state.get(StateMachine.FORM_STATE_KEY_SELECTION);
                if(i != null) {
                    ((List)c).setSelectedIndex(i.intValue());
                }
            }
        }
    }
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:29,代码来源:ScrollableView.java


示例4: replace

import com.codename1.ui.Component; //导入依赖的package包/类
/**
 * Removes an existing component replacing it with the specified component.
 *
 * @param existingComponent the Component that should be removed and
 *        replaced with newComponent
 * @param newComponent the Component to put in existingComponents place
 * @throws IllegalArgumentException is either of the Components are null or
 *         if existingComponent is not being managed by this layout manager
 */
public void replace(Component existingComponent, Component newComponent) {
    if (existingComponent == null || newComponent == null) {
        throw new IllegalArgumentException("Components must be non-null");
    }
    // Make sure all the components have been registered, otherwise we may
    // not update the correct Springs.
    if (springsChanged) {
        registerComponents(horizontalGroup, HORIZONTAL);
        registerComponents(verticalGroup, VERTICAL);
    }
    ComponentInfo info = (ComponentInfo)componentInfos.
            remove(existingComponent);
    if (info == null) {
        throw new IllegalArgumentException("Component must already exist");
    }
    host.removeComponent(existingComponent);
    if (newComponent.getParent() != host) {
        host.addComponent(newComponent);
    }
    info.setComponent(newComponent);
    componentInfos.put(newComponent, info);
    invalidateHost();
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:33,代码来源:GroupLayout.java


示例5: addLayoutComponent

import com.codename1.ui.Component; //导入依赖的package包/类
public void addLayoutComponent(Object constraints, Component comp, Container c) {
    GridBagConstraints cons;
    if (constraints != null) {
        if (!(constraints instanceof GridBagConstraints)) {
            throw new IllegalArgumentException("AddLayoutComponent: constraint object must be GridBagConstraints"); //$NON-NLS-1$
        }
        cons = (GridBagConstraints) constraints;
    } else {
        if (comptable.containsKey(comp)) {
            //  don't replace constraints with default ones
            return;
        }
        cons = defaultConstraints;
    }
    /*try {
        //cons.verify();
    } catch (IllegalArgumentException e) {
        // awt.81=AddLayoutComponent: {0}
        throw new IllegalArgumentException("AddLayoutComponent: " + e.getMessage()); //$NON-NLS-1$
    }*/
    GridBagConstraints consClone = (GridBagConstraints) cons.clone();
    comptable.put(comp, consClone);
    Container parent = comp.getParent();
    updateParentInfo(parent, consClone);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:26,代码来源:GridBagLayout.java


示例6: ComponentSpring

import com.codename1.ui.Component; //导入依赖的package包/类
private ComponentSpring(Component component, int min, int pref,
        int max) {
    this.component = component;
    if (component == null) {
        throw new IllegalArgumentException(
                "Component must be non-null");
    }
    checkSize(min, pref, max, true);
    
    this.min = min;
    this.max = max;
    this.pref = pref;
    
    // getComponentInfo makes sure component is a child of the
    // Container GroupLayout is the LayoutManager for.
    getComponentInfo(component);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:18,代码来源:GroupLayout.java


示例7: getApplicableStyles

import com.codename1.ui.Component; //导入依赖的package包/类
/**
 * Returns a mask of the STYLE_* constants of which CodenameOne styles this selector should be applied to
 *
 * @param cmp The component in question
 * @param selector The selector
 * @return a mask of the STYLE_* constants of which CodenameOne styles this selector should be applied to
 */
private int getApplicableStyles(Component cmp,CSSElement selector) {
    int result=0;
    if (cmp instanceof HTMLLink) {
        int pseudoClass=selector.getSelectorPseudoClass();
        boolean done=false;
        if ((pseudoClass & CSSElement.PC_FOCUS)!=0) { // Focused (i.e. CSS focus/hover)
            result|=STYLE_SELECTED;
            done=true;
        }
        if ((pseudoClass & CSSElement.PC_ACTIVE)!=0) { // active in CSS means pressed in CodenameOne
            result|=STYLE_PRESSED;
            done=true;
        }

        if (!done) {
            result|=STYLE_SELECTED|STYLE_UNSELECTED;
        }
    } else {
            result|=STYLE_SELECTED|STYLE_UNSELECTED;
    }
    return result;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:30,代码来源:CSSEngine.java


示例8: findEmptyContainer

import com.codename1.ui.Component; //导入依赖的package包/类
private Container findEmptyContainer(Container c) {
    int count = c.getComponentCount();
    if(count == 0) {
        return c;
    }
    for(int iter = 0 ; iter < count ; iter++) {
        Component x = c.getComponentAt(iter);
        if(x instanceof Container) {
            Container current = findEmptyContainer((Container)x);
            if(current != null) {
                return current;
            }
        }
    }
    return null;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:UIBuilder.java


示例9: processAccessKey

import com.codename1.ui.Component; //导入依赖的package包/类
/**
 * Tries to assign the given key string as an access key to the specified component
 * The key string given here is a single key
 *
 * @param keyStr The string representing the key (either a character, a unicode escape sequence or a special key name
 * @param htmlC The HTMLComponent
 * @param ui The component to set the access key on
 * @param override If true overrides other keys assigned previously for this component
 * @return true if successful, false otherwise
 */
private boolean processAccessKey(String keyStr,HTMLComponent htmlC,Component ui,boolean override) {
    if (keyStr.startsWith("\\")) { // Unicode escape sequence, may be used to denote * and # which technically are illegal as values
        try {
            int keyCode=Integer.parseInt(keyStr.substring(1), 16);
            htmlC.addAccessKey((char)keyCode, ui, override);
            return true;
        } catch (NumberFormatException nfe) {
            return false;

        }
    } else if (keyStr.length()==1) {
        htmlC.addAccessKey(keyStr.charAt(0), ui, override);
        return true;
    } else { //special key shortcut
        if (specialKeys!=null) {
            Integer key=(Integer)specialKeys.get(keyStr);
            if (key!=null) {
                htmlC.addAccessKey(key.intValue(), ui, override);
                return true;
            }
        }
        return false;
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:35,代码来源:CSSEngine.java


示例10: launchAd

import com.codename1.ui.Component; //导入依赖的package包/类
private void launchAd() {
    Component c = getComponentAt(0);
    if (c instanceof HTMLComponent) {
        HTMLComponent h = (HTMLComponent) c;
        h.setSupressExceptions(true);
        HTMLElement dom = h.getDOM();
        Vector links = dom.getDescendantsByTagName("a");
        if (links.size() > 0) {
            HTMLElement e = (HTMLElement) links.elementAt(0);
            String link = e.getAttribute("href");
            if (link != null) {
                Display.getInstance().execute(link);
            }
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:Ads.java


示例11: wrap

import com.codename1.ui.Component; //导入依赖的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


示例12: refreshZoom

import com.codename1.ui.Component; //导入依赖的package包/类
void refreshZoom(Container solitairContainer) {
    int dpi =  DPIS[currentZoom / 5];
    Preferences.set("dpi", dpi);
    Preferences.set("zoom", currentZoom);
    try {
        cards = Resources.open("/gamedata.res",dpi);
        cardImageCache.clear();
        Image cardBack = getCardImage("card_back.png");
        for(Component c : solitairContainer) {
            CardComponent crd = (CardComponent)c;
            crd.setImages(getCardImage(crd.getCard().getFileName()), cardBack);
        }
        solitairContainer.revalidate();
        solitairContainer.getParent().replace(solitairContainer.getParent().getComponentAt(0), createPlacementContainer(solitairContainer), null);
    } catch(IOException e) {
        Log.e(e);
    }        
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:19,代码来源:Solitaire.java


示例13: paintShiftFadeHierarchy

import com.codename1.ui.Component; //导入依赖的package包/类
private void paintShiftFadeHierarchy(Container c, int alpha, Graphics g, boolean incoming) {
    int componentCount = c.getComponentCount();
    for(int iter = 0 ; iter < componentCount ; iter++) {
        Component current = c.getComponentAt(iter);
        if(current instanceof Container) {
            paintShiftFadeHierarchy((Container)current, alpha, g, incoming);
            continue;
        }
        g.setAlpha(alpha);
        Motion m = getComponentShiftMotion(current, incoming);
        if(m != null) {
            int tval = m.getValue();
            g.translate(tval, 0);
            current.paintComponent(g, false);
            g.translate(-tval, 0);
        }
        g.setAlpha(255);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:20,代码来源:CommonTransitions.java


示例14: addPreferredGap

import com.codename1.ui.Component; //导入依赖的package包/类
/**
 * Adds an element representing the preferred gap between the two
 * components.
 * 
 * @param comp1 the first component
 * @param comp2 the second component
 * @param type the type of gap; one of the constants defined by
 *        LayoutStyle
 * @param canGrow true if the gap can grow if more
 *                space is available
 * @return this <code>SequentialGroup</code>
 * @throws IllegalArgumentException if <code>type</code> is not a
 *         valid LayoutStyle constant
 * @see LayoutStyle
 */
public SequentialGroup addPreferredGap(Component comp1,
        Component comp2,
        int type, boolean canGrow) {
    if (type != LayoutStyle.RELATED &&
            type != LayoutStyle.UNRELATED &&
            type != LayoutStyle.INDENT) {
        throw new IllegalArgumentException("Invalid type argument");
    }
    if (comp1 == null || comp2 == null) {
        throw new IllegalArgumentException(
                "Components must be non-null");
    }
    return (SequentialGroup)addSpring(new PaddingSpring(
            comp1, comp2, type, canGrow));
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:31,代码来源:GroupLayout.java


示例15: getComponentConstraint

import com.codename1.ui.Component; //导入依赖的package包/类
/**
 * Returns the component constraint
 * 
 * @param comp the component whose constraint is queried
 * @return one of the constraints defined in this class
 */
public Object getComponentConstraint(Component comp) {
    if (comp == portraitCenter) {
        return CENTER;
    } else if (comp == portraitNorth) {
        return NORTH;
    } else if (comp == portraitSouth) {
        return SOUTH;
    } else if (comp == portraitEast) {
        return EAST;
    } else if (comp == overlay) {
        return OVERLAY;
    } else {
        if(comp == portraitWest) {
            return WEST;
        }
    }
    return null;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:25,代码来源:BorderLayout.java


示例16: drawLabelStringValign

import com.codename1.ui.Component; //导入依赖的package包/类
/**
 * Implements the drawString for the text component and adjust the valign
 * assuming the icon is in one of the sides
 */
private int drawLabelStringValign(AndroidGraphics underlying, 
        CodenameOneTextPaint nativeFont, String str, int x, int y, int textSpaceW,
        boolean isTickerRunning, int tickerShiftText, int textDecoration, boolean rtl,
        boolean endsWith3Points, int textWidth,
        int iconStringHGap, int iconHeight, int fontHeight, int valign, Bitmap textCache) {
    if(str.length() == 0) {
        return 0;
    }
    switch (valign) {
        case Component.TOP:
            return drawLabelString(underlying, nativeFont, str, x, y, textSpaceW, isTickerRunning, tickerShiftText, textDecoration, rtl, endsWith3Points, textWidth, fontHeight, textCache);
        case Component.CENTER:
            return drawLabelString(underlying, nativeFont, str, x, y + iconHeight / 2 - fontHeight / 2, textSpaceW, isTickerRunning, tickerShiftText, textDecoration, rtl, endsWith3Points, textWidth, fontHeight, textCache);
        default:
            return drawLabelString(underlying, nativeFont, str, x, y + iconStringHGap, textSpaceW, isTickerRunning, tickerShiftText, textDecoration, rtl, endsWith3Points, textWidth, fontHeight, textCache);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:22,代码来源:AndroidAsyncView.java


示例17: removeLayoutComponent

import com.codename1.ui.Component; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void removeLayoutComponent(Component comp) {
    if (comp == portraitCenter) {
        portraitCenter = null;
    } else if (comp == portraitNorth) {
        portraitNorth = null;
    } else if (comp == portraitSouth) {
        portraitSouth = null;
    } else if (comp == portraitEast) {
        portraitEast = null;
    } else if (comp == portraitWest) {
        portraitWest = null;
    } else if (comp == overlay) {
        overlay = null;
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:19,代码来源:BorderLayout.java


示例18: onQueueAction

import com.codename1.ui.Component; //导入依赖的package包/类
public void onQueueAction(Component c, ActionEvent event) 
{
    event.consume();
    final List list = (List) event.getSource();
    final Map item = (Map)list.getSelectedItem();

    Button clickedButton = ((GenericListCellRenderer)list.getRenderer()).extractLastClickedComponent();
    if (clickedButton != null) {
        // Occurs when touching a button

        if (clickedButton.getName().equals("btnMediaActionFixed")) {
            ArrayList<Command> commands = new ArrayList<Command>();

            Image icon = StateMachine.getResourceFile().getImage("popup_trash_icon.png");
            icon.lock();
            commands.add(new Command(ui.translate("command_remove_item_from_playlist", "[default]Remove item"), icon) {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    ui.player.removeFromQueue((Map) list.getSelectedItem());
                    if(ui.player.isQueueEmpty())
                    {
                        Display.getInstance().getCurrent().setTransitionOutAnimator(CommonTransitions.createEmpty());
                        ui.playerView.setFromMiniPlayer(false);
                        ui.back();
                        ui.back();
                    }
                    else
                        initQueueModel(list);
                }
            });
            ui.dialogOptions.show(commands);
            return;
        }
    }
    
    ui.player.setQueueAndPlay((TrackListModel) list.getModel());
    Display.getInstance().getCurrent().setTransitionOutAnimator(CommonTransitions.createFade(200));
    ui.back();
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:41,代码来源:QueueView.java


示例19: initSpinnerRenderer

import com.codename1.ui.Component; //导入依赖的package包/类
void initSpinnerRenderer() {
    DefaultListCellRenderer render = ((DefaultListCellRenderer) super.getRenderer());
    render.setRTL(false);
    setRTL(false);
    render.setShowNumbers(false);
    render.setUIID("SpinnerRenderer");
    Component bgFocus = render.getListFocusComponent(this);
    bgFocus.setUIID("SpinnerRendererFocus");
    bgFocus.getSelectedStyle().setBgTransparency(0);
    bgFocus.getUnselectedStyle().setBgTransparency(0);
    render.setAlwaysRenderSelection(true);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:13,代码来源:Spinner.java


示例20: reverseAlignForBidi

import com.codename1.ui.Component; //导入依赖的package包/类
/**
 * Reverses alignment in the case of bidi
 */
private int reverseAlignForBidi(Component c, int align) {
    if(c.isRTL()) {
        switch(align) {
            case Component.RIGHT:
                return Component.LEFT;
            case Component.LEFT:
                return Component.RIGHT;
        }
    }
    return align;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:15,代码来源:DefaultLookAndFeel.java



注:本文中的com.codename1.ui.Component类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileWithSnapshotFeature类代码示例发布时间:2022-05-23
下一篇:
Java PriorityQueue类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap