本文整理了Java中javax.swing.ImageIcon.setImage()
方法的一些代码示例,展示了ImageIcon.setImage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageIcon.setImage()
方法的具体详情如下:
包路径:javax.swing.ImageIcon
类名称:ImageIcon
方法名:setImage
暂无
代码示例来源:origin: magefree/mage
public MageScrollButton(int direction, int width, boolean freeStanding) {
super(direction, width, freeStanding);
setOpaque(false);
this.width = width;
buttonUp.setImage(buttonUp.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
buttonDown.setImage(buttonDown.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
buttonLeft.setImage(buttonLeft.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
buttonRight.setImage(buttonRight.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
}
代码示例来源:origin: openpnp/openpnp
/**
* Overridden to forward to a wrapped ImageIcon. Does nothing if the wrapped icon
* is not an ImageIcon.
* <P>
* In common with <code>ImageIcom</code>, the newly set image will only be shown when the
* concerned component(s) are repainted.
*
* @param image Sets the image displayed by a wrapped ImageIcon
*/
@Override
public void setImage(Image image) {
if (icon instanceof ImageIcon) {
((ImageIcon) icon).setImage(image);
}
}
代码示例来源:origin: stackoverflow.com
ImageIcon receivedIcon = null;
receivedIcon.setImage(im);
代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client
/**
* Overridden to forward to a wrapped ImageIcon. Does nothing if the wrapped icon
* is not an ImageIcon.
* <P>
* In common with <code>ImageIcom</code>, the newly set image will only be shown when the
* concerned component(s) are repainted.
*
* @param image Sets the image displayed by a wrapped ImageIcon
*/
@Override
public void setImage(Image image) {
if (icon instanceof ImageIcon) {
((ImageIcon) icon).setImage(image);
}
}
代码示例来源:origin: stackoverflow.com
ImageIcon image = ? (whatever/wherever your gif is)
int width = 100;
int height = 100;
image.setImage(image.getImage().getScaledInstance(width, height, Image.SCALE_DEFAULT));
代码示例来源:origin: stackoverflow.com
ImageIcon receivedIcon = new ImageIcon();
receivedIcon.setImage(im);
代码示例来源:origin: org.boofcv/visualize
/**
* Creates a dialog window showing the specified image. The function will not
* exit until the user clicks ok
*/
public static void showDialog(BufferedImage img) {
ImageIcon icon = new ImageIcon();
icon.setImage(img);
JOptionPane.showMessageDialog(null, icon);
}
代码示例来源:origin: org.boofcv/boofcv-swing
/**
* Creates a dialog window showing the specified image. The function will not
* exit until the user clicks ok
*/
public static void showDialog(BufferedImage img) {
ImageIcon icon = new ImageIcon();
icon.setImage(img);
JOptionPane.showMessageDialog(null, icon);
}
代码示例来源:origin: stackoverflow.com
ImageIcon a_1 = new ImageIcon(FrontHand.class.getResource("/Sprites/character_move_down.gif"));
a_1.setImage(a_1.getImage().getScaledInstance(150, 150, Image.SCALE_DEFAULT));
move_player_down = a_1;
代码示例来源:origin: net.anwiba.commons/anwiba-commons-swing-icon
@Override
public void setImage(final Image image) {
this.model.get().setImage(image);
}
代码示例来源:origin: io.scif/scifio-cli
/** Handles slider events. */
@Override
public void stateChanged(final ChangeEvent e) {
final boolean outOfBounds = false;
updateLabel(-1, -1);
final BufferedImage image = outOfBounds ? null : getImage();
if (image == null) {
iconLabel.setIcon(null);
iconLabel.setText("No image plane");
}
else {
icon.setImage(image);
iconLabel.setIcon(icon);
iconLabel.setText(null);
}
}
代码示例来源:origin: io.scif/scifio
/** Handles slider events. */
@Override
public void stateChanged(final ChangeEvent e) {
final boolean outOfBounds = false;
updateLabel(-1, -1);
final BufferedImage image = outOfBounds ? null : getImage();
if (image == null) {
iconLabel.setIcon(null);
iconLabel.setText("No image plane");
}
else {
icon.setImage(image);
iconLabel.setIcon(icon);
iconLabel.setText(null);
}
}
代码示例来源:origin: scifio/scifio
/** Handles slider events. */
@Override
public void stateChanged(final ChangeEvent e) {
final boolean outOfBounds = false;
updateLabel(-1, -1);
final BufferedImage image = outOfBounds ? null : getImage();
if (image == null) {
iconLabel.setIcon(null);
iconLabel.setText("No image plane");
}
else {
icon.setImage(image);
iconLabel.setIcon(icon);
iconLabel.setText(null);
}
}
代码示例来源:origin: stackoverflow.com
FileDialog fd = new FileDialog(frame, "Test", FileDialog.LOAD);
String Image_path
fd.setVisible(true);
name = fd.getDirectory() + fd.getFile();
image_path=name;
ImageIcon icon= new ImageIcon(name);
icon.setImage(icon.getImage().getScaledInstance(jLabel2.getWidth(),jLabel2.getHeight() , Image.SCALE_DEFAULT));
jLabel2.setIcon(icon);
代码示例来源:origin: org.microemu/microemu-javase-swing
private void updateScaledImage(int scale, JFrame scaledLCDFrame) {
J2SEMutableImage scaledImage = (J2SEMutableImage) ((SwingDisplayComponent) emulatorContext
.getDisplayComponent()).getScaledDisplayImage(scale);
((ImageIcon) (((JLabel) scaledLCDFrame.getContentPane()).getIcon())).setImage(scaledImage.getImage());
((JLabel) scaledLCDFrame.getContentPane()).repaint();
}
};
代码示例来源:origin: org.jspresso.framework/jspresso-swing-application
/**
* {@inheritDoc}
*/
@Override
protected Icon createIcon(String urlSpec, Dimension iconSize) {
if (urlSpec != null) {
URL imageURL = UrlHelper.createURL(urlSpec);
if (imageURL != null) {
ImageIcon imageIcon = new ImageIcon(imageURL);
imageIcon.setImage(imageIcon.getImage().getScaledInstance(
iconSize.getWidth(), iconSize.getHeight(), Image.SCALE_SMOOTH));
return imageIcon;
}
}
return null;
}
}
代码示例来源:origin: chatty/chatty
private void setImageIcon(ImageIcon newIcon) {
boolean sizeChanged = icon.getIconWidth() != newIcon.getIconWidth()
|| icon.getIconHeight() != newIcon.getIconHeight();
Image oldImage = icon.getImage();
icon.setImage(newIcon.getImage());
icon.setDescription(newIcon.getDescription());
informUsers(oldImage, newIcon.getImage(), sizeChanged);
}
代码示例来源:origin: org.jspresso.framework/jspresso-wings-application
/**
* {@inheritDoc}
*/
@Override
protected SIcon createIcon(String urlSpec, Dimension iconSize) {
if (urlSpec != null) {
URL imageURL = UrlHelper.createURL(urlSpec);
if (imageURL != null) {
ImageIcon imageIcon = new ImageIcon(imageURL);
imageIcon.setImage(imageIcon.getImage().getScaledInstance(
iconSize.getWidth(), iconSize.getHeight(), Image.SCALE_SMOOTH));
return new SImageIcon(imageIcon);
}
}
return null;
}
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-editor
private void configUi()
{
setCursor( Cursor.getPredefinedCursor( Cursor.SE_RESIZE_CURSOR ) );
g_grabber = editor.util.EditorUtilities.loadIcon( "images/status_grabber.gif" );
g_grabber.setImage( editor.util.EditorUtilities.createSystemColorImage( g_grabber.getImage() ) );
setPreferredSize( new Dimension( g_grabber.getIconWidth(), g_grabber.getIconHeight() ) );
setOpaque( true );
setBackground( editor.util.EditorUtilities.CONTROL );
DragController controller = new DragController();
addMouseListener( controller );
addMouseMotionListener( controller );
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
private void configUi()
{
setCursor( Cursor.getPredefinedCursor( Cursor.SE_RESIZE_CURSOR ) );
g_grabber = editor.util.EditorUtilities.loadIcon( "images/status_grabber.gif" );
g_grabber.setImage( editor.util.EditorUtilities.createSystemColorImage( g_grabber.getImage() ) );
setPreferredSize( new Dimension( g_grabber.getIconWidth(), g_grabber.getIconHeight() ) );
setOpaque( true );
setBackground( Scheme.active().getControl() );
DragController controller = new DragController();
addMouseListener( controller );
addMouseMotionListener( controller );
}
内容来源于网络,如有侵权,请联系作者删除!