Java开发人员进入Java Desktop开发

时间:2022-05-26 11:22:51

I've been writing Java web (JSF, Struts, JSR168) apps for a number of years. With the recent departure of a colleague, it looks like I'm going to be building more client applications. I've used Eclipse since the beginning and I'm really comfortable with it. It feels as though SWT is waning (just an opinion based on literature I can find) and Swing is surging.

多年来我一直在编写Java web(JSF,Struts,JSR168)应用程序。随着最近一位同事离职,看起来我将构建更多的客户端应用程序。我从一开始就使用Eclipse,我对它非常满意。感觉好像SWT正在减弱(只是基于我能找到的文献的观点)和Swing正在飙升。

My question: Is there value in learning Swing through writing apps by hand in Eclipse (as opposed to using Matisse in Netbeans)?

我的问题:通过在Eclipse中手工编写应用程序来学习Swing是否有价值(而不是在Netbeans中使用Matisse)?

5 个解决方案

#1


Yes, it is very valuable to learn coding Swing apps by hand. One reason for this is that no GUI-Designer I know always does the things you want them to do. The other - and in my opinion more important reason - is that most GUI builders (especially NetBeans') generate all and everything into one single class. This can be very annoying because the maintainability is reduced a lot (separation of concerns). Also many GUI builders have blocked regions, i.e. you cannot modify the generated code by hand. Or if you do the GUI builder will overwrite it the next time you use it.

是的,学习手动编写Swing应用程序非常有价值。这样做的一个原因是我所知道的GUI-Designer总是做你想让他们做的事情。另一个 - 在我看来更重要的原因 - 是大多数GUI构建器(尤其是NetBeans)将所有内容生成到一个单独的类中。这可能非常烦人,因为可维护性大大降低(关注点分离)。许多GUI构建器也有阻塞区域,即您无法手动修改生成的代码。或者,如果您执行此操作,GUI构建器将在您下次使用时覆盖它。

However that standard LayoutManagers coming with Swing are very complicated. This is why I suggest that you give MigLayout or JGoodies FormLayout a try. On the JGoodies site you also find other libs for alternative Look&Feels, Binding and Validation, which can be very useful.

然而,与Swing一起使用的标准LayoutManagers非常复杂。这就是为什么我建议你试试MigLayout或JGoodies FormLayout。在JGoodies站点上,您还可以找到其他用于替代外观和感觉,绑定和验证的库,这些库非常有用。

I would also suggest that you have a look at the Presentation Model pattern (Martin Fowler), which helps a lot if you want to unit-test your GUI-behaviour.

我还建议你看一下Presentation Model模式(Martin Fowler),如果你想对你的GUI行为进行单元测试,它会有很大的帮助。

If you then are motivated to improve the design and add some very cool effects to your application check out the book Filthy Rich Clients.

如果您有动力改进设计并为您的应用程序添加一些非常酷的效果,请查看Filthy Rich Clients一书。

Hope it helps.

希望能帮助到你。

#2


Yes, definitely - even if you plan on using Matisse most of the time, you will benefit from having at least a reasonable understanding of the Swing code under the hood.

是的,当然 - 即使您计划在大多数时间使用Matisse,您也将受益于至少对Swing代码的合理理解。

#3


It sure will help. Maybe you'll reach the end of what Matisse can do, and want to tweak some of the code by hand. At this point it will be better to know what happens under the hood.

这肯定会有所帮助。也许你会达到马蒂斯可以做到的最终目的,并希望手动调整一些代码。在这一点上,最好知道引擎盖下发生了什么。

#4


Note that using Matisse and writing Swing by hand are not mutually exclusive at all. Matisse just produces Swing code, and you can customize it. You can make part of your GUI with Matisse, and the part next to it by hand, for instance. Get the best of both worlds - that's how I do it, at least.

请注意,使用马蒂斯和手写Swing并不是完全相互排斥的。 Matisse只生成Swing代码,您可以自定义它。例如,您可以使用Matisse创建GUI的一部分,然后手动旁边的部分。充分利用这两个世界 - 至少我是这样做的。

Fast way to learn how to do something in Swing is to do it in Matisse, and then see the code it produced.

学习如何在Swing中执行某些操作的快速方法是在Matisse中执行此操作,然后查看它生成的代码。

#5


You definitively need to know how Swing works since you will most likely have to adapt and change things which the GUI prgram expects you to know how works and what it is called.

你明确地需要知道Swing是如何工作的,因为你很可能必须适应和改变GUI程序希望你知道它是如何工作和被称为什么的东西。

The Java Tutorial has a good Swing trail: http://java.sun.com/docs/books/tutorial/uiswing/

Java Tutorial有一个很好的Swing路径:http://java.sun.com/docs/books/tutorial/uiswing/

#1


Yes, it is very valuable to learn coding Swing apps by hand. One reason for this is that no GUI-Designer I know always does the things you want them to do. The other - and in my opinion more important reason - is that most GUI builders (especially NetBeans') generate all and everything into one single class. This can be very annoying because the maintainability is reduced a lot (separation of concerns). Also many GUI builders have blocked regions, i.e. you cannot modify the generated code by hand. Or if you do the GUI builder will overwrite it the next time you use it.

是的,学习手动编写Swing应用程序非常有价值。这样做的一个原因是我所知道的GUI-Designer总是做你想让他们做的事情。另一个 - 在我看来更重要的原因 - 是大多数GUI构建器(尤其是NetBeans)将所有内容生成到一个单独的类中。这可能非常烦人,因为可维护性大大降低(关注点分离)。许多GUI构建器也有阻塞区域,即您无法手动修改生成的代码。或者,如果您执行此操作,GUI构建器将在您下次使用时覆盖它。

However that standard LayoutManagers coming with Swing are very complicated. This is why I suggest that you give MigLayout or JGoodies FormLayout a try. On the JGoodies site you also find other libs for alternative Look&Feels, Binding and Validation, which can be very useful.

然而,与Swing一起使用的标准LayoutManagers非常复杂。这就是为什么我建议你试试MigLayout或JGoodies FormLayout。在JGoodies站点上,您还可以找到其他用于替代外观和感觉,绑定和验证的库,这些库非常有用。

I would also suggest that you have a look at the Presentation Model pattern (Martin Fowler), which helps a lot if you want to unit-test your GUI-behaviour.

我还建议你看一下Presentation Model模式(Martin Fowler),如果你想对你的GUI行为进行单元测试,它会有很大的帮助。

If you then are motivated to improve the design and add some very cool effects to your application check out the book Filthy Rich Clients.

如果您有动力改进设计并为您的应用程序添加一些非常酷的效果,请查看Filthy Rich Clients一书。

Hope it helps.

希望能帮助到你。

#2


Yes, definitely - even if you plan on using Matisse most of the time, you will benefit from having at least a reasonable understanding of the Swing code under the hood.

是的,当然 - 即使您计划在大多数时间使用Matisse,您也将受益于至少对Swing代码的合理理解。

#3


It sure will help. Maybe you'll reach the end of what Matisse can do, and want to tweak some of the code by hand. At this point it will be better to know what happens under the hood.

这肯定会有所帮助。也许你会达到马蒂斯可以做到的最终目的,并希望手动调整一些代码。在这一点上,最好知道引擎盖下发生了什么。

#4


Note that using Matisse and writing Swing by hand are not mutually exclusive at all. Matisse just produces Swing code, and you can customize it. You can make part of your GUI with Matisse, and the part next to it by hand, for instance. Get the best of both worlds - that's how I do it, at least.

请注意,使用马蒂斯和手写Swing并不是完全相互排斥的。 Matisse只生成Swing代码,您可以自定义它。例如,您可以使用Matisse创建GUI的一部分,然后手动旁边的部分。充分利用这两个世界 - 至少我是这样做的。

Fast way to learn how to do something in Swing is to do it in Matisse, and then see the code it produced.

学习如何在Swing中执行某些操作的快速方法是在Matisse中执行此操作,然后查看它生成的代码。

#5


You definitively need to know how Swing works since you will most likely have to adapt and change things which the GUI prgram expects you to know how works and what it is called.

你明确地需要知道Swing是如何工作的,因为你很可能必须适应和改变GUI程序希望你知道它是如何工作和被称为什么的东西。

The Java Tutorial has a good Swing trail: http://java.sun.com/docs/books/tutorial/uiswing/

Java Tutorial有一个很好的Swing路径:http://java.sun.com/docs/books/tutorial/uiswing/