如何通过某些组中最长的文本自动设置字段的最小宽度
我使用 iReport 创建报告,我想知道是否有办法设置“光学分组字段”的宽度。应将它们设置为仍显示最长文本的最小尺寸。我的左侧有静态文本,右侧有文本字段。此文本字段设置为宽度 150 并向右对齐,但我想设置较小的尺寸以消除空格。
考虑这样的事情
Name: Paul
Surname: Smither
,并希望自动
Name: Paul
Surname: Smither
等可以小于预设尺寸,但不能更大。
有办法吗??甚至某些组件
I use iReport to create reports, and I would like to know if there is a way to set the width of "optically grouped fields". They should be set to the minimal size that still displays longest text. I have Static Text on left side and Text Field right of them. This Text Fields are set to the width 150 and alignment to right, but I'd like to set smaller size to wipe out white spaces.
Consider some thing like this
Name: Paul
Surname: Smither
And want automatically to
Name: Paul
Surname: Smither
etc. can be smaller then preset size but no bigger.
Is there a way?? even some component
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果不使用 Java 框架,您无法动态更改元素宽度。
引用自 JasperReports 终极指南:
您可以阅读这篇文章以更好地了解更改元素大小。
You cannot change the element width dynamically without using Java frameworks.
The quote from JasperReports Ultimate Guide:
You can read this article for better understanding the mechanism of changing the element size.
如果它确实只是来自数据集中同一行的几个字段,那么您可以将某些内容组合在一起。
$P{MaxLengthString} 默认值为 10 个空格:
" "
将字段文本从
$F{FirstName}
更改为:那是...呃...有点复杂。它仅适用于等宽字体。我不敢相信我真的建议了这个。不要这样做。 (但它应该有效。)
If it's genuinely just a couple of fields that come from the same row in the dataset, then you could hack something together.
$P{MaxLengthString} default value is 10 spaces:
" "
Change your field text from
$F{FirstName}
to this:That is... er... a bit more complex. And it only works with monospace fonts. And I can't believe I really suggested this. Don't do it. (But it ought to work.)