-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAvatar.java
More file actions
189 lines (147 loc) · 3.35 KB
/
Avatar.java
File metadata and controls
189 lines (147 loc) · 3.35 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Avatar extends JFrame implements ActionListener
{
Picture1 pic1 = new Picture1(new ImageIcon("pics/1.jpg").getImage());
Picture2 pic2 = new Picture2(new ImageIcon("pics/2.png").getImage());
Picture3 pic3 = new Picture3(new ImageIcon("pics/3.jpg").getImage());
Picture4 pic4 = new Picture4(new ImageIcon("pics/4.jpg").getImage());
Picture5 pic5 = new Picture5(new ImageIcon("pics/5.jpg").getImage());
JButton jb1,jb2,jb3,jb4,jb5;
static String ava1="pics/1.jpg";
public Avatar(String str)
{
super(str);
setLayout(null);
jb1=new JButton("Select");
jb2=new JButton("Select");
jb3=new JButton("Select");
jb4=new JButton("Select");
jb5=new JButton("Select");
jb1.setBounds(30,180,100,30);
jb2.setBounds(160,180,100,30);
jb3.setBounds(290,180,100,30);
jb4.setBounds(420,180,100,30);
jb5.setBounds(550,180,100,30);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
jb4.addActionListener(this);
jb5.addActionListener(this);
add(jb1);
add(jb2);
add(jb3);
add(jb4);
add(jb5);
add(pic1);
add(pic2);
add(pic3);
add(pic4);
add(pic5);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==jb1)
{
ava1="pics/1.jpg";
System.out.println(ava1);
}
if(ae.getSource()==jb2)
{
ava1="pics/2.png";
System.out.println(ava1);
}
if(ae.getSource()==jb3)
{
ava1="pics/3.jpg";
System.out.println(ava1);
}
if(ae.getSource()==jb4)
{
ava1="pics/4.jpg";
System.out.println(ava1);
}
if(ae.getSource()==jb5)
{
ava1="pics/5.jpg";
System.out.println(ava1);
}
}
/*public static void main(String[] args)
{
Avatar a=new Avatar("Avatar");
a.show();
a.setSize(700,700);
}*/
}
class Picture1 extends JPanel
{
Image image;
public Picture1(Image img)
{
image = img;
setSize(700,700);
setLayout(null);
}
public void paintComponent(Graphics g)
{
g.drawImage(image,0,0,null);
}
}
class Picture2 extends JPanel
{
Image image;
public Picture2(Image img)
{
image = img;
setSize(700,700);
setLayout(null);
}
public void paintComponent(Graphics g)
{
g.drawImage(image,140,0,null);
}
}
class Picture3 extends JPanel
{
Image image;
public Picture3(Image img)
{
image = img;
setSize(700,700);
setLayout(null);
}
public void paintComponent(Graphics g)
{
g.drawImage(image,280,0,null);
}
}
class Picture4 extends JPanel
{
Image image;
public Picture4(Image img)
{
image = img;
setSize(700,700);
setLayout(null);
}
public void paintComponent(Graphics g)
{
g.drawImage(image,420,0,null);
}
}
class Picture5 extends JPanel
{
Image image;
public Picture5(Image img)
{
image = img;
setSize(700,700);
setLayout(null);
}
public void paintComponent(Graphics g)
{
g.drawImage(image,560,0,null);
}
}