I have read the developer guide, more times than I'd like to admit, 
although I must admit I haven't made it past miscellaneous functions.  In 
fact I can tell you that you have so far 26 navigation errors in your 
document and numerous typos as well as outdated code and samples that no 
longer work.  Dont believe me that's ok, here's the list of navigation 
errors:

https://www.codenameone.com/manual/basics.html#_component/container_hierarchy
https://www.codenameone.com/manual/basics.html#_layout_managers
https://www.codenameone.com/manual/advanced-theming.html#_theme_constants
https://www.codenameone.com/manual/advanced-theming.html#_how_does_a_theme_work?
https://www.codenameone.com/manual/advanced-theming.html#_understanding_images_multi-images
https://www.codenameone.com/manual/advanced-theming.html#_use_millimeters_for_padding/margin_font_sizes
https://www.codenameone.com/manual/components.html#_label
https://www.codenameone.com/manual/components.html#_button
https://www.codenameone.com/manual/components.html#_checkbox/radiobutton
https://www.codenameone.com/manual/components.html#_spanlabel
https://www.codenameone.com/manual/components.html#_list,_multilist,_renderers_models
https://www.codenameone.com/manual/components.html#_table
https://www.codenameone.com/manual/components.html#_tree
https://www.codenameone.com/manual/components.html#_sharebutton
https://www.codenameone.com/manual/components.html#_mediamanager_mediaplayer
https://www.codenameone.com/manual/components.html#_picker
https://www.codenameone.com/manual/animations.html#_layout_animations
https://www.codenameone.com/manual/edt.html#_call_serially_(and_wait)
https://www.codenameone.com/manual/edt.html#_invoke_and_block
https://www.codenameone.com/manual/graphics.html#_images
https://www.codenameone.com/manual/misc-features.html#_localization_internationalization_(l10n_i18n)
https://www.codenameone.com/manual/misc-features.html#_location_-_gps
https://www.codenameone.com/manual/misc-features.html#_capture_-_photos,_video,_audio
https://www.codenameone.com/manual/misc-features.html#_google_login
https://www.codenameone.com/manual/misc-features.html#_lead_component
https://www.codenameone.com/manual/misc-features.html#_running_3rd_party_apps_using_display's_execute

Now getting back to getting some technical support.  I am mostly positive 
this is *NOT* and EDT problem.  For some reason you remove the center 
component from the title bar and never replace it.  This happens during the 
out animation of the toastbar.  stack:


Thread [EDT] (Suspended (breakpoint at line 202 in BorderLayout)) 
 BorderLayout.removeLayoutComponent(Component) line: 202 
 Toolbar(Container).removeComponentImplNoAnimationSafety(Component) line: 
929 
 Container$3.updateState() line: 913 
 Container$3(ComponentAnimation).updateAnimationState() line: 80 
 AnimationManager.updateAnimations() line: 69 
 FrmMain(Form).repaintAnimations() line: 1350 
 Display.edtLoopImpl() line: 1078 
 Display.invokeAndBlock(Runnable, boolean) line: 1204 
 Display.invokeAndBlock(Runnable) line: 1242 
 AnimationManager.addAnimationAndBlock(ComponentAnimation) line: 105 
 Container.animateHierarchy(int, boolean, int) line: 2476 
 Container.animateHierarchyAndWait(int) line: 2196 
 ToastBar.setVisible(boolean) line: 724 
 ToastBar.updateStatus() line: 468 
 ToastBar.removeStatus(ToastBar$Status) line: 680 
 ToastBar.access$700(ToastBar, ToastBar$Status) line: 76 
 ToastBar$Status.clear() line: 348 
 FrmMain.refresh() line: 73 
 FrmMain.onClick() line: 64 
 FrmMain$2.actionPerformed(ActionEvent) line: 52 
 EventDispatcher.fireActionEvent(ActionEvent) line: 349 
 Button.fireActionEvent(int, int) line: 403 
 Button.released(int, int) line: 442 
 Button.pointerReleased(int, int) line: 530 
 FrmMain(Form).pointerReleased(int, int) line: 2599 
 FrmMain(Form).pointerReleased(int, int) line: 2563 
 FrmMain(Component).pointerReleased(int[], int[]) line: 3154 
 Display.handleEvent(int) line: 2024 
 Display.edtLoopImpl() line: 1066 
 Display.mainEDTLoop() line: 995 
 RunnableWrapper.run() line: 120 
 CodenameOneThread.run() line: 176 

Then when setTitle is called, the center component is null and a new 
component is created:

    public void setTitle(String title) {
        checkIfInitialized();
        Component center = ((BorderLayout) getLayout()).getCenter();
        if (center instanceof Label) {
            ((Label) center).setText(title);
        } else {
            titleComponent = new Label(title);
            titleComponent.setUIID("Title");
            if (center != null) {
                replace(center, titleComponent, null);
            } else {
                addComponent(BorderLayout.CENTER, titleComponent);
            }
        }
    }

Using callSeriallyandWait on setTitle results in an error because we are 
already on the EDT.  Here is a full test sample.  It is not complicated. 
and has only the minimum required.  

package com.mycompany.myapp;

import com.codename1.components.ToastBar;
import com.codename1.ui.Button;
import com.codename1.ui.Command;
import com.codename1.ui.Component;
import com.codename1.ui.Container;
import com.codename1.ui.Dialog;
import com.codename1.ui.Display;
import com.codename1.ui.FontImage;
import com.codename1.ui.Label;
import com.codename1.ui.TextArea;
import com.codename1.ui.Toolbar;
import com.codename1.ui.geom.Dimension;
import com.codename1.ui.layouts.BoxLayout;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.table.Table;
import com.codename1.ui.table.TableLayout;

public class FrmMain extends com.codename1.ui.Form {
protected Container cntFixed = new Container(); // fixed panel
TableLayout layout = new TableLayout(3, 3);
ToastBar.Status status = ToastBar.getInstance().createStatus();
protected DlgClientFilter2 dlgFilter = new DlgClientFilter2();
protected Table table = null;

public FrmMain() {
this(com.codename1.ui.util.Resources.getGlobalResources());
}

public FrmMain(com.codename1.ui.util.Resources resourceObjectInstance) {
initManualComponents();
}

protected void initManualComponents() {
setLayout(new BoxLayout(BoxLayout.Y_AXIS));
setTitle("Clients");
setName("FrmClients");

// sidebar
if (getToolbar() == null) {
setToolbar(new Toolbar());
}
getToolbar().addCommandToSideMenu(new Command("Dashboard") {
public void actionPerformed(com.codename1.ui.events.ActionEvent ev) {
}
});

Command cmdFilter = new Command("", 
FontImage.createMaterial(FontImage.MATERIAL_FILTER_LIST,
UIManager.getInstance().getComponentStyle("Command"), 5)) {
public void actionPerformed(com.codename1.ui.events.ActionEvent ev) {
onClick();
}
};
getToolbar().addCommandToRightBar(cmdFilter);

table = new Table();
this.add(table);
}

protected void onClick() {
System.out.println(Display.getInstance().isEdt());
dlgFilter.show(10, 0, (int) (Display.getInstance().getDisplayWidth() * .5), 
0);
refresh();
}

public void refresh() {
System.out.println(Display.getInstance().isEdt());
status.setMessage("Test");
status.setProgress(0);
status.show();

status.clear();
System.out.println(Display.getInstance().isEdt());
// This does not work as we are already on the EDT, so just call setTitle()
// Display.getInstance().callSeriallyAndWait(() ->  setTitle("Test Done"));
setTitle("Test Done");
}
public class DlgClientFilter2 extends Dialog {
protected TableLayout layout = new TableLayout(10,3);
protected Button btnApply = new 
Button(FontImage.createMaterial(FontImage.MATERIAL_DONE, 
UIManager.getInstance().getComponentStyle("Command"), 5));

protected TextArea taNotes = new TextArea() {

@Override
protected Dimension calcPreferredSize() {
return new Dimension(800, 500);
}
};

public DlgClientFilter2() {
       initManualComponents();
   }
   
   protected void initManualComponents() {
    this.setLayout(layout);

    taNotes.setPreferredSize(new Dimension(800, 500));
       
    Container content = getContentPane();
       content.add(layout.createConstraint().widthPercentage(33), new 
Label(""));
       content.add(layout.createConstraint().widthPercentage(33), new 
Label(""));
       content.add(layout.createConstraint().widthPercentage(33), new 
Label(""));

    Container cnt2 = new Container();
    cnt2.add(btnApply);
    btnApply.addActionListener(evt -> onApply());
    
content.add(layout.createConstraint().horizontalSpan(3).horizontalAlign(Component.RIGHT),
 
cnt2);
    content.add(layout.createConstraint().horizontalSpan(3), taNotes);

   }
   
   protected void onApply() {
    dispose();
   }
   
}
}



On Friday, September 23, 2016 at 10:56:51 PM UTC-7, Shai Almog wrote:
>
> No. 
> I suggest re-reading the developer guide chapter on the EDT. And 
> understanding *exactly* what invoke and block does.
> We have bugs, this isn't one of them.
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/5ae24670-833c-4890-867e-fd2d419e0fb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to