|
|
|
@ -31,10 +31,12 @@ import java.awt.image.BufferedImage
|
|
|
|
|
|
|
|
|
|
fun main() { |
|
|
|
|
val count = mutableStateOf(0) |
|
|
|
|
Window { |
|
|
|
|
Window( |
|
|
|
|
icon = getMyAppIcon() |
|
|
|
|
) { |
|
|
|
|
onActive { |
|
|
|
|
val tray = Tray().apply { |
|
|
|
|
icon(getMyAppIcon()) |
|
|
|
|
icon(getTrayIcon()) |
|
|
|
|
menu( |
|
|
|
|
MenuItem( |
|
|
|
|
name = "Increment value", |
|
|
|
@ -72,6 +74,20 @@ fun main() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun getMyAppIcon() : BufferedImage { |
|
|
|
|
val size = 256 |
|
|
|
|
val image = BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB) |
|
|
|
|
val graphics = image.createGraphics() |
|
|
|
|
graphics.setColor(Color.green) |
|
|
|
|
graphics.fillOval(size / 4, 0, size / 2, size) |
|
|
|
|
graphics.setColor(Color.blue) |
|
|
|
|
graphics.fillOval(0, size / 4, size, size / 2) |
|
|
|
|
graphics.setColor(Color.red) |
|
|
|
|
graphics.fillOval(size / 4, size / 4, size / 2, size / 2) |
|
|
|
|
graphics.dispose() |
|
|
|
|
return image |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun getTrayIcon() : BufferedImage { |
|
|
|
|
val size = 256 |
|
|
|
|
val image = BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB) |
|
|
|
|
val graphics = image.createGraphics() |
|
|
|
@ -98,11 +114,16 @@ import androidx.compose.foundation.layout.Column
|
|
|
|
|
import androidx.compose.foundation.Text |
|
|
|
|
import androidx.compose.material.Button |
|
|
|
|
import androidx.compose.ui.window.Notifier |
|
|
|
|
import java.awt.Color |
|
|
|
|
import java.awt.Graphics2D |
|
|
|
|
import java.awt.image.BufferedImage |
|
|
|
|
|
|
|
|
|
fun main() { |
|
|
|
|
val message = "Some message!" |
|
|
|
|
val notifier = Notifier() |
|
|
|
|
Window { |
|
|
|
|
Window( |
|
|
|
|
icon = getMyAppIcon() |
|
|
|
|
) { |
|
|
|
|
Column { |
|
|
|
|
Button(onClick = { notifier.notify("Notification.", message) }) { |
|
|
|
|
Text(text = "Notify") |
|
|
|
@ -116,6 +137,20 @@ fun main() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun getMyAppIcon() : BufferedImage { |
|
|
|
|
val size = 256 |
|
|
|
|
val image = BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB) |
|
|
|
|
val graphics = image.createGraphics() |
|
|
|
|
graphics.setColor(Color.green) |
|
|
|
|
graphics.fillOval(size / 4, 0, size / 2, size) |
|
|
|
|
graphics.setColor(Color.blue) |
|
|
|
|
graphics.fillOval(0, size / 4, size, size / 2) |
|
|
|
|
graphics.setColor(Color.red) |
|
|
|
|
graphics.fillOval(size / 4, size / 4, size / 2, size / 2) |
|
|
|
|
graphics.dispose() |
|
|
|
|
return image |
|
|
|
|
} |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
![Notifier](notifier.gif) |
|
|
|
|