Multiple JLabel

This program uses a JFrame container to hold an instance of a multiple JLabel. The labels displays a multiple text message.

Program

1

 

 

 

Program Source

import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.FlowLayout;

class Frame extends JFrame{
    
    Frame()
    {
        setTitle("Multiple JLabel");
        setLayout(new FlowLayout());
        setLabel();
        setSize(700, 200);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    
    private void setLabel()
    {
        JLabel jl1 = new JLabel("JLabel01");
        JLabel jl2 = new JLabel("JLabel02");
        JLabel jl3 = new JLabel("JLabel03");
        add(jl1);
        add(jl2);
        add(jl3);
    }
}

public class Javaapp {
   
    public static void main(String[] args) {
        
        Frame frame = new Frame();
    }
}

Leave a Comment