-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntersect.java
More file actions
86 lines (73 loc) · 1.84 KB
/
Copy pathIntersect.java
File metadata and controls
86 lines (73 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Intersect.java
/**
* @author: Josimar H. Lopes
* @year: 2010/04/12
*/
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.io.File;
import java.io.FileNotFoundException;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.ImageIcon;
public class Intersect extends JFrame implements Runnable
{
private ImageIcon switchImages;
private Dimension screenSize;
private File imageFolder;
public Intersect()
{
screenSize = Toolkit.getDefaultToolkit().getScreenSize();
switchImages = new ImageIcon( "intersect.jpg" );
add( new IntersectLoad() );
setUndecorated( true );
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
setSize( (int)screenSize.getWidth(), (int)screenSize.getHeight() );
setVisible( true );
}
public void run()
{
imageFolder = new File( "/home/lopes/Projects/Intersect/sample" );
String path = imageFolder.getPath() + "/";
System.out.println( path );
String[] directory = imageFolder.list();
for( String file : directory )
{
try
{
Thread.sleep( 20 );
}
catch( InterruptedException exception )
{
exception.printStackTrace();
}
switchImages = new ImageIcon( "" + path + file );
repaint();
}
System.exit( 1 );
}
private class IntersectLoad extends JPanel
{
public void paintComponent( Graphics g )
{
super.paintComponent( g );
if( switchImages.getIconWidth() > getWidth() || switchImages.getIconHeight() > getHeight() )
{
g.drawImage( switchImages.getImage(), 0, 0, (int)getWidth(),
(int)getHeight(),this );
}
else
{
g.drawImage( switchImages.getImage(),
(int)(getWidth()-switchImages.getIconWidth())/2,
(int)(getHeight()-switchImages.getIconHeight())/2,this );
}
}
}
public static void main( String[] args )
{
new Thread( new Intersect() ).start();
}
}