当前位置: 首页>>代码示例>>Java>>正文


Java UIManager类代码示例

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


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

示例1: Progress

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
/**
 * Binds the progress UI to the completion of this request
 *
 * @param title the title of the progress dialog
 * @param request the network request pending
 * @param showPercentage shows percentage on the progress bar
 */
public Progress(String title, ConnectionRequest request, boolean showPercentage) {
    super(title);
    this.request = request;
    SliderBridge b = new SliderBridge(request);
    b.setRenderPercentageOnTop(showPercentage);
    b.setRenderValueOnTop(true);
    setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    addComponent(b);
    Command cancel = new Command(UIManager.getInstance().localize("cancel", "Cancel"));
    if(Display.getInstance().isTouchScreenDevice() || getSoftButtonCount() < 2) {
        // if this is a touch screen device or a blackberry use a centered button
        Button btn = new Button(cancel);
        Container cnt = new Container(new FlowLayout(CENTER));
        cnt.addComponent(btn);
        addComponent(cnt);
    } else {
        // otherwise use a command
        addCommand(cancel);
    }
    setDisposeWhenPointerOutOfBounds(false);
    setAutoDispose(false);
    NetworkManager.getInstance().addProgressListener(this);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:31,代码来源:Progress.java

示例2: init

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
public void init(Object context) {
    try {
        Resources theme = Resources.openLayered("/theme");
        UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
    } catch(IOException e){
        e.printStackTrace();
    }
    // Pro users - uncomment this code to get crash reports sent to you automatically
    /*Display.getInstance().addEdtErrorHandler(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            evt.consume();
            Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown"));
            Log.p("OS " + Display.getInstance().getPlatformName());
            Log.p("Error " + evt.getSource());
            Log.p("Current Form " + Display.getInstance().getCurrent().getName());
            Log.e((Throwable)evt.getSource());
            Log.sendLog();
        }
    });*/
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:21,代码来源:ChartsDemo.java

示例3: init

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
public void init(Object context) {
    try {
        Resources theme = Resources.openLayered("/theme");
        placeholder = (EncodedImage)theme.getImage("thumbnail.png");
        THUMB_URL_PREFIX = THUMB_URL_PREFIX + "w=" + placeholder.getWidth() + "&h=" + placeholder.getHeight() + "&i=";
        UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
    } catch(IOException e){
        e.printStackTrace();
    }
    // Pro users - uncomment this code to get crash reports sent to you automatically
    /*Display.getInstance().addEdtErrorHandler(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            evt.consume();
            Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown"));
            Log.p("OS " + Display.getInstance().getPlatformName());
            Log.p("Error " + evt.getSource());
            Log.p("Current Form " + Display.getInstance().getCurrent().getName());
            Log.e((Throwable)evt.getSource());
            Log.sendLog();
        }
    });*/
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:23,代码来源:PhotoShare.java

示例4: init

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
public void init(Object context) {
    try {
        theme = Resources.openLayered("/theme");
        UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
        int dpi =  Preferences.get("dpi", calculateDPI());
        cards = Resources.open("/gamedata.res",dpi);
        currentZoom = Preferences.get("zoom", defaultZoom);
    } catch(IOException e){
        e.printStackTrace();
    }
    // Pro users - uncomment this code to get crash reports sent to you automatically
    Display.getInstance().addEdtErrorHandler(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            evt.consume();
            Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown"));
            Log.p("OS " + Display.getInstance().getPlatformName());
            Log.p("Error " + evt.getSource());
            Log.p("Current Form " + Display.getInstance().getCurrent().getName());
            Log.e((Throwable)evt.getSource());
            Log.sendLog();
        }
    });
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:24,代码来源:Solitaire.java

示例5: init

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
public void init(Object context) {
    try {
        theme = Resources.openLayered("/theme");
        UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
    } catch(IOException e){
        e.printStackTrace();
    }
    // Pro users - uncomment this code to get crash reports sent to you automatically
    /*Display.getInstance().addEdtErrorHandler(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            evt.consume();
            Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown"));
            Log.p("OS " + Display.getInstance().getPlatformName());
            Log.p("Error " + evt.getSource());
            Log.p("Current Form " + Display.getInstance().getCurrent().getName());
            Log.e((Throwable)evt.getSource());
            Log.sendLog();
        }
    });*/
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:21,代码来源:LocalNotificationTest.java

示例6: editString

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public void editString(Component cmp, int maxSize, int constraint, String text, int keyCode) {
    UIManager m = UIManager.getInstance();
    CONFIRM_COMMAND = new Command(m.localize("ok", "OK"), Command.OK, 1);
    CANCEL_COMMAND = new Command(m.localize("cancel", "Cancel"), Command.CANCEL, 2);
    if(mid.getAppProperty("forceBackCommand") != null) {
        canvas.addCommand(MIDP_BACK_COMMAND);
    }
    currentTextBox = new TextBox("", "", maxSize, TextArea.ANY);
    currentTextBox.setCommandListener((CommandListener)canvas);
    currentTextBox.addCommand(CONFIRM_COMMAND);
    currentTextBox.addCommand(CANCEL_COMMAND);
    currentTextComponent = cmp;
    currentTextBox.setMaxSize(maxSize);
    currentTextBox.setString(text);
    currentTextBox.setConstraints(constraint);
    display.setCurrent(currentTextBox);
    ((C)canvas).setDone(false);
    Display.getInstance().invokeAndBlock(((C)canvas));
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:23,代码来源:GameCanvasImplementation.java

示例7: installNativeTheme

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public void installNativeTheme() {
    
    InputStream i = getResourceAsStream(getClass(), "/nokia_touch_theme.res");
    if(i == null){
        i = getResourceAsStream(getClass(), "/nokia_non_touch.res");
    }
    if(i == null){
        i = getResourceAsStream(getClass(), "/nokia_asha_theme.res");
    }
    if(i == null){
        i = getResourceAsStream(getClass(), "/nativeJ2METheme.res");
    }
    if(i != null){
        try {
            Resources r = Resources.open(i);
            UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0]));
        } catch(Throwable t) {
            t.printStackTrace();
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:25,代码来源:GameCanvasImplementation.java

示例8: installNativeTheme

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
/**
 * Installs the native theme, this is only applicable if hasNativeTheme()
 * returned true. Notice that this method might replace the
 * DefaultLookAndFeel instance and the default transitions.
 */
public void installNativeTheme() {
    hasNativeTheme();
    if (nativeThemeAvailable) {
        try {
            InputStream is;
            if (android.os.Build.VERSION.SDK_INT < 14 && !isTablet() || Display.getInstance().getProperty("and.hololight", "false").equals("true")) {
                is = getResourceAsStream(getClass(), "/androidTheme.res");
            } else {
                is = getResourceAsStream(getClass(), "/android_holo_light.res");
            }
            Resources r = Resources.open(is);
            Hashtable h = r.getTheme(r.getThemeResourceNames()[0]);
            h.put("@commandBehavior", "Native");
            UIManager.getInstance().setThemeProps(h);
            is.close();
            Display.getInstance().setCommandBehavior(Display.COMMAND_BEHAVIOR_NATIVE);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:27,代码来源:AndroidImplementation.java

示例9: getMenu

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
public Menu getMenu(int val) {
    if (Display.getInstance().getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE) {
        m = new Menu();
        if(commands != null){
            for (int iter = 0; iter < commands.size(); iter++) {
                final Command cmd = (Command) commands.elementAt(iter);
                String txt = UIManager.getInstance().localize(cmd.getCommandName(), cmd.getCommandName());
                MenuItem i = new MenuItem(txt, iter, iter) {
                    public void run() {
                        Display.getInstance().callSerially(new Runnable() {
                            public void run() {
                                impl.getCurrentForm().dispatchCommand(cmd, new ActionEvent(cmd));
                            }
                        });
                    }
                };
                m.add(i);
            }
        }
        return m;
    }
    return super.getMenu(val);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:24,代码来源:BlackBerryCanvas.java

示例10: getFitText

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
/**
 * Calculates the best text to fit into the available space.
 * 
 * @param text the entire text
 * @param width the width to fit the text into
 * @param paint the paint
 * @return the text to fit into the space
 */
private String getFitText(String text, float width, Paint paint) {
    if(UIManager.getInstance().getLookAndFeel().isDefaultEndsWith3Points()) {
      String newText = text;
      int length = text.length();
      int diff = 0;
      while (paint.measureText(newText) > width && diff < length) {
        diff++;
        newText = text.substring(0, length - diff) + "...";
      }
      if (diff == length) {
        newText = "...";
      }
      return newText;
    }
    return text;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:25,代码来源:AbstractChart.java

示例11: setBackCommand

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
/**
 * Indicates the command that is defined as the back command out of this form.
 * A back command can be used both to map to a hardware button (e.g. on the Sony Ericsson devices)
 * and by elements such as transitions etc. to change the behavior based on 
 * direction (e.g. slide to the left to enter screen and slide to the right to exit with back).
 * 
 * @param backCommand the command to treat as the back Command
 */
public void setBackCommand(Command backCommand) {
    this.backCommand = backCommand;
    if(parent.getToolbar() != null) {
        return;
    }
    if(backCommand != null && UIManager.getInstance().isThemeConstant("hideBackCommandBool", false)) {
        removeCommand(backCommand);
    }
    
    int b = getCommandBehavior();
    if (b == Display.COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK || b == Display.COMMAND_BEHAVIOR_ICS
            || Display.getInstance().isNativeTitle()) {
        int i = commands.indexOf(backCommand);
        if (i > -1) {
            commands.removeElementAt(i);
        }
    }
    updateTitleCommandPlacement();
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:28,代码来源:MenuBar.java

示例12: createTouchCommandButton

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
/**
 * Creates a touch command for use as a touch menu item
 * 
 * @param c command to map into the returned button
 * @return a button that would fire the touch command appropriately
 */
protected Button createTouchCommandButton(Command c) {
    Button b = new Button(c);
    if (b.getIcon() == null) {
        // some themes look awful without any icon
        b.setIcon((Image) parent.getUIManager().getThemeImageConstant("defaultCommandImage"));
    } else {
        if (UIManager.getInstance().isThemeConstant("commandAsIconBool", false)) {
            b.setText("");
        }
    }
    b.setTactileTouch(true);
    b.setTextPosition(Label.BOTTOM);
    b.setEndsWith3Points(false);
    String uiid = (String)c.getClientProperty("cn1$CommandUIID");
    if(uiid != null) {
        b.setUIID(uiid);
    } else {
        b.setUIID("TouchCommand");
    }
    Integer gap = (Integer)c.getClientProperty("iconGap");
    if(gap != null) {
        b.setGap(gap.intValue());
    }
    return b;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:32,代码来源:MenuBar.java

示例13: createOpenButton

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
/**
 * Creates the Side Menu open button.
 * @return a Button instance to place on the TitleArea
 */ 
protected Button createOpenButton(){
    Button ob = new Button();
    ob.setUIID("MenuButton");
    UIManager uim = parent.getUIManager();
    Image i = (Image) uim.getThemeImageConstant("sideMenuImage");
    if (i != null) {
        ob.setIcon(i);
    } else {
        float size = 4.5f;
        try {
            size = Float.parseFloat(uim.getThemeConstant("menuImageSize", "4.5"));
        } catch(Throwable t) {
            Log.e(t);
        }
        FontImage.setMaterialIcon(ob, FontImage.MATERIAL_MENU, size);
    }
    Image p = (Image) uim.getThemeImageConstant("sideMenuPressImage");
    if (p != null) {
        ob.setPressedIcon(p);
    }
    return ob;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:27,代码来源:SideMenuBar.java

示例14: setBackCommand

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void setBackCommand(Command backCommand) {
    super.setBackCommand(backCommand);
    if (parent instanceof Dialog) {
        return;
    }
    addOpenButton(null, false);
    installRightCommands();
    installLeftCommands();
    if (getBackCommand() != null
            && getCommandCount() > 0
            && !UIManager.getInstance().isThemeConstant("hideBackCommandBool", false)
            && !getCommands().contains(getBackCommand())) {
        getCommands().insertElementAt(getBackCommand(), 0);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:19,代码来源:SideMenuBar.java

示例15: initLaf

import com.codename1.ui.plaf.UIManager; //导入依赖的package包/类
/**
 * This method initializes the Component defaults constants
 */
protected void initLaf(UIManager uim){
    if(uim == getUIManager() && isInitialized()){
        return;
    }
    selectText = uim.localize("select", "Select");
    LookAndFeel laf = uim.getLookAndFeel();
    animationSpeed = laf.getDefaultSmoothScrollingSpeed();
    rtl = laf.isRTL();
    tactileTouch = isFocusable();
    tensileDragEnabled = laf.isDefaultTensileDrag();
    snapToGrid = laf.isDefaultSnapToGrid();
    alwaysTensile = laf.isDefaultAlwaysTensile();
    tensileHighlightEnabled = laf.isDefaultTensileHighlight();
    scrollOpacityChangeSpeed = laf.getFadeScrollBarSpeed();
    isScrollVisible = laf.isScrollVisible();
    
    if(tensileHighlightEnabled) {
        tensileLength = 3;
    } else {
        tensileLength = -1;
    }        
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:26,代码来源:Component.java


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