FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing4/app/src/processing/app/laf/PdeLabel.java at main · processing/processing4 · GitHub
processing
processing4
Repository navigation
Code
Issues
259
(259)
Pull requests
31
(31)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing4
/
app
/
src
/
processing
/
app
/
laf
/
PdeLabel.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
76 lines (60 loc) · 1.51 KB
Breadcrumbs
processing4
/
app
/
src
/
processing
/
app
/
laf
/
PdeLabel.java
Copy path
File metadata and controls
76 lines (60 loc) · 1.51 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
processing
.
app
.
laf
;
import
javax
.
swing
.
JTextPane
;
import
javax
.
swing
.
text
.
html
.
HTMLDocument
;
// not in use; this all works with JLabel, but it's confusing as heck
public
class
PdeLabel
extends
JTextPane
{
String
message
;
String
css
;
public
PdeLabel
() {
setEditable
(
false
);
setOpaque
(
false
);
setContentType
(
"text/html"
);
/*
pane.addHyperlinkListener(e -> {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (e.getURL() != null) {
Platform.openURL(e.getURL().toString());
}
}
});
*/
}
@
Override
public
void
setText
(
String
message
) {
this
.
message
=
message
;
rebuild
();
}
public
void
setText
(
String
message
,
String
css
) {
this
.
message
=
message
;
this
.
css
=
css
;
rebuild
();
}
private
void
rebuild
() {
StringBuffer
buffer
=
new
StringBuffer
(
"<html><head>"
);
// if (css != null) {
// buffer.append("<style type='text/css'>").append(css).append("</style>");
// }
buffer
.
append
(
"</head><body>"
);
buffer
.
append
(
message
);
// System.out.println(buffer);
super
.
setText
(
buffer
.
toString
());
if
(
css
!=
null
) {
((
HTMLDocument
)
getDocument
()).
getStyleSheet
().
addRule
(
css
);
}
/*
if (css != null) { // reapply the styles
setStyle(css);
}
*/
}
public
void
setStyle
(
String
css
) {
//((HTMLDocument) getDocument()).getStyleSheet().addRule(css);
this
.
css
=
css
;
rebuild
();
}
/*
public void setURL(String url) {
this.url = url;
}
*/
}
Back
|
FazBrowse Home
|
New Git URL