【问题标题】:Graphical anomalies when imports images and updating jLabels / jTextArea导入图像和更新 jLabels / jTextArea 时的图形异常
【发布时间】:2014-09-01 08:54:58
【问题描述】:

我有一个应用程序,每当我加载任何图像或更新 JTextArea 时,它总是将新对象/文本放在框架的左上角,而不是简单地更新它应该更新的任何对象..

我完全傻眼了,为什么它会以这种方式更新屏幕,有没有人有任何关于如何改变它的提示或提示?

下面是在 jTabbedFrame 中添加 jLabel 的代码

JLabel tempJLabel = new javax.swing.JLabel();
//tempJLabel.setLocation(1200,1200);
BufferedImage img = scaleImage(getStoredProductImage(photoDir[i]), 190); //scale down found image to whatever is needed
String filename = photoDir[i].getName();
Image tempImage = new Image(img,photoDir[i].getName(),photoDir[i],figureSaveDir(gtinTextBox.getText(), uidTextBox.getText()),tFrame,tempJLabel);       //create ImageObj for later use
if(filename.length()>20){
    tFrame.addTab(photoDir[i].getName().substring(15,19), tempJLabel);
    tempJLabel.setIcon(new ImageIcon(tempImage.getImg()));
}

不确定我是否还应该附加 GUI 构造的信息...

【问题讨论】:

  • 是什么让您认为我们可以在不查看任何代码的情况下回答您的问题?在问题中发布您的代码,请参阅How to create a Minimal, Complete, and Verifiable example
  • 哦,抱歉,虽然有人可以通过视觉识别问题。即在不先设置位置的情况下导入图像.. 将图像导入程序见上文
  • 可能是线程问题,或布局管理器问题,或 paint- 或 paintComponent 方法的错误实现。但是这种猜测对你没有帮助......
  • 看起来很奇怪...我的意思是您的一般选项卡布局(为什么这称为 TAB 布局?)!什么是 JTabbedFrame?也许你只是用错了?

标签: java jar jlabel jtextpane graphical-programming


【解决方案1】:

我假设您只是以任何错误的方式使用它。
Tab-Layout 的屏幕截图对我来说真的很奇怪。

但也许我错了(我不知道 JTabbedFrame 是什么?)

当您的意思是 JTabbedPane 时,也许您需要阅读以下内容: http://docs.oracle.com/javase/tutorial/uiswing/components/tabbedpane.html
使用前。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-11
    • 2017-08-17
    • 1970-01-01
    • 2014-03-01
    • 1970-01-01
    • 2022-01-23
    相关资源
    最近更新 更多