简体   繁体   English

有没有办法在Eclipse中从Visual Editor创建的GUI转换为WindowBuilder GUI?

[英]Is there a way to convert from Visual Editor created GUI to WindowBuilder GUI in Eclipse?

Since Visual Editor is no longer supported in newer versions of eclipse, I am trying to make the switch to WindowBuilder. 由于新版本的eclipse不再支持Visual Editor,因此我尝试切换到WindowBuilder。

It seems that I should just be able to open a panel created in Visual Editor in WindowBuilder and all components should display, but this does not seem to be the case. 看来我应该能够在WindowBuilder中打开在Visual Editor中创建的面板,并且所有组件都应该显示,但是事实并非如此。 All components sizes seem to come in as 0px x 0px and even after changing this, the components still do not show up in the preview window. 所有组件的大小似乎都为0px x 0px,即使更改了此大小,组件仍不会显示在预览窗口中。

All components are custom that extend the standard JComponent (such as JLabel). 所有组件都是自定义的,它们扩展了标准JComponent(例如JLabel)。

I am not sure if the problem is some sort of incompatibility, the fact that I am using custom components and containers, or a problem with my WindowBuilder installation (or something else!). 我不确定问题是某种形式的不兼容性,还是我正在使用自定义组件和容器,或者我的WindowBuilder安装是否有问题(或其他问题!)。 Does anyone have any insight? 有人有见识吗? I would be much appreciated! 我将不胜感激! :) :)

如果我正确理解了您的问题,那么您只需在包浏览器中的类上单击右键> Open with> WindowBuilder Editor

I have found that sometimes the code doesn't transfer over nicely when trying to directly re-open the file using the WindowBuilder editor. 我发现有时尝试使用WindowBuilder编辑器直接重新打开文件时,代码无法很好地传递。 I found that creating a new WindowBuilder document of the same type as your existing code, then replacing the file contents works pretty well, if you don't mind the inconvenience. 我发现创建一个与您现有代码相同类型的新WindowBuilder文档,然后替换文件内容的效果很好,如果您不介意麻烦的话。

After working on this problem for some time I have found out what was causing the errors. 解决此问题一段时间后,我发现了导致错误的原因。 It seems that Visual Editor was a bit more forgiving when parsing the code to display the preview. 在解析代码以显示预览时,Visual Editor似乎更加宽容。

My issues with Window Builder generally stemmed from the following things: 我与Window Builder有关的问题通常源于以下方面:

  • lack of paramterless contructors in both the panel/dialog to be displayed and components within. 在要显示的面板/对话框和其中的组件中都缺少无参数的构造函数。 WB relies on these constructors to parse the code WB依靠这些构造函数来解析代码
  • trouble getting dynamically generated resources which led to throwing null pointer exceptions. 获取动态生成的资源会导致抛出空指针异常的麻烦。 Visual Editor seemed to ignore these and display what it could. Visual Editor似乎忽略了这些内容并显示了可能的内容。 Window Builder would not display any part of the offending component. Window Builder将不会显示问题组件的任何部分。 Adding null checks in certain places remedied this. 在某些地方添加空检查可以解决此问题。

After fixing these problems, I did not have to recreate any of my GUI screens in Window Builder 解决这些问题后,我不必在Window Builder中重新创建任何GUI屏幕

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

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