简体   繁体   English

将awt转换为自动摆动

[英]convert awt to swing automatically

From what I know and have been reading, converting from awt to swing seems to be quite mechanical. 从我所知道和已经阅读过的内容来看,从awt到swing的转换似乎是非常机械的。 With the exception of the different threading model, most of swing components generally map well with the awt ones. 除了不同的线程模型之外,大多数摆动组件通常与awt组件很好地对应。

Was looking for a tool to do this conversion automatically. 正在寻找一种自动执行此转换的工具。 Understandably, this may not be a 100% conversion, but at least the mechanical process should be fairly automated. 可以理解,这可能不是100%的转换,但至少机械过程应该是相当自动化的。 Would any one know of a such a tool ? 有人会知道这样的工具吗?

Why a script changing AWT to Swing component names will not be sufficient. 为什么脚本将AWT更改为Swing组件名称是不够的。

  • Swing components must be constructed & updated on the EDT. 必须在EDT上构建和更新Swing组件。 This restriction does not apply to AWT. 此限制不适用于AWT。
  • Pre 1.5(?) components needed to be added to Swing top level containers using getContentPane().add() 需要使用getContentPane()将Pre 1.5(?)组件添加到Swing顶级容器中.add()
  • Scrolling is different between an AWT TextArea (built-in) & Swing JTextArea (wrapped in a JScrollPane ) AWT TextArea (内置)和Swing JTextArea (包装在JScrollPane )之间的滚动是不同的
  • Constructors may vary. 构造者可能会有所不同。 EG no JTextArea(String,int,int,int) EG没有JTextArea(String,int,int,int)
  • In non TLCs. 在非TLC中。 Override paint(Graphics) in AWT, paintComponent(Graphics) in Swing. 覆盖AWT中的paint(Graphics),Swing中的paintComponent(Graphics)。
  • There is no direct equivalent of Canvas . Canvas没有直接的等价物。
  • A CheckBox might be translated to a JCheckBox , but a CheckBox in a CheckBoxGroup should be converted to a JRadioButton in a ButtonGroup . CheckBox可能会被转换为JCheckBox ,但CheckBox中的CheckBoxGroup应该转换为ButtonGroupJRadioButton

Advantages of Swing it will miss. Swing的优点将会错过。

  • JFrame has a defaultCloseOperation(int) , which can (often) replace the AWT WindowListener . JFrame有一个defaultCloseOperation(int) ,它可以(经常)替换AWT WindowListener

there is a good article http://java.sys-con.com/node/36335 有一篇很好的文章http://java.sys-con.com/node/36335

by reading this article it should be fairly easy to build this awt to swing tool yourself. 通过阅读本文,自己构建这个awt应该相当容易。 you could write a search/replace script to change the names of the AWT components to the corresponding Swing ones. 你可以编写一个搜索/替换脚本来将AWT组件的名称更改为相应的Swing组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM