scrollpanewatermark.java.svn-base
来自「开源项目openfire的完整源程序」· SVN-BASE 代码 · 共 67 行
SVN-BASE
67 行
/**
* $Revision: $
* $Date: $
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Lesser Public License (LGPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.spark.component;
import org.jivesoftware.spark.util.GraphicUtils;
import org.jivesoftware.spark.util.log.Log;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.TexturePaint;
import java.awt.Graphics2D;
import javax.swing.JViewport;
import javax.swing.JComponent;
/**
* Allows for background and foreground image handling of text components.
*
*/
public class ScrollPaneWatermark extends JViewport {
private Image backgroundImage;
private Image foregroundImage;
private TexturePaint texture;
public void setBackgroundImage(Image image) {
this.backgroundImage = image;
Rectangle rect = new Rectangle(0, 0, backgroundImage.getWidth(null), backgroundImage.getHeight(null));
try {
texture = new TexturePaint(GraphicUtils.convert(image), rect);
}
catch (Exception e) {
Log.error(e);
}
}
public void setForegroundImage(Image image) {
this.foregroundImage = image;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
if(foregroundImage != null){
g.drawImage(foregroundImage, getWidth() - foregroundImage.getWidth(null), 0, null);
}
}
public void setView(JComponent view){
view.setOpaque(false);
super.setView(view);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?