imageborder.java

来自「YOYOPlayer MP3播放器 java+JMF实现」· Java 代码 · 共 46 行

JAVA
46
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.hadeslee.yoyoplayer.player.ui;import java.awt.Component;import java.awt.Graphics;import java.awt.Image;import java.awt.Insets;import javax.swing.border.Border;/** * * @author hadeslee */public class ImageBorder implements Border {    private Insets insets = new Insets(0, 0, 0, 0);    private Image image = null;    public ImageBorder() {        super();    }    public void setImage(Image image) {        this.image = image;    }    public boolean isBorderOpaque() {        return true;    }    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {        if (image != null) {            int x0 = x + (width - image.getWidth(null)) / 2;            int y0 = y + (height - image.getHeight(null)) / 2;            g.drawImage(image, x0, y0, null);        }    }    public Insets getBorderInsets(Component c) {        return insets;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?