limage icon
Wed Dec 27 2023 06:08:27 GMT+0000 (Coordinated Universal Time)
Saved by
@dsce
import java.awt.*;
import java.awt.event.*;
import javax .swing.*;
public class LabelDemo{
private JFrame frame;
private JLabel label;
public LabelDemo(){
frame=new JFrame("a simple swing app");
Toolkit tk=frame.getToolkit();
Dimension dim=tk.getScreenSize();
int width=(int)dim.getWidth();
int height=(int)dim.getHeight();
frame.setSize(width,height);
frame.setLayout(new FlowLayout());
ImageIcon ic= new ImageIcon("giphy.gif");
label=new JLabel("A Shining planet",ic,JLabel.CENTER);
label.setFont(new Font("Verdana",Font.BOLD,18));
label.setBackground(Color.blue);
frame.add(label);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main(String[] args){
new LabelDemo();
}
}
content_copyCOPY
Comments