java标题边框自定义图标.doc
文本预览下载声明
带图标的边框
关键技术:
MatteBorder
MatteBorder(int?top, int?left, int?bottom, int?right, Icon?tileIcon) ??????????创建具有指定 insets 和平铺图标的衬边边框。package com.java2010.swing02;
import java.awt.Color;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;
import javax.swing.border.TitledBorder;
public class Test03 extends JFrame{
/**
* @param args
*/
//构造方法
public Test03(){
ImageIcon icon=new ImageIcon(getClass().getResource(icon.png));
MatteBorder matte=new MatteBorder(16,16,16,16,icon);
JPanel jp1=new JPanel();
Font font=new Font(黑体,1,16);
TitledBorder title=new TitledBorder(matte,带图标的边框,TitledBorder.RIGHT,TitledBorder.TOP,font,Color.blue);
jp1.setBorder(title);
this.add(jp1);
this.setSize(400,300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Test03();
}
}
显示全部