-
Notifications
You must be signed in to change notification settings - Fork 2
/
TransparentTextArea.java
40 lines (32 loc) · 1.04 KB
/
TransparentTextArea.java
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
package me.atom.windowsj;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.JTextPane;
/**
*
* TransparentTextarea.java created by Guillaume Cendre (aka chlkbumper)
*
* This class creates a custom JTextPane. It make it (almost -_-)
* transparent and set its initial text.
*
*/
public class TransparentTextArea extends JTextPane {
private static final long serialVersionUID = 1L;
public TransparentTextArea() {
setOpaque(false);
setText("Je suis Atom, votre assistant personnel. En quoi puis-je vous aider ?" + '\n' +
"(C) Copyright 2013 Guillaume Cendre");
}
@Override
protected void paintComponent(Graphics g) {
g.setColor(new Color(255, 255, 255, 0));
Insets insets = getInsets();
int x = insets.left;
int y = insets.top;
int width = getWidth() - (insets.left + insets.right);
int height = getHeight() - (insets.top + insets.bottom);
g.fillRect(x, y, width, height);
super.paintComponent(g);
}
}