首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

jTree 背景图片.节点色彩

2012-10-27 
jTree 背景图片.节点颜色import java.awt.* import java.util.* import java.awt.event.* import javax

jTree 背景图片.节点颜色

import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;

public class Tree
{
?public static void main(String[] args)
?{
?JFrame frame = new JFrame("Table");
?frame.addWindowListener( new WindowAdapter() {
??public void windowClosing(WindowEvent e)
??{
??Window win = e.getWindow();
??win.setVisible(false);
??win.dispose();
??System.exit(0);
??}
??} );


?JTree tree = new JTree()
?{
?ImageIcon image = new ImageIcon( "F:\\1.jpg" );

?public void paint( Graphics g )
?{
?// First draw the background image - tiled
?Dimension d = getSize();
?for( int x = 0; x < d.width; x += image.getIconWidth() )
?for( int y = 0; y < d.height; y += image.getIconHeight() )
?g.drawImage( image.getImage(), x, y, null, null );
?super.paint(g);
?}

?};

?tree.setOpaque( false );
?tree.setCellRenderer( new MyCellRenderer() );
?JScrollPane sp = new JScrollPane( tree );

?frame.getContentPane().add( sp );
?frame.pack();
?frame.show();
?}

?}

热点排行