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();
}
}
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();
}
}