Hi,
Is there a reference documentation somewhere about the JB*
components, what each bring over the regular swing ones. Without (Java)doc currently we can look at the code but it’d be nice if a reference was available. (The current code base is in Java)
14 条回复
some are documented here https://plugins.jetbrains.com/docs/intellij/lists-and-trees.html and https://plugins.jetbrains.com/docs/intellij/misc-swing-components.html
IntelliJ Platform Plugin SDK Help
List and Tree Controls | IntelliJ Platform Plugin SDK (64 kB)
https://plugins.jetbrains.com/docs/intellij/lists-and-trees.html
IntelliJ Platform Plugin SDK Help
Miscellaneous Swing Components | IntelliJ Platform Plugin SDK (64 kB)
https://plugins.jetbrains.com/docs/intellij/misc-swing-components.html
1
when using https://plugins.jetbrains.com/docs/intellij/kotlin-ui-dsl.html you’ll get recommended components automatically
IntelliJ Platform Plugin SDK Help
Kotlin UI DSL | IntelliJ Platform Plugin SDK (64 kB)
https://plugins.jetbrains.com/docs/intellij/kotlin-ui-dsl.html
I have seen some these links and they are indeed what I am looking for, but the UI toolkit you’ve built have way more component or utils, JBScrollPane, JBLabel, JBTextField, CellRendererPanel, RelativeFont, JBFont, etc.
mostly, they fix known bugs in Swing or certain OS
1
Obviously far from scientific, but my stance is to use the JB version of a component over the Swing version of the same component when available assuming that 1) it's going to provide a more homogeneous look-and-feel within the host IDE; 2) it's likely that it's fixed bugs and/or tuned to perform better. And note that not all JB components are named as such, e.g., ComboBox
vs. JComboBox
.
111
Yes I discovered the ComboBox yesterday as well, there are not all located in the same ui
parent packages, eg:
com.intellij.ui.table.JBTable
com.intellij.openapi.ui.ComboBox
Thank you both
On the same topic, one of my absolute favorite JB components is SimpleColoredComponent
and its derivatives Colored*CellRenderer
. Think of these as being a replacement for JLabel
when you want to have styled text fragments.
psst com.intellij.ui.HtmlToSimpleColoredComponentConverter
Interesting, I wonder if one can hook actions on <a>
tagged text.
there’s dedicated com.intellij.ui.components.labels.LinkLabel
Yes but what if we need different actions for different part of the “text”
com.intellij.ui.components.JBLabel#createHyperlinkListener
and inspect HyperlinkEvent
I actually implemented my own very simple HyperlinkLabel
component because LinkLabel
didn't quite do what I wanted/needed. Specifically I wanted a label that could behave like a hyperlink in some situations and like a regular label in others when there's no clickable status. It ends up being <50 lines of code (including white space) as a small subclass of SimpleColoredComponent
, so the cost of ownership is very, very low for a component that does exactly what I need. (已编辑)