动态调整jframe /图像的大小或滚动 [英] Dynamically resize jframe/image or scroll

查看:345
本文介绍了动态调整jframe /图像的大小或滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如本问题所述(将图像包装到Jframe ),我需要一个jframe来匹配提供的确切图像(图像本身最初是一个已经转换为图像的PDF)

As discussed in this question (Wrap image to Jframe), i need a jframe to match the exact provided image (The image itself is originally a PDF which has been converted to an image)

提供的解决方案确实构建了一个jframe到我的图像尺寸,但我实际上无法看到所有的图像。我需要能够调整jframe的大小,图像动态调整为新的jframe大小。如果失败了,我想如果我只是滚动jframe甚至放大或缩小,我至少可以到达我目前看不到的图像部分。

The solution provided does indeed build a jframe to my image dimensions, but i can't actually see all of the image. I need to be able to resize the jframe, with the image dynamically adjusting to the new jframe size. Failing that, i think if i could just scroll the jframe or even zoom in or out, i could at least get to the parts of the image that i currently cannot see.

我需要这个的原因是,在我的代码中,我可以选择在图像上绘制一个Rectangle2D - 代码吐出坐标为java.awt.geom.Rectangle2D $ Float [x,y,w, h]。

The reason i need this is that, within my code, i have an option to draw a Rectangle2D against the image - the code spits out the co-ordinates as java.awt.geom.Rectangle2D$Float[x,y,w,h].

然后,我将使用这些坐标,使用Apache PDFbox中的PDFTextStripperbyArea类从原始PDF中提取区域。 PDFTextStripperbyArea将其输入作为Rectangle2D测量值。因此,图像和jframe必须始终具有相同的大小才能检索准确的坐标。

I will then use these co-ordinates to extract the region against the original PDF using PDFTextStripperbyArea class from Apache PDFbox. PDFTextStripperbyArea takes its input as Rectangle2D measurements. Hence, the image and the jframe must always be the same size in order to retrieve accurate co-ordinates.

任何人都可以提供帮助吗?

Can anybody help?

推荐答案

要使用滚动窗格扭曲标签,您可以实现以下更改:

To warp the label with a scroll pane you could implement the following changes:

    //frame.setLayout(new FlowLayout()); - comment out -  use default (Borderlayout)
    JLabel lbl= new JLabel();
    lbl.setIcon(icon);
    JScrollPane jsp = new JScrollPane(lbl); //warp the label with a scrollpane 
    //frame.add(lbl); 
    frame.add(jsp); //add scrollpane to frame instead of lbl

您可以找到更多信息这里

这篇关于动态调整jframe /图像的大小或滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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