Skip to content

Commit 9f1842f

Browse files
add read-only TextField with honoring look and feel
1 parent 9273e60 commit 9f1842f

File tree

1 file changed

+24
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)