beck
beck

Reputation: 3027

setHidden is not working codenameone

I used setHidden(true) and it doesnt work. The container and its components are visible if setHidden is used instead of setVisible. Moreover the problem I am getting while using setVisible is that the background of the container just pop up after the components inside the container animates from top. How can I make the background of the container move frm top along with its components.

questionAnswerContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));

titleDialog = new Label("Yuppie!");
titleDialog.setUIID("GameDialogLabelBold");
body1 = new Label("Let’s celebrate");
body2 = new Label("with another");
body3 = new Label("drink");
Button ok = new Button(theme.getImage("playIcon.png"));

dialogContainer = (BoxLayout.encloseY(titleDialog, body1, body2, body3, ok));
dialogContainer.getAllStyles().setBgImage(theme.getImage("yuppieDialog.png"));
dialogContainer.setPreferredW(screenWidth * 2 / 3);
dialogContainer.setPreferredH(screenWidth * 2 / 3);

add(BorderLayout.CENTER, LayeredLayout.encloseIn(questionAnswerContainer, FlowLayout.encloseCenterMiddle(dialogContainer)));
dialogContainer.getParent().setVisible(false);
//        dialogContainer.setHidden(true);  //it doesnot work, the container and its components are visible if setHidden is used instead of setVisible
f.revalidate();


public void checkIfCorrect(Button checkBtn, Form f) {
    dialogContainer.getParent().setY(-Display.getInstance().getDisplayHeight());
    dialogContainer.getParent().setVisible(true);
    //     dialogContainer.getParent().setHidden(false);
}

Upvotes: 1

Views: 115

Answers (1)

akash kubavat
akash kubavat

Reputation: 847

Give a try to f.invalidate(); as well. For me, sometimes combination of both invalidate and revalidate works.

Upvotes: 0

Related Questions