Site icon WebArtDeveloper

How to create a Box Layout Frame in Core Java

In this tutorial how to create a Box Layout Frame in Core Java is shown.

Code:

BoxLayoutExample.java

import java.awt.*;
import javax.swing.*;

public class BoxLayoutExample extends Frame
{
Button buttons[];

public BoxLayoutExample()
{
buttons = new Button[5];

for(int i=0;i<5;i++)
{
buttons[i] = new Button(“Button” +(i+1));
add(buttons[i]);
}

setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
setSize(400,400);
setVisible(true);
}

public static void main(String args[])
{
BoxLayoutExample b = new BoxLayoutExample();
}
}

https://youtu.be/LQktJggN1Ck

Exit mobile version