This repository was archived by the owner on Nov 16, 2017. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTransparency.java
More file actions
Latest commit
65 lines (56 loc) · 1.93 KB
/
Copy pathTransparency.java
File metadata and controls
65 lines (56 loc) · 1.93 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
/*
* By attaching this document to the given files (the �work�), you, the licensee,
* are hereby granted free usage in both personal and commerical environments,
* without any obligation of attribution or payment (monetary or otherwise).
*
* The licensee is free to use, copy, modify, publish, distribute, sublicence,
* and/or merchandise the work, subject to the licensee inflecting a positive
* message unto someone. This includes (but is not limited to): smiling,
* being nice, saying �thank you�, assisting other persons, or any
* similar actions percolating the given concept.
*
* The above copyright notice serves as a permissions notice also,
* and may optionally be included in copies or portions of the work.
*
* The work is provided �as is�, without warranty or support, express or implied.
* The author(s) are not liable for any damages, misuse, or other claim, whether
* from or as a consequence of usage of the given work.
*/
packageProiect;
importjava.awt.*;
importjavax.swing.*;
/**
* This class add transparency to a component (ex. a JFrame).
*
* @author Stefan Cosma
*
*/
publicclassTransparencyextendsJComponent {
privatestaticfinallongserialVersionUID = 1L;
@SuppressWarnings("unused")
privateJFrameframe;
privateImagebackground;
publicTransparency(JFrameframe) {
this.frame = frame;
updateBackground();
}
publicvoidupdateBackground() {
try {
Robotrbt = newRobot();
Toolkittk = Toolkit.getDefaultToolkit();
Dimensiondim = tk.getScreenSize();
background = rbt.createScreenCapture(newRectangle(0, 0, (int) dim
.getWidth(), (int) dim.getHeight()));
} catch (Exceptionex) {
p(ex.toString());
ex.printStackTrace();
}
}
privatevoidp(Stringstring) {
}
publicvoidpaintComponent(Graphicsg) {
Pointpos = this.getLocationOnScreen();
Pointoffset = newPoint(-pos.x, -pos.y);
g.drawImage(background, offset.x, offset.y, null);
}
}