如何在netbeans java swing应用程序中编写模块化代码?
我正在 Netbeans 中创建我的 java Swing 应用程序。目前代码有2000多行。在一个文件中包含这么多行是否正确?此外,当我编辑这个文件时,IDE 变得很慢。有什么办法可以克服这个问题吗?
I am creating my java Swing application in Netbeans. At present there are more than 2000 lines of code. Is it right to have these many number of lines in a single file. Moreover the IDE has become slow when i am editing this file. Is there any way to overcome this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在较大的 swing 项目中,我对应用程序进行分区,如下所示:
每个 GUI 元素(如 JPanel、JDialog 等)有一个类。
使用单独的类为每个屏幕使用单独的包,特别是如果您必须实现自定义的 TableModel 或其他复杂的数据结构
不要使用匿名类和内部类,请实现 ActionListener 并检查其中的 ActionEvent.getActionCommand()。
In larger swing projects I do partinioning of the app like that:
Have one class per GUI element like JPanel,JDialog etc.
Use a separate package for each screen, especially if you have to implement customized TableModels or other complex data structures
Don't use anonymous and inner classes, implement instead an ActionListener and check ActionEvent.getActionCommand() in there.