Skip to content

Commit 24bd500

Browse files
add read-only TextArea honoring look and feel
1 parent 9f1842f commit 24bd500

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.utplsql.sqldev.ui.runner
2+
3+
import java.awt.Graphics
4+
import javax.swing.JTextArea
5+
import javax.swing.UIManager
6+
7+
class RunnerTextArea extends JTextArea {
8+
9+
override paintComponent(Graphics g) {
10+
// default for non-opaque components
11+
if (!opaque) {
12+
super.paintComponent(g)
13+
return
14+
}
15+
16+
// use value of JTextField for consistency
17+
g.color = UIManager.getColor("TextField.inactiveBackground")
18+
g.fillRect(0, 0, width, height)
19+
20+
// do rest, changing opaque to ensure background is not overwritten
21+
setOpaque(false)
22+
super.paintComponent(g)
23+
setOpaque(true)
24+
}
25+
}

0 commit comments

Comments
 (0)