IDEA Plugin JB* Components

Brice Dutheil 昨天 下午 3:09

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 条回复


Yann Cébron:jb: 1 天前

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 HelpIntelliJ 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 HelpIntelliJ Platform Plugin SDK Help

Miscellaneous Swing Components | IntelliJ Platform Plugin SDK (64 kB)

https://plugins.jetbrains.com/docs/intellij/misc-swing-components.html

:+1:1

Yann Cébron:jb: 1 天前

when using https://plugins.jetbrains.com/docs/intellij/kotlin-ui-dsl.html you’ll get recommended components automatically

IntelliJ Platform Plugin SDK HelpIntelliJ Platform Plugin SDK Help

Kotlin UI DSL | IntelliJ Platform Plugin SDK (64 kB)

https://plugins.jetbrains.com/docs/intellij/kotlin-ui-dsl.html

Brice Dutheil 1 天前

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.

Yann Cébron:jb: 1 天前

mostly, they fix known bugs in Swing or certain OS

:+1:1

Scott Wells 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.

:向上:1:+1:1:祈祷:1

Brice Dutheil 4 小时前

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

Brice Dutheil 4 小时前

Thank you both

Scott Wells 28 分钟前

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.

Yann Cébron:jb: 24 分钟前

psst com.intellij.ui.HtmlToSimpleColoredComponentConverter

Brice Dutheil 22 分钟前

Interesting, I wonder if one can hook actions on <a> tagged text.

Yann Cébron:jb: 21 分钟前

there’s dedicated com.intellij.ui.components.labels.LinkLabel

Brice Dutheil 19 分钟前

Yes but what if we need different actions for different part of the “text”

Yann Cébron:jb: 18 分钟前

com.intellij.ui.components.JBLabel#createHyperlinkListener and inspect HyperlinkEvent

Scott Wells 2 分钟前

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. (已编辑)

原文地址:https://www.cnblogs.com/beansoft/p/15404407.html