简体   繁体   English

java jscrollpane

[英]java jscrollpane

I have a problem with displaying the components of a JScrollPane. 我在显示JScrollPane的组件时遇到问题。 Let me first explain the context. 首先让我解释一下上下文。 I've got one big splitpane: 我有一个大的分割窗格:

        center = new JSplitPane(JSplitPane.VERTICAL_SPLIT, p, p1);
        center.setDividerLocation(0.9);
        center.setDividerSize(3);
        center.setResizeWeight(1);
        center.setContinuousLayout(true);

The p pane is shown the right way, no problem here. p窗格显示正确,这里没有问题。 But the p1 pane won't be displayed, i can see the empty bottom-part of the splitPane, but that's all. 但是不会显示p1窗格,我可以看到splitPane的空白底部,仅此而已。

        JPanel p = new JPanel();
        p.add(canvas);
        JPanel p1 = new JPanel();
        p1.add(canvasPropPane);

The canvasPropPane is a scrollPane that i initialize like this: canvasPropPane是我这样初始化的scrollPane:

        VolumeSizeAndPosition volum = new VolumeSizeAndPosition();
        canvasPropPane = new JScrollPane(volum);

volume was tested on an independent frame and have been shown the right way. volume在独立的框架上进行了测试,并且显示了正确的方式。 I tried showing on the canvasPropPane a simple button canvasPropPane.add(wildButton); 我试图在canvasPropPane上显示一个简单的按钮canvasPropPane.add(wildButton); and it has a strange behavior: it paints the button only after i hover the mouse over it's location; 而且它的行为很奇怪:只有当我将鼠标悬停在其位置上时,它才会绘制按钮; at repaint (after resizing the scrollpane) it disappears. 在重新绘制(调整滚动窗格的大小)时,它消失了。

I've solved similar problems by calling invalidate() on all of the underlying nested Swing objects. 我已经通过对所有基础嵌套的Swing对象调用invalidate()解决了类似的问题。 So for your particular question p.invalidate() and p1.invalidate() may help. 因此,对于您的特定问题,p.invalidate()和p1.invalidate()可能会有所帮助。 I believe this strange behavior to be a bug in Swing. 我相信这种奇怪的行为是Swing中的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM