从方法返回时,StretchIcon class 不起作用。导致错误
StretchIcon class doesn't work when returned from a method. Causes error
直接调用 - new StretchIcon(imageStr);
- 有效。
但是从方法返回时不是。导致错误。
public static ImageIcon getPhotoSI(String imageStr){
return new StretchIcon(imageStr);
}
可能是什么问题?
错误
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException:
Uncompilable source code - Erroneous ctor sym type: library.StretchIcon.<init>
at library.IImage.getPhotoSI(IImage.java:36)
at Users.populateTable(Users.java:448)
at FrmUsers.btnSearch_ActionPerformed(FrmUsers.java:455)
at FrmUsers.access0(FrmUsers.java:18)
我是 Java 的新手。似乎问题不在于将其包名称包含在帮助程序中 class (StretchIcon.java).
喜欢
包库;
到StretchIcon.java。 运行 没有它的应用程序会导致运行时错误,并且 netbeans 无法将一些相关元素包含到已编译的源代码中。
喜欢
package library; // <- this one.
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.image.ImageObserver;
import java.net.URL;
import javax.swing.ImageIcon;
public class StretchIcon extends ImageIcon {
/**
* Determines whether the aspect ratio of the image is maintained.
* Set to <code>false</code> to allow th image to distort to fill the component.
*/
protected boolean proportionate = true;
/**
* Creates a <CODE>StretchIcon</CODE> from an array of bytes.
*
* @param imageData an array of pixels in an image format supported by
* the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
*
* @see ImageIcon#ImageIcon(byte[])
*/
public StretchIcon(byte[] imageData) {
super(imageData);
}
/**
* Creates a <CODE>StretchIcon</CODE> from an array of bytes with the specified behavior.
*
* @param imageData an array of pixels in an image format supported by
* the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
* @param proportionate <code>true</code> to retain the image's aspect ratio,
* <code>false</code> to allow distortion of the image to fill the
* component.
*
* @see ImageIcon#ImageIcon(byte[])
*/
public StretchIcon(byte[] imageData, boolean proportionate) {
super(imageData);
this.proportionate = proportionate;
}
}
直接调用 - new StretchIcon(imageStr);
- 有效。
但是从方法返回时不是。导致错误。
public static ImageIcon getPhotoSI(String imageStr){
return new StretchIcon(imageStr);
}
可能是什么问题?
错误
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException:
Uncompilable source code - Erroneous ctor sym type: library.StretchIcon.<init>
at library.IImage.getPhotoSI(IImage.java:36)
at Users.populateTable(Users.java:448)
at FrmUsers.btnSearch_ActionPerformed(FrmUsers.java:455)
at FrmUsers.access0(FrmUsers.java:18)
我是 Java 的新手。似乎问题不在于将其包名称包含在帮助程序中 class (StretchIcon.java).
喜欢
包库;
到StretchIcon.java。 运行 没有它的应用程序会导致运行时错误,并且 netbeans 无法将一些相关元素包含到已编译的源代码中。
喜欢
package library; // <- this one.
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Insets;
import java.awt.image.ImageObserver;
import java.net.URL;
import javax.swing.ImageIcon;
public class StretchIcon extends ImageIcon {
/**
* Determines whether the aspect ratio of the image is maintained.
* Set to <code>false</code> to allow th image to distort to fill the component.
*/
protected boolean proportionate = true;
/**
* Creates a <CODE>StretchIcon</CODE> from an array of bytes.
*
* @param imageData an array of pixels in an image format supported by
* the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
*
* @see ImageIcon#ImageIcon(byte[])
*/
public StretchIcon(byte[] imageData) {
super(imageData);
}
/**
* Creates a <CODE>StretchIcon</CODE> from an array of bytes with the specified behavior.
*
* @param imageData an array of pixels in an image format supported by
* the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
* @param proportionate <code>true</code> to retain the image's aspect ratio,
* <code>false</code> to allow distortion of the image to fill the
* component.
*
* @see ImageIcon#ImageIcon(byte[])
*/
public StretchIcon(byte[] imageData, boolean proportionate) {
super(imageData);
this.proportionate = proportionate;
}
}