我有这个kotlin代码:
private fun showNoMoreCards() = showContent {
row {
label(gapLeft = LEFT_MARGIN, text = "Congratulations, you've reviewed all the cards for now!")
}
}
fun showContent(init: LayoutBuilder.() -> Unit) {
val panel = panel(LCFlags.fill) {
init()
}
val content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false)
toolWindow.contentManager.removeAllContents(false)
toolWindow.contentManager.addContent(content)
}
```
我不了解也不想学习kotlin,我想用Java来做。有很多这样的代码,我只需要一些指导(大概是JPanels之类的东西)就可以了-有人可以给我大致等效的Java代码吗?
中找到此代码答案 0 :(得分:1)
抱歉,这可能会稍微有些偏离,但这是我能做到的最好的Java 8提供的代码量(并且无需实际阅读提供的Github存储库):
private void showNoMoreCards() {
showContent((layoutBuilder) -> {
layoutBuilder.row((rowBuilder) -> {
rowBuilder.label(LEFT_MARGIN, "Congratulations, you've reviewed all the cards for now!");
});
});
}
public void showContent(java.util.function.Consumer<LayoutBuilder> init) {
JPanel panel = panel(LCFlags.fill, () -> {
init.apply(layoutBuilder);
});
Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false)
toolWindow.getContentManager().removeAllContents(false);
toolWindow.getContentManager().addContent(content);
}