Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想根据单元格的大小调整 JGoodies 表单布局内的图像大小,即使图像完全适合单元格。如果我理解正确,单元格没有真正的组件,大小只有布局管理器隐式知道,对吗?有任何想法吗?
正如 kleopatra 所建议的,我找到了这个解决方案: 图像被放在一个滚动窗格中,我得到了单元格的可见大小
javax.swing.JComponent.getVisibleRect().getWidth();
JPanel 是 JComponent... 我不能直接粘贴更多代码,因为我们使用了其他包装 Swing 的框架,我没有直接测试,抱歉。如果其他人遇到此问题并使用此解决方案,请添加低级 Swing 代码,谢谢。
感谢您的建议!