Java Swing:Flyweight与新窗口 [英] Java Swing: flyweight vs new windows

查看:109
本文介绍了Java Swing:Flyweight与新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个新的应用程序,在该应用程序中,我将同时打开一些窗口. 我目前正在尝试设计GUI,但我在两种选择中苦苦挣扎:

I'm developing a new application where I'll have some windows opened at the same time. I'm currently trying to design the GUI and I'm struggling with two choices:

  1. 我可以使用侧面导航面板,并使用页面的中心显示每个面板的内容.这些面板将按照重量级模式存储,我只是在单击导航按钮时将其隐藏/显示(以便按隐藏时的原样保存内容,例如用户注册表格).

  1. I could use a side navigation panel and using the center of the page to display the content of each panel. These panels would be stored according flyweight pattern and I would just hide/show them when navigation buttons are clicked (in order to save the content as is was when hidden, for example a user registration form).

我可以使用首页显示整个菜单,并使用弹出窗口/新窗口显示内容.这些可以关闭/最小化,等等.)

I could use a front page displaying the menu all over it and use popups/new windows to show the content. These could be closed/minimized etc).

我的问题是:如果所有面板都以我的举重模式存储怎么办?它会带来巨大的性能影响还是会在存储15个JPanels的情况下仍然平稳运行? (当然,那些JPanels有时会包含很多内容,例如表单等).

My problem is: What if all the panels are stored in my flyweight pattern? will it have a huge performance hit or will it still run smoothly with like 15 JPanels stored? (of course those JPanels will have sometimes lots of content in it such as forms etc).

您认为什么是最佳的易用/性能选择?

What do you think would be the best easy-to-use/performance choice ?

谢谢:)

推荐答案

JTable 渲染已经使用了 flyweight模式,因此列表是选择的理想选择.自定义渲染器可以显示任意缩略图表示,而ListSelectionListener可以在相邻容器中显示任意细节.如果单个数据记录占用的内存过多,请在TableModel中考虑 LRU缓存.

JTable rendering already uses the flyweight pattern, so a one column table is ideal for selection. A custom renderer can display an arbitrary thumbnail representation, while a ListSelectionListener can display arbitrary detail in an adjacent container. In the TableModel, consider an LRU cache if the individual data records are consuming too much memory.

与性能问题一样,原型 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆