mshd.net
当前位置:首页 >> JAvA的imAgEIO读取图片后,怎么把他显示在pAnEl上呢? >>

JAvA的imAgEIO读取图片后,怎么把他显示在pAnEl上呢?

您好:读取bmp文件到BufferedImage中 File file2 = new File("c:\\testimages\\tttt" + ".bmp"); // BufferedImage bi = backstore.getBufferedImage(); try { output = ImageIO.read(file2); } catch (IOException e) { e.printStackTrace(); }...

BufferedImage bi = new BufferedImage(frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_INT_ARGB);Graphics2D g2d = bi.createGraphics();frame.paint(g2d);ImageIO.write(bi, "PNG", new File("frame.png"));

要在panel上面加图片,需要重写paint方法,那样就麻烦了,JLabel有现成的设置方法; JLabel l=new JLabel(); Icon icon=new ImageIcon("D:\\a.jpg"); //在此直接创建对象 l.setIcon(icon); 然后把你原来放在panel上的东西放在JLabel上面,再把JL...

你可以尝试下面两种方法: 获取JPanel的画布,用drawImage方法把图片画在JPanel上 新建个JLabel,用setIcon方法设置JLabel的图片,再添加进JPanel filechooser可以参考一下这段代码 private void openImage(){JFileChooser jfc=new JFileChooser...

还有什么要求可以再说 import java.awt.BorderLayout;import java.awt.Dimension;import java.awt.Graphics;import java.awt.Image;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import javax....

看看这个是不是你想要的; JPanel jpanel = new JPanel(); BufferedImage image = new BufferedImage(jpanel.getWidth(),jpanel.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); jpanel.paint(g2); ImageIO...

private static Toolkit tk = Toolkit.getDefaultToolkit(); private static Image im=E.class.getResource("images/6.gif");//E指当前所在类images/6.gif目录 void draw(Graphics g) { Color c = g.getColor(); g.setColor(Color.BLUE); g.draw...

public class GifComponent extends JComponent { private static final long serialVersionUID = 1L; private GifBean[] gifBeans; private Map gifBeanMap = new HashMap(); private int index = 0; private int delayFactor; private Timer t...

.setBackground(Color.yourChoseColor); 直接设置小块的背景色不就行了。

JPanel panel 重复定义,编译有问题 ~~~~~~~ 图片最好提前载入好 ~~~~~

网站首页 | 网站地图
All rights reserved Powered by www.mshd.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com