首页 \ 问答 \ SWT StyledText是否有高度限制?(Does SWT StyledText have a height limit?)

SWT StyledText是否有高度限制?(Does SWT StyledText have a height limit?)

我正在尝试创建一个包含ScrolledComposite中显示的StyledText框的应用程序。 我在StyledText框中显示大量行有困难(超过2,550似乎会导致问题)。

StyledText框本身不能有滚动条,但必须可以通过ScrolledComposite滚动。 由于StyledText下方和上方还有其他需要滚动的项目,我不想要多个滚动条。

因此,对于大量数据,我有一个非常大(如高度)的StyledText框似乎在一定高度后停止。

截图

问题是StyledText应该和它的内容一样高,而不是。 下面的差距的原因是包含复合材料正在调整StyledText报告的高度,但实际上它不是它的高度。

这是一段简化的示例代码来说明我的问题:

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


public class ExpandBox2
{
    public static void main(String[] args)
    {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setText("Example");
        shell.setLayout(new FillLayout());

        ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.V_SCROLL);
        scrolledComposite.setLayout(new FillLayout(SWT.VERTICAL));

            Composite mainComp = new Composite(scrolledComposite, SWT.NONE);
        mainComp.setLayout(new FillLayout(SWT.VERTICAL));

        StyledText styledText = new StyledText(mainComp, SWT.NONE);
        styledText.getContent().setText(bigString());

        mainComp.setSize(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));

        scrolledComposite.setContent(mainComp);
        scrolledComposite.setMinSize(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        scrolledComposite.setExpandHorizontal(true);
        scrolledComposite.setExpandVertical(true);
        scrolledComposite.getVerticalBar().setIncrement(10);


        shell.setSize(400, 350);
        shell.open();
        while (!shell.isDisposed ()) {
            if (!display.readAndDispatch ()) {
                display.sleep ();
            }
        }
        display.dispose();

    }

    private static String bigString()
    {
        String big = "";

        for(int i=0;i<10000;i++)
        {
            big = big + "hello\r\n";
        }

        return big;
    }

}

更新:有趣的是,SWT Label和SWT Text会出现此问题


I am trying to create an application that contains a StyledText box displayed within a ScrolledComposite. I am having difficulties displaying a large number of lines in my StyledText box (over 2,550 seems to cause issues).

The StyledText box must not itself have a scroll bar but must be scrollable via the ScrolledComposite. As there are other items below and above the StyledText that need to be scrollable to and I do not want multiple scroll bars.

Hence with large amounts of data I have a very large (as in height) StyledText box that seems to stop after a certain height.

Screenshot

The issue is that the StyledText should be as tall is its contents and it is not. The reason for the gap underneath is that the containing composite is resizing what StyledText reports to be its height but this is not in fact its height.

Here is a piece of simplified example code to illustrate my issue:

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


public class ExpandBox2
{
    public static void main(String[] args)
    {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setText("Example");
        shell.setLayout(new FillLayout());

        ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.V_SCROLL);
        scrolledComposite.setLayout(new FillLayout(SWT.VERTICAL));

            Composite mainComp = new Composite(scrolledComposite, SWT.NONE);
        mainComp.setLayout(new FillLayout(SWT.VERTICAL));

        StyledText styledText = new StyledText(mainComp, SWT.NONE);
        styledText.getContent().setText(bigString());

        mainComp.setSize(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));

        scrolledComposite.setContent(mainComp);
        scrolledComposite.setMinSize(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        scrolledComposite.setExpandHorizontal(true);
        scrolledComposite.setExpandVertical(true);
        scrolledComposite.getVerticalBar().setIncrement(10);


        shell.setSize(400, 350);
        shell.open();
        while (!shell.isDisposed ()) {
            if (!display.readAndDispatch ()) {
                display.sleep ();
            }
        }
        display.dispose();

    }

    private static String bigString()
    {
        String big = "";

        for(int i=0;i<10000;i++)
        {
            big = big + "hello\r\n";
        }

        return big;
    }

}

Update: Interestingly this problem occurs with SWT Label and SWT Text


原文:https://stackoverflow.com/questions/4510579
更新时间:2022-05-08 22:05

最满意答案

似乎QASM是重命名的过程,因此很多链接都被破坏了。 您可以在此github位置找到Open Quantum汇编语言规范:

https://github.com/IBM/qiskit-openqasm/tree/master/

PDF中的日期是2017年1月。


It seems that QASM is the process of being renamed, so many of the links are broken. You can find the Open Quantum Assembly Language spec at this github location:

https://github.com/IBM/qiskit-openqasm/tree/master/

The date in the PDF is January 2017.

相关问答

更多
  • 我的问题是:如果x.precomputedValue为true ,是否会计算functionReturningBoolean(x) ? 编号&&和|| 在Scala中短路。 你可以从文档中看出: 此方法使用“短路”评估,其行为就像声明为def ||(x: => Boolean): Boolean 。 如果计算结果为true ,则返回true而不评估b 。 更一般地说:只要编译器在“OR”语句中看到值为true ,它是否会查看语句中的第二个条件? 类似地,在一个“AND”语句中,例如a && b ,如果a是假 ...
  • 你最后的要点很可能是原因。 在python3.3中 ,默认情况下启用了哈希随机化来解决安全问题。 基本上,这个想法是,你现在永远不知道你的字符串将如何散列(这决定了它们在字典中的顺序)。 这里有一个演示: d = {"a": 1, "b": 2, "c": 3} print(d) 在我的机器上,使用python3.4,这导致了3种不同的排序结果: $ python3.4 test.py {'a': 1, 'c': 3, 'b': 2} $ python3.4 test.py {'c': 3, 'b': 2 ...
  • 如果您只想在数字0,1,...,9上获得离散的均匀分布,那么只需使用样本 sample(0:9, k, replace = TRUE) 使用你现在拥有的代码,你实际得到的概率为0.05,每个得到0或10,概率为.10,得到1-9。 If all you want to do is get a discrete uniform distribution on the numbers 0, 1, ..., 9 then just use sample sample(0:9, k, replace = TRUE ...
  • 它可能不会帮助整体速度(正如@Ander在他的回答中提到的那样),但是您可以做出的一点小改进就是直接在GPU上构建随机数字,如下所示: rand(1, 10000, 'gpuArray') 一般来说,GPU上的随机数生成要比CPU上的快得多。 你可以进一步使用gpuArray版本,它将JIT编译成本机GPU代码。 在我的GPU(Tesla K20c)上,这使GPU的版本比CPU版本快10倍。 以下是完整的脚本: %% CPU version tic Array=zeros(1,1000); for j=1 ...
  • 我在你的代码中发现了一些问题: compute_dE方法返回错误的能量,因为因子2不应该存在。 伊辛系统的汉密尔顿主义是 在你有效使用的同时 compute_energy方法返回错误的能量。 该方法应仅迭代每个旋转对一次。 像这样的东西应该做的伎俩: for (unsigned int i = 0; i < max; i++) { for (unsigned int j = i + 1; j < max; j++) { energy_sum += other.compute_point_energy(i, ...
  • 没有用于管理GUI运行状态的API。 原因是,您可以在Cmdenv中运行模拟而无需重新编译代码,并且在Cmdenv中暂停模拟是不可能/没有意义的。 但是你可以做一个技巧,因为模拟是可重复的: 添加一些代码,在特定条件发生时打印出事件编号。 运行模拟并记下模拟运行时打印出的事件编号。 现在再次开始模拟(使用相同的参数),但使用“Run until ... / Event number”并指定GUI应停止的事件编号。 There is no API for managing the GUI's run stat ...
  • 这里有一些经典的代码翻转硬币并计算你得到多少头: def coin_count(): bit = False counter = 0 for _ in range(500): bit ^= random() < 0.5 # False → 50% False, 50% True # True → 50% False, 50% True if bit: counte ...
  • 只是解决方案 这是lsqnonlin一个非常标准的lsqnonlin ,你只需要正确地格式化它。 这意味着这样的事情: %First, define a function whose inputs are a single vector, and whose %outputs can be minimized funToMinimize = @(abc) myfunction(Xdata,abc(1), abc(2), abc(3)) - Ydata; %Define an initial guess o ...
  • 似乎QASM是重命名的过程,因此很多链接都被破坏了。 您可以在此github位置找到Open Quantum汇编语言规范: https://github.com/IBM/qiskit-openqasm/tree/master/ PDF中的日期是2017年1月。 It seems that QASM is the process of being renamed, so many of the links are broken. You can find the Open Quantum Assembly L ...
  • 这可能是指PigeonRank ,这是谷歌的愚人节之一 This is probably referring to PigeonRank, which is one of Google's April Fools

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)