简体   繁体   English

我应该如何有效地更新Swing GUI?

[英]How should I efficiently update a Swing GUI?

I created a program with a Swing GUI in NetBeans a while back using the Graphical Editor. 我使用图形编辑器使用NetBeans中的Swing GUI创建了一个程序。 I now needed a web version but since I use eclipse now I copied + pasted the code into a new Web Applet project. 我现在需要一个Web版本,但是由于我现在使用eclipse,所以我将代码复制+粘贴到了一个新的Web Applet项目中。 I found some problems I didn't spot before and updated the code in the web applet. 我发现了一些以前没有发现的问题,并更新了Web小程序中的代码。

I want to add some buttons to the GUI, but one problem is its an annoyance to find the part of the code where NetBeans put all the variable declarations, then find another part of the code where all the fields are initialised, then find the other part of the code where the layout needs to be defined, then find the other part of the code where all the action listeners are added, etc... Another problem is that the Swing layouts are complex and also an annoyance to hard code... it is difficult to judge what the exact outcome will look like when you have to edit GroupLayouts with other swing components already layed out in them. 我想在GUI上添加一些按钮,但是一个问题是它很烦恼,无法找到NetBeans放置所有变量声明的代码部分,然后找到初始化所有字段的代码的另一部分,然后找到另一个一部分代码需要定义布局,然后找到另一部分添加所有动作侦听器的代码,依此类推。另一个问题是Swing布局很复杂,并且对硬代码也很烦。 。当您必须使用已经在其中布置的其他swing组件编辑GroupLayouts时,很难判断确切的结果。

Also, I can't edit this in NetBeans because the Generator is very fussy and if I copy+paste code in there it wont read it as a Java Form nor generate an XML file which I think it uses to manage your layout. 另外,我无法在NetBeans中进行编辑,因为Generator非常繁琐,如果我在其中复制+粘贴代码,它将无法将其读取为Java Form,也不会生成XML文件(我认为该文件用于管理布局)。

Are there any free GUI designers out there that take a bunch of java swing code and allow you to graphically edit it? 有没有免费的GUI设计器需要一堆Java Swing代码并允许您以图形方式对其进行编辑? How do professionals manage their graphical layouts? 专业人士如何管理其图形布局?

So I should have implemented the Model-View approach from the start. 所以我应该从一开始就实现Model-View方法。

Here is a nice tutorial on the subject: http://people.csail.mit.edu/phw/OnToJava/ONTOJAVA755.HTML 这是有关该主题的不错的教程: http : //people.csail.mit.edu/phw/OnToJava/ONTOJAVA755.HTML

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

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