如何在netbeans java swing应用程序中编写模块化代码?

发布于 2024-09-01 02:26:01 字数 108 浏览 6 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空心↖ 2024-09-08 02:26:01

在较大的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文