forked from prashantkalokhe/Hacktoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flg_panel.js
41 lines (31 loc) · 892 Bytes
/
flg_panel.js
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
39
40
41
package com. flag;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
public class FlagPanel extends JPanel {
@Override
protected void paintComponent(Graphics g) {
super .paintComponent(g);
g.setColor(Color.decode("#FF8F1C"));
g.drawRect(10, 10, 400, 70);
g.fillRect(10, 10, 400, 70)
g.setColor(Color.WHITE);
g.drawRect(10, 80, 400, 70);
g.fillRect(10, 80, 400, 70);
g.setColor(Color.decode("#509E2F"));
g.drawRect(10, 150, 400, 70);
g.fillRect(10, 150, 400, 70);
g.setColor(Color.BLACK);
g.fillRect(10, 10, 5, 540);
try {
Image img = ImageIO.read(new FileInputStream("src/a.jpg"));
g.drawImage(img, 165, 80, 70, 70, null);
g.setFont(new Font("Lato", Font.BOLD, 30));
g.setColor(Color.BLUE);
g.drawString("Happy Independence Day !!", 25, 400);
} catch (Exception e) {
e.printStackTrace();
}
}