「java屏幕图片」java窗口显示图片

博主:adminadmin 2022-12-11 07:06:06 62

今天给各位分享java屏幕图片的知识,其中也会对java窗口显示图片进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

在窗体中,java显示图片怎么做

下面是一个JAVA显示图片的例子,请参考:

package com.tarena.java;

import t.Image;

import .File;

import .IOException;

import ageio.ImageIO;

import javax.swing.ImageIcon;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.SwingUtilities;

/**

* 加载显示图象,需要JDK1.5或以上

*/

public class showtu extends JFrame {

public showtu(String bmpFile) {

Image image = null;

try {

image = ad(new File(bmpFile));

} catch (IOException ex) {

}

JLabel label = new JLabel(new ImageIcon(image));

add(label);

setDefaultCloseOperation(EXIT_ON_CLOSE);

pack();

}

public static void main(String[] args){

final String fileName = "F:\\456备用\\亮个相.JPG"; //换成你要显示的图片

vokeLater(new Runnable(){

public void run(){

new showtu(fileName).setVisible(true);

}

});

}

}

JAVA在屏幕上绘制图片的问题

下边这句代码去掉,就会显示图片了。

g = bim.getGraphics();

你把画笔改成了图片的。应该还是继续使用,窗品的画笔。

java中怎样在界面中显示图片

方法一:

[java] view plain copy

JLabel helloLabel = new JLabel("New label");

helloLabel.setIcon(new ImageIcon("E:\\javaSE\u4EE3\u7801\\TimeManager\\asset\\hello.gif"));

helloLabel.setBackground(Color.BLACK);

helloLabel.setBounds(0, 0, 105, 50);

contentPane.add(helloLabel);

方法二:

[java] view plain copy

ImageIcon imagetoshow=new ImageIcon(urlofimagetoshow);

JLabel showimagelabel=new JLabel(imagetoshow);

this.getLayeredPane().add(showimagelabel,

new Integer(Integer.MIN_VALUE)); // 设置JLabel在最底层

showimagelabel.setBounds(0, 0, 500,150);

关于java屏幕图片和java窗口显示图片的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-12-11,除非注明,否则均为首码项目网原创文章,转载请注明出处。