如何在JetPack上制作两个Windows撰写桌面并从窗户到另一个窗口?
例如,当我单击按钮时,如何在JetPack撰写台式机上制作两个窗口,然后从窗口到另一个窗口?
fun main() = application {
Window(
onCloseRequest = ::exitApplication,
title = "Products Manager",
state = rememberWindowState(width = 700.dp, height = 600.dp)
) {
val count = remember { mutableStateOf(0) }
MaterialTheme {
Column(Modifier.fillMaxSize(), Arrangement.spacedBy(5.dp)) {
Button(modifier = Modifier.align(Alignment.CenterHorizontally),
onClick = {
count.value++
}) {
Text(if (count.value == 0) "Hello World" else "Clicked ${count.value}!")
}
Button(modifier = Modifier.align(Alignment.CenterHorizontally),
onClick = {
count.value = 0
}) {
Text("Reset")
}
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要创建多个窗口,您只需要拥有多个
窗口
Composable。查看文档部分。要以编程方式切换在Windows之间,您可以在窗口上使用
window.tofront()
应该成为最高的:window
在frame> frame> frame> framewindowscope
内部可用window.content
。这是一个示例,如何使用两个窗口“类型”完成。您可以用任何其他标识符替换类型。
To create multiple windows, you simply need to have multiple
Window
composables. Check out Open and close multiple windows documentation section for example.To switch between windows programmatically, you can use
window.toFront()
on the window that should become topmost:window
is property available inFrameWindowScope
insideWindow.content
.Here's an example how it can be done with two window "types". You can replace type with any other identifier.