在窗体中,java显示图片怎么做
答案:1 悬赏:30 手机版
解决时间 2021-03-11 08:57
- 提问者网友:感性作祟
- 2021-03-10 11:40
在窗体中,java显示图片怎么做
最佳答案
- 五星知识达人网友:污到你湿
- 2021-03-10 11:56
下面是一个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;
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);
}
});
}
}
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;
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);
}
});
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯