Java Code Examples for com.codename1.ui.Form#repaint()

The following examples show how to use com.codename1.ui.Form#repaint() . 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: TextComponentSample2745.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void start() {
    if(current != null){
        current.show();
        return;
    }
    Form hi = new Form("Hi World", new TextModeLayout(2, 1));
    TextComponent cmp1 = new TextComponent().label("label1");
    TextComponent cmp2 = new TextComponent().label("label2");
    hi.add(cmp1);
    hi.add(cmp2);
    hi.show();
    
    cmp1.text("text1");
    cmp2.text("text2");
    hi.revalidateWithAnimationSafety();
    hi.repaint();
}
 
Example 2
Source File: PainterChain.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes a glass pane from the given form, this is the opposite operation for the
 * install glass pane
 * 
 * @param f form from which to remove the chain
 * @param p painter to remove
 */
public static void removeGlassPane(Form f, Painter p) {
    Painter existing = f.getGlassPane();
    if(existing == null) {
        return;
    }
    if(existing == p) {
        f.setGlassPane(null);
        return;
    }
    if(existing instanceof PainterChain) {
        PainterChain pc = (PainterChain)existing;
        if(pc.chain.length == 1) {
            f.setGlassPane(null);
        } else {
            Vector v = new Vector();
            int plen = pc.chain.length;
            for(int iter = 0 ; iter < plen ; iter++) {
                if(pc.chain[iter] != p) {
                    v.addElement(pc.chain[iter]);
                }
            }
            if(v.size() == 0) {
                f.setGlassPane(null);
                return;
            }
            Painter[] newChain = new Painter[v.size()];
            int clen = newChain.length;
            for(int iter = 0 ; iter < clen ; iter++) {
                newChain[iter] = (Painter)v.elementAt(iter);
            }
            pc.chain = newChain;
            f.repaint(); // Since setGlassPane was not called and still the painter changed, we need to call repaint
        }
    } 
}
 
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();

 }