Skip to main content

show a form by clicking a button

2 replies [Last post]
kroko
Offline
Joined: 2011-06-17
Points: 0

hi

i'm making an app wich should contains many forms.

i have an homeform which have 3 buttons.

when i click on a button i would like the app to show() a form.

how can i do that.

because there is action Listener but what else?

how can we use it with a button.

thank you

dav

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
abuhmead1987
Offline
Joined: 2010-04-21
Points: 0

Button button=new Button("Button01");

button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
//Do SomeThing here
}
});
====================================================================
====================================================================
//another approach
Button button=new Button(new Command("Button01", 0));
button.addActionListener(this);
public void actionPerformed(ActionEvent evt) {
if(evt.getCommand().getId()==0)
//Do something here ;
}
Giorgio Vespucc...
Offline
Joined: 2011-06-23
Points: 0

Hi Kroko
Are you meaning that you have 3 con.sun.lwuit.Buttons or Commands?
In both cases the actionPerformed() method from Command (if you bind the
Button with a Command via
thiscontructor)
is useful.
There you can call your form.show().
This solution imho avoids you to add an ActionListener to the Button,
because the Command is already an event listener in itself.
Hope this help.

On Thu, Jul 7, 2011 at 6:22 PM, wrote:

> hi
>
> i'm making an app wich should contains many forms.
>
> i have an homeform which have 3 buttons.
>
> when i click on a button i would like the app to show() a form.
>
> how can i do that.
>
> because there is action Listener but what else?
>
> how can we use it with a button.
>
> thank you
>
> dav
>
>