package com.mycompany.myapp;
import com.codename1.components.ToastBar;
import com.codename1.ui.Command;
import com.codename1.ui.Display;
import com.codename1.ui.FontImage;
import com.codename1.ui.Toolbar;
import com.codename1.ui.layouts.BoxLayout;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.table.Table;
public class FrmClients extends com.codename1.ui.Form {
protected Table table = null;
protected DlgClientFilter dlgFilter = new DlgClientFilter();
ToastBar.Status status = ToastBar.getInstance().createStatus();
public FrmClients() {
initManualComponents();
}
protected void initManualComponents() {
Toolbar.setGlobalToolbar(true);
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) {
onFilter();
}
};
getToolbar().addCommandToRightBar(cmdFilter);
table = new Table();
this.add(table);
}
public void refresh() {
status.setMessage("Test");
status.setProgress(0);
status.show();
loadClients(status);
}
protected void loadClients(ToastBar.Status prog) {
prog.clear();
setTitle("Test Done");
return;
}
protected void onFilter() {
dlgFilter.show(10, 0, (int)(Display.getInstance().getDisplayWidth()*.5), 0);
refresh();
}
}
package com.mycompany.myapp;
import com.codename1.ui.Button;
import com.codename1.ui.Component;
import com.codename1.ui.Container;
import com.codename1.ui.Dialog;
import com.codename1.ui.FontImage;
import com.codename1.ui.Label;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.table.TableLayout;
public class DlgClientFilter extends Dialog {
public boolean Cancelled = false;
protected TableLayout layout = new TableLayout(10,3);
protected Button btnApply = new Button(FontImage.createMaterial(FontImage.MATERIAL_DONE, UIManager.getInstance().getComponentStyle("Command"), 5));
protected Button btnClose = new Button(FontImage.createMaterial(FontImage.MATERIAL_CLEAR, UIManager.getInstance().getComponentStyle("Command"), 5));
public DlgClientFilter() {
initManualComponents();
}
protected void initManualComponents() {
this.setLayout(layout);
this.setUIID("Form");
this.setDialogUIID("Form");
this.getStyle().setBgTransparency(255);
this.getDialogStyle().setBgTransparency(255);
add(layout.createConstraint().widthPercentage(30), new Label(""));
add(layout.createConstraint().widthPercentage(55), new Label(""));
add(layout.createConstraint().widthPercentage(15), new Label(""));
Container cnt2 = new Container();
cnt2.add(btnApply);
cnt2.add(btnClose);
btnApply.addActionListener(evt -> onApply());
btnClose.addActionListener(evt -> onClose());
add(layout.createConstraint().horizontalSpan(3).horizontalAlign(Component.RIGHT), cnt2);
add(layout.createConstraint().horizontalSpan(3), new Label("Client Info"));
}
protected void onApply() {
Cancelled = false;
dispose();
}
protected void onClose() {
Cancelled = true;
dispose();
}
}
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
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);
}
}
}
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(); } }}