java-melwuitlwuit-formlwuit-button

How to remove the Title-bar of a LWUIT Form?


In the actionPerformed of a Button I want to remove the Title-bar of the actual LWUIT Form. How to achieve that? And how to redisplay it again after a certain action has been complete?


Solution

  • Use below code for hide/show the title of the Form in the Button action event,

    final Form form = new Form("Sample");
    form.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
    final Container titleContainer = form.getTitleArea();
    titleContainer.setVisible(false);
    Button b = new Button("button");
    b.addActionListener(new ActionListener() {
    
      public void actionPerformed(ActionEvent evt) {
        if (!titleContainer.isVisible()) {
           titleContainer.setVisible(true);
        } else {
           titleContainer.setVisible(false);
        }
        form.revalidate();
        }            
      });
    form.addComponent(b);
    form.show();