-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.JLabel.java
More file actions
38 lines (32 loc) · 1.19 KB
/
2.JLabel.java
File metadata and controls
38 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
public class Main{
public static void main(String[] args){
//--------------JLabel = a GUI Display Area------------
//JLabel Components
ImageIcon label_img = new ImageIcon("btn.png");
Border border = BorderFactory.createLineBorder(Color.green,2);
JLabel label = new JLabel();
label.setText("Assalamu Alaikum");
label.setForeground(Color.red);
label.setFont(new Font("MV Boli", Font.BOLD, 17));
label.setHorizontalTextPosition(JLabel.CENTER);
label.setVerticalTextPosition(JLabel.CENTER);
label.setIcon(label_img);
label.setIconTextGap(100);
label.setBackground(Color.white);
label.setOpaque(true);
label.setBorder(border);
label.setHorizontalAlignment(JLabel.CENTER);
label.setVerticalAlignment(JLabel.CENTER);
//JFrame Components
JFrame frame = new JFrame();
frame.setVisible(true);
frame.setSize(400,400);
frame.setResizable(true);
frame.setTitle("Hello");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(label);
}
}