本文介绍了经验丰富的Java SWT程序员在移动到Swing时应该注意哪些主要内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能遇到的主要区别是什么?应用设计有哪些重大差异?线程模型?您如何构建GUI? SWT的任何功能在Swing中都不可用

What are the major differences which may be encountered? Any major differences in application design? Threading models? The way you go about constructing GUIs? Any features of SWT which aren't available in Swing?

推荐答案

从Swing和SWT之间的经验中得出的一些结果

Few findings from my experience between Swing and SWT


  • Swing的渲染有点慢(我的经验),使用更多的内存

  • 本机外观可能只是部分(取决于所选的look'n'feel)

  • 大多数Swing组件以某种方式实现MVC模式(所以你不必须使自己的数据绑定)

  • 可以对组件进行子类化,当您需要更改某些组件的行为(因此经常使用)时使用它

  • Swing发送程序生成的事件(我讨厌这个行为)]

  • 不得不调用(a)syncExec()方法(你不必关心从哪个线程更新你的GUI,就像在SWT中一样,但一定要阅读和)

  • Swing真的很尴尬(与SWT相比)

  • 没有更多的dispose()方法;]

  • Swing在容器中具有标准的布局管理器(请参阅),并且具有(使用MigLayout,它适用于Swing和SWT以及没有竞争对手)

  • 在组件实例创建之前,必须先了解您的父级,但您必须对父(容器)

  • Sadd不依赖平台(每个平台不再有多重构建d x32 / x64)

  • Swing有自己的错误(作为其他技术,这是不可避免的)

  • Rendering of Swing is a bit slower (my experience) and use much more memory
  • Native look is possible just partially (depends on selected look'n'feel)
  • Most of Swing components somehow implements MVC pattern (so you don't have to make your own data binding)
  • It's possible to subclass components and it is used when you have to change behaviour of some component (so it's used often)
  • Swing sends program generated events (I hate this behavior ;] )
  • In Swing you don't have to call (a)syncExec() method (you don't have to care from which thread you are updating your GUI so much as in SWT, but be sure to read Swing threading policy (end of page) and Concurrency in Swing)
  • Swing is really garrulous (compared to SWT)
  • No more dispose() methods ;]
  • Swing have standard layout manager in containers (see BorderLayout) and have different layout managers in basis (use MigLayout, it's for Swing and SWT as well and have no competitor)
  • You don't have to know your parent on component instance creation, but you'll have to you .add(Component c) method on parent (container)
  • Swing is not platform dependent (no more multi-builds for each platform and x32/x64)
  • Swing have its own bugs (as other technologies, it's inevitable)

这篇关于经验丰富的Java SWT程序员在移动到Swing时应该注意哪些主要内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 08:51