Skip to content

Dialog tinted only first time it is showing #1944

Closed
@JrmyDev

Description

@JrmyDev

When you create a Dialog instance and show it many times, the tint appear only the first time that the dialog is showed.

package com.mycompany.test;

import com.codename1.components.SpanLabel;
import com.codename1.io.Log;
import com.codename1.ui.Button;
import com.codename1.ui.Display;
import com.codename1.ui.FontImage;
import com.codename1.ui.Form;
import com.codename1.ui.Dialog;
import com.codename1.ui.Label;
import com.codename1.ui.animations.CommonTransitions;
import com.codename1.ui.layouts.BorderLayout;
import com.codename1.ui.layouts.BoxLayout;
import com.codename1.ui.layouts.FlowLayout;
import com.codename1.ui.layouts.LayeredLayout;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.ui.util.UITimer;

import java.io.IOException;

import com.codename1.ui.Toolbar;

/**
 * This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose of building native mobile applications using Java.
 */
public class TestDialog {

    private Form current;
    private Resources theme;
    private Dialog dialog;

    public void init(Object context) {
        theme = UIManager.initFirstTheme("/theme");

        // Enable Toolbar on all Forms by default
        Toolbar.setGlobalToolbar(true);
        dialog = new Dialog();
        dialog.addComponent(new SpanLabel("Hello world"));
        // Pro only feature, uncomment if you have a pro subscription
        // Log.bindCrashProtection(true);
    }

    public void start() {
        if (current != null) {
            current.show();
            return;
        }
        Form hi = new Form("Welcome", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE));
        final Label apple = new Label(theme.getImage("apple-icon.png"));
        final Label android = new Label(theme.getImage("android-icon.png"));
        final Label windows = new Label(theme.getImage("windows-icon.png"));
        Button getStarted = new Button("Test dialog show!");
        FontImage.setMaterialIcon(getStarted, FontImage.MATERIAL_LINK);
        getStarted.setUIID("GetStarted");
        hi.addComponent(BorderLayout.CENTER, LayeredLayout.encloseIn(BoxLayout.encloseY(new Label(theme.getImage("duke-no-logos.png")), getStarted), FlowLayout.encloseRightMiddle(apple)));

        getStarted.addActionListener((e) -> {
            Display.getInstance().callSerially(new Runnable() {

                @Override
                public void run() {

                    dialog.showPopupDialog(getStarted);
                }
            });
        });

        hi.show();
    }

    public void stop() {
        current = Display.getInstance().getCurrent();
        if (current instanceof Dialog) {
            ((Dialog) current).dispose();
            current = Display.getInstance().getCurrent();
        }
    }

    public void destroy() {
    }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions