java Google Web Toolkit 是否类似于 AWT 和 Swing

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/407506/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 12:16:12  来源:igfitidea点击:

Is Google Web Toolkit similar to AWT and Swing

javaswinggwtawt

提问by Bill K

I've looked breifly into GWTand like the idea that I can develop in Java and have the application compile down to HTML and JavaScript. Is the concept behind GWT and AWT and Swing the same or different?

我简要地研究了GWT并且喜欢我可以用 Java 开发并将应用程序编译为 HTML 和 JavaScript 的想法。GWT 和 AWT 以及 Swing 背后的概念是相同还是不同?

采纳答案by Sathish

GWT is very much similar to Swing in its usage of Widgets, Panels and the EventListeners it provides. A different way to look at GWT is to think of Javascript and HTML as Assembly language and GWT as a sort of High level language which generates Javascript and HTML. With GWT its easy to develop desktop-like apps for the web using the same tools you would use for building a desktop app

GWT 在使用小部件、面板和它提供的事件侦听器方面与 Swing 非常相似。看待 GWT 的另一种方式是将 Javascript 和 HTML 视为汇编语言,将 GWT 视为一种生成 Javascript 和 HTML 的高级语言。使用 GWT,可以使用与构建桌面应用程序相同的工具轻松为 Web 开发类似桌面的应用程序

回答by Bill K

It is programmed very similarly(patterned after Swing) and the code is 100% java (compiles with a standard Java compiler without errors), but the way it works is very different. Instead of compiling into a Java app, it compiles into Javascript that is sent to your browser.

它的编程非常相似(在 Swing 之后进行模式化)并且代码是 100% java(使用标准 Java 编译器编译而没有错误),但它的工作方式非常不同。它不是编译成 Java 应用程序,而是编译成发送到浏览器的 Javascript。

This ability to program good active Javascript without actually coding Javascript and HTML is pretty nice.

这种无需实际编码 Javascript 和 HTML 即可编写良好的活动 Javascript 的能力非常好。

Also, since it programs much like swing, you can do stuff like adding listeners that effect other controls pretty easily.

此外,由于它的编程方式与 Swing 非常相似,因此您可以很容易地添加影响其他控件的侦听器。

回答by Yoni Roit

Define concept.

定义概念。

AWT/Swing are used for desktop Java apps or applets. They both require JVM to run.

AWT/Swing 用于桌面 Java 应用程序或小程序。它们都需要 JVM 才能运行。

GWT is used to translate Java code to Javascript. This only runs on Javascript engines, i.e. browser.

GWT 用于将 Java 代码转换为 Javascript。这仅在 Javascript 引擎上运行,即浏览器。

The API design, as stated above, is similar to Swing. You get the same Panels, Buttons and other Component classes as in Swing.

如上所述,API 设计类似于 Swing。您将获得与 Swing 中相同的面板、按钮和其他组件类。

回答by Paul Tomblin

AWT and Swing are for programming stand-alone applications (and to a lesser extent, applets). GWT is supposed to make programming web applications similar to stand-alone apps. I wouldn't program a non-web app using GWT.

AWT 和 Swing 用于编写独立的应用程序(以及在较小程度上用于小程序)。GWT 应该使编程 Web 应用程序类似于独立应用程序。我不会使用 GWT 编写非 Web 应用程序。

回答by Powerlord

GWT is conceptually similar to Swing, but is more a replacement for JSPs than anything else.

GWT 在概念上与 Swing 相似,但更像是 JSP 的替代品。

回答by stlawrence

GWT is a javascript toolkit that allows you to write the javascript in Java. The only real similarities to Swing and AWT are that they are toolkits for creating user interfaces and they use Java. The end product is different and the real purpose for using them is different. GWT gives you the ability to generate a ajax user interface for a web browser while the other 2 give you a console (or applet) java app. In my mind the real reason for using GWT is to get a quick ajax interface up for prototyping purposes. But I dont think its really production ready- ie I dont thing Google uses it in their own webapps. A better choice for more robust ajax webapps is http://developer.yahoo.com/yui/or http://script.aculo.us/.

GWT 是一个 javascript 工具包,允许您用 Java 编写 javascript。Swing 和 AWT 唯一真正的相似之处在于它们是用于创建用户界面的工具包,并且它们使用 Java。最终产品不同,使用它们的真正目的也不同。GWT 使您能够为 Web 浏览器生成 ajax 用户界面,而另外两个则为您提供控制台(或小程序)java 应用程序。在我看来,使用 GWT 的真正原因是为原型设计目的获得一个快速的 ajax 界面。但我认为它并没有真正准备好生产 - 即我不认为谷歌在他们自己的 web 应用程序中使用它。更健壮的 ajax webapps 的更好选择是http://developer.yahoo.com/yui/http://script.aculo.us/

回答by Henrik Paul

disclamer: While I do work at IT Mill, this is just for information to the original poster. This isn't marketing spam.

免责声明:虽然我在 IT Mill 工作,但这只是为了提供原始海报的信息。这不是营销垃圾邮件。

If you like the idea of being able to write Java and get a webpage out of that, you might be interested in IT Mill Toolkit. It's a toolkit for making RIA software on top of a J2EE stack, and it uses GWT heavily.

如果您喜欢能够编写 Java 并从中获取网页的想法,您可能对IT Mill Toolkit感兴趣。它是用于在 J2EE 堆栈之上制作 RIA 软件的工具包,并且大量使用 GWT。

One of the basic ideas are that the code generated by GWT is just as prone to client-side forging attacks as any other JS/Ajax-traffic. IT Mill Toolkit makes sure that the data is validated server-side too.

基本思想之一是 GWT 生成的代码与任何其他 JS/Ajax 流量一样容易受到客户端伪造攻击。IT Mill Toolkit 确保数据也在服务器端得到验证。

The toolkit is also designed in such a way that if you are familiar to Swing, you should have no problems picking it up.

该工具包的设计方式也是如此,如果您熟悉 Swing,则上手应该没有问题。