Java GUI Swing 模型说明

2022-01-24 00:00:00 user-interface java swing jframe

我已经使用 Swing 有一段时间了,但是 JFrames、paint()super 的整个模型/结构等在我脑海中都是模糊的.我需要一个清晰的解释或链接来解释整个 GUI 系统是如何组织的.

解决方案

同样的事情发生在我身上.实际上,直到今天我还没有完全了解它是如何工作的.

Swing 是一个非常灵活的框架——也许太灵活了.灵活性带来了很多抽象,而抽象带来了混乱.:)

我发现以下文章值得一读.他们帮助我更好地了解 Swing 的大局.

他们很好地解释了模型和委托是如何工作的.当我看到那些 JLabelLabelUIui.update 等时,总是让我发疯.

I've been working with Swing for a while now but the whole model/structure of JFrames, paint(), super, etc is all murky in my mind. I need a clear explanation or link that will explain how the whole GUI system is organized.

解决方案

The same happened to me. Actually to this day I don't quite get 100% how all it works.

Swing is a very flexible framework - perhaps too flexible. With flexibility comes a lot of abstraction and with abstraction comes confusion. :)

I've found the following articles worth reading. They helped me to better understand the big picture of Swing.

  • A Swing Architecture Overview
  • The process of installing a UI delegate, which is just this image:

They explain quite well how the model and the delegate work. It always drives me mad when I see those JLabel, LabelUI, ui.update, etc.

相关文章