Skip to content

Commit e802329

Browse files
add toolbar based on JToolBar to mimic look & feel of SQLDev
this way the GUI can be shown outside of the IDE, that simplifies development
1 parent 435bb51 commit e802329

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.utplsql.sqldev.ui.runner
2+
3+
import java.awt.Color
4+
import java.awt.GradientPaint
5+
import java.awt.Graphics
6+
import java.awt.Graphics2D
7+
import javax.swing.JToolBar
8+
9+
class GradientToolbar extends JToolBar {
10+
override paintComponent(Graphics g) {
11+
// default for non-opaque components
12+
if (!opaque) {
13+
super.paintComponent(g)
14+
return
15+
}
16+
17+
// paint gradient background from top to bottom
18+
val g2d = g as Graphics2D
19+
val w = width
20+
val h = height
21+
val h2 = height / 2 as int
22+
val colorTop = new Color(237, 237, 237)
23+
val colorMiddle = new Color(244, 244, 244)
24+
val colorBottom = new Color(254, 254, 254)
25+
val gp1 = new GradientPaint(0, 0, colorTop, 0, h2, colorMiddle)
26+
g2d.paint = gp1
27+
g2d.fillRect(0, 0, w, h2)
28+
val gp2 = new GradientPaint(0, h2, colorMiddle, 0, h, colorBottom)
29+
g2d.paint = gp2
30+
g2d.fillRect(0, h2, w, h)
31+
32+
// do rest, changing opaque to ensure background is not overwritten
33+
setOpaque(false)
34+
super.paintComponent(g)
35+
setOpaque(true)
36+
}
37+
38+
}

0 commit comments

Comments
 (0)