Skip to content

Instantly share code, notes, and snippets.

@Foso
Created November 7, 2020 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Foso/88cde0855153d8851d1368fc64404033 to your computer and use it in GitHub Desktop.
Save Foso/88cde0855153d8851d1368fc64404033 to your computer and use it in GitHub Desktop.
import androidx.compose.desktop.AppWindow
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Button
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import java.awt.BorderLayout
import javax.swing.JButton
import javax.swing.JLabel
import javax.swing.JPanel
import javax.swing.SwingUtilities.invokeLater
fun main() {
invokeLater {
val appWindow = AppWindow()
val pane = JPanel()
val jBtn = JButton()
val jlabel = JLabel()
jlabel.text = "LABEL"
pane.add(jBtn)
pane.add(jlabel)
appWindow.window.add(pane, BorderLayout.NORTH)
appWindow.show {
val scaleFactor = remember { mutableStateOf(1) }
jBtn.addActionListener {
scaleFactor.value++
}
jBtn.text = "JButton " + scaleFactor.value
jlabel.text = "LAB" + scaleFactor.value
Column {
Text("HALLO" + scaleFactor.value)
Button(onClick = { scaleFactor.value++ }) {
Text("Click me")
}
}
}
}
}
@Foso
Copy link
Author

Foso commented Nov 7, 2020

Screenshot from 2020-11-07 21-50-51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment