Java Code Examples for com.codename1.ui.plaf.UIManager#getInstance()

The following examples show how to use com.codename1.ui.plaf.UIManager#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @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));
}
 
Example 2
Source File: Form.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public UIManager getUIManager() {
    if (uiManager != null) {
        return uiManager;
    } else {
        return UIManager.getInstance();
    }
}
 
Example 3
Source File: CheckboxTest2900.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void start() {
     if(current != null){
         current.show();
         return;
     }
     Form hi = new Form("Hi >>0 World",new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE)); 

     UIManager man = UIManager.getInstance();
man.setLookAndFeel(new DefaultLookAndFeel(man));
  	
     current = hi;
     Container vpanel = new Container();
     current.add(BorderLayout.CENTER,vpanel);

     vpanel.setLayout(new FlowLayout());//new BoxLayout(BoxLayout.Y_AXIS));
      
 
     for(int i=0;i<20;i++)
      {
          DCheckbox cb1 = new DCheckbox("Test Checkbox #"+i,true);
          cb1.setOppositeSide((i&1)==0);	 
          vpanel.add(cb1);
      }

      hi.show();
     Runnable rr = new Runnable (){
     	public void run() {
     	System.out.println("running");
     	while(true)
     	{
     	hi.repaint();
     	try {
     	Thread.sleep(1);
     	}

     		  catch (InterruptedException e) {};
     		}}};
     	new Thread(rr).start();

 }
 
Example 4
Source File: BlackBerryImplementation.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
protected EditPopup(TextArea lightweightEdit, int maxSize) {
    super(new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL), Field.FOCUSABLE | Field.EDITABLE | Screen.DEFAULT_MENU);
    UIManager m = UIManager.getInstance();
    okString = m.localize("ok", "OK");
    cancelString = m.localize("cancel", "Cancel");
    this.lightweightEdit = lightweightEdit;
    long type = 0;
    int constraint = lightweightEdit.getConstraint();
    if ((constraint & TextArea.DECIMAL) == TextArea.DECIMAL) {
        type = BasicEditField.FILTER_REAL_NUMERIC;
    } else if ((constraint & TextArea.EMAILADDR) == TextArea.EMAILADDR) {
        type = BasicEditField.FILTER_EMAIL;
    } else if ((constraint & TextArea.NUMERIC) == TextArea.NUMERIC) {
        type = BasicEditField.FILTER_NUMERIC;
    } else if ((constraint & TextArea.PHONENUMBER) == TextArea.PHONENUMBER) {
        type = BasicEditField.FILTER_PHONE;
    } else if ((constraint & TextArea.NON_PREDICTIVE) == TextArea.NON_PREDICTIVE) {
        type = BasicEditField.NO_COMPLEX_INPUT;
    }


    if (lightweightEdit.isSingleLineTextArea()) {
        type |= BasicEditField.NO_NEWLINE;
    }

    if ((constraint & TextArea.PASSWORD) == TextArea.PASSWORD) {
        nativeEdit = new BBPasswordEditField(lightweightEdit, type, maxSize, 0, 0xffffff);
    } else {
        nativeEdit = new BBEditField(lightweightEdit, type, maxSize, 0, 0xffffff);
    }
    
    
    // using Field.EDITABLE flag now because of bug with DevTrack ID 354265 at
    // https://www.blackberry.com/jira/browse/JAVAAPI-101
    //nativeEdit.setEditable(true);
    net.rim.device.api.ui.Font f = nativeEdit.getFont();
    if (f.getHeight() > lightweightEdit.getStyle().getFont().getHeight()) {
        nativeEdit.setFont(f.derive(f.getStyle(),
                lightweightEdit.getStyle().getFont().getHeight()));
    }
    add(nativeEdit);
    nativeEdit.setFocus();
    nativeEdit.setFocusListener(this);
}
 
Example 5
Source File: DurationSpinner3D.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
private void init() {
    setLayout(new BorderLayout());
    Container wrapper = new Container(new LayeredLayout());
    
    Container box = new Container(BoxLayout.x());
    UIManager uim = UIManager.getInstance();
    
    Style s = null;

    if (includeDays) {
        days = Spinner3D.create(0, 1000, 0, 1);
        days.setPreferredW(new Label("000", "Spinner3DRow").getPreferredW());
        s = Style.createProxyStyle(days.getRowStyle(), days.getSelectedRowStyle());
        s.setAlignment(Component.RIGHT);
        box.add(days);
        box.add(new Label(uim.localize("day", "day")));
    }
    if (includeHours) {
        hours = Spinner3D.create(0, includeDays ? 24 : 1000, 0, 1);
        hours.setPreferredW(new Label("000", "Spinner3DRow").getPreferredW());
        s = Style.createProxyStyle(hours.getRowStyle(), hours.getSelectedRowStyle());
        s.setAlignment(Component.RIGHT);
        box.add(hours);
        box.add(new Label(uim.localize("hour", "hour")));
    }
    if (includeMinutes) {
        minutes = Spinner3D.create(0, includeHours ? 59 : 1000, 0, 1);
        minutes.setPreferredW(new Label("000", "Spinner3DRow").getPreferredW());
        s = Style.createProxyStyle(minutes.getRowStyle(), minutes.getSelectedRowStyle());
        s.setAlignment(Component.RIGHT);
        box.add(minutes);
        box.add(new Label(uim.localize("min", "min")));
    }
    if (includeSeconds) {
        seconds = Spinner3D.create(0, includeMinutes ? 59 : 1000, 0, 1);
        seconds.setPreferredW(new Label("0000", "Spinner3DRow").getPreferredW());
        s = Style.createProxyStyle(seconds.getRowStyle(), seconds.getSelectedRowStyle());
        s.setAlignment(Component.RIGHT);
        box.add(seconds);
        box.add(new Label(uim.localize("sec", "sec")));
    }
    if (includeMilliseconds) {
        milliseconds = Spinner3D.create(0, 1000, 0, 1);
        milliseconds.setPreferredW(new Label("0000", "Spinner3DRow").getPreferredW());
        s = Style.createProxyStyle(milliseconds.getRowStyle(), milliseconds.getSelectedRowStyle());
        s.setAlignment(Component.RIGHT);
        box.add(milliseconds);
        box.add(new Label("ms", "ms"));
    }
    
    wrapper.add(box);
    LayeredLayout ll = (LayeredLayout)wrapper.getLayout();
    ll.setInsets(box, "0 auto 0 auto");
    add(BorderLayout.CENTER, wrapper);
}