我想用java编一程序,读取jpg文件并显示。望得到较好的方法! 我想用java编一程序,读取jpg文件并显示。望得到较好的方法!不知能不能使用BufferedImage。先谢谢了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 别人写的将JEditorPane透明就可以看到下面组件上绘的图了。import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.net.*;public class Test extends JFrame { JPanel pane; JEditorPane text; Image image; public Test() { super("背景"); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { System.exit(0); } }); String url = "http://images.csdn.net/20041202/sms3.JPG"; try { image = (new ImageIcon(new URL(url))).getImage(); text = new JEditorPane(); text.setOpaque(false); pane = new JPanel() { public void paintComponent(Graphics g) { g.drawImage(image, 0, 0, this); } }; pane.setLayout(new BorderLayout()); pane.add(text); } catch (MalformedURLException ex) { } this.getContentPane().add(pane); this.setSize(200, 150); this.setVisible(true); } public static void main(String[] args) { new Test(); }} sorry,问题没有表述清楚,我想读的图片是非常大的(如10000*8000),总是出现OutOfMemoryError,试过修改-Xms 和 -Xmx 都不是很管用,希望得到指教! 关于java.io超级新手简单问题 怎么用PrintWriter输出到文件的内容无法把原来的给覆盖掉??? lucene 中搜索的结果为什么不能全部显示?求高手~ java编程思想 第三版 习题讨教做法 关于super的用法,急(100分) 打印问题,在线等待,解决马上结帖!!! 哪里有jbuilder的书籍下载,最好是最新的? 哪里有《最新 jbuilder 开发指南》一书下载? 为什么?为什么?为什么?为什么?为什么? java问题求解答 JAVA怎样实现下拉菜单? 能否用JAVA画出颜色渐变,文字阴影,图形阴影等,谢谢
import java.awt.*;
import java.awt.event.*;
import java.net.*;public class Test extends JFrame {
JPanel pane;
JEditorPane text;
Image image; public Test() {
super("背景");
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent) {
System.exit(0);
}
});
String url = "http://images.csdn.net/20041202/sms3.JPG";
try {
image = (new ImageIcon(new URL(url))).getImage();
text = new JEditorPane();
text.setOpaque(false);
pane = new JPanel() {
public void paintComponent(Graphics g) {
g.drawImage(image, 0, 0, this);
}
};
pane.setLayout(new BorderLayout());
pane.add(text);
}
catch (MalformedURLException ex) {
}
this.getContentPane().add(pane);
this.setSize(200, 150);
this.setVisible(true);
}
public static void main(String[] args) {
new Test();
}
}