Jan 02

Eight buttons: four each in two panels

import java.applet.Applet;
import java.awt.*;
***************************
/** Eight buttons: four each in two panels.
*
*/

public class ButtonTest2 extends Applet {
public void init() {
String[] labelPrefixes = { "Start", "Stop", "Pause",
"Resume" };
Panel p1 = new Panel();
for (int i=0; i<4; i++) {
p1.add(new Button(labelPrefixes[i] + " Thread1"));
}
Panel p2 = new Panel();
for (int i=0; i<4; i++) {
p2.add(new Button(labelPrefixes[i] + " Thread2"));
}
add(p1);
add(p2);
}
}
**************************

Note: Brought from our old site: http://www.salearningschool.com/example_codes/ on Jan 2nd, 2017

Skip to toolbar