Switching between one button and two buttons on the same place in FlowLayout??

U

Ulf Meinhardt

The task seems to be simple: I have an applet with a text label on the top and a button
on the bottom. When I click now on the button this button should disappear and two
buttons should be displayed at exact the place of the previous single button.

The dimensions of the first single button should be the same of the sum of the two following buttons
(equal height but sum of width).

Now when I click on one of the new buttons the game goes the other way: The two buttons
should disappear and the single button should be displayed again and so far.

How can I implement such a 1<->2 button in-place-switch?

A more grahical view:
(L=Label,SSSSSS=Single Button,
1=Left of the two buttons, 2=Rgight of the two buttons)

LLLLLLLLLLLL
LLLLLLLLLLLL
SSSSSSSSSSSS
SSSSSSSSSSSS

<- Click ->

LLLLLLLLLLLL
LLLLLLLLLLLL
111111222222
111111222222


import java.awt.*;
import java.applet.Applet;

public class myButtons extends Applet {
Label lab;
Button button1, button2, button3;
public void init() {
lab = new Label("Text")
button1 = new Button("Ok");
button2 = new Button("left");
button3 = new Button("right");
add(lab);
add(button1);
//add(button2);
//add(button3);
}
}


Ulf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top