author | Markus Bröker<broeker.markus@googlemail.com> |
Fri, 27 Jan 2017 21:25:15 +0100 | |
changeset 16 | 55b0d5006e7b |
parent 14 | f12f77aa13b2 |
permissions | -rw-r--r-- |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
1 |
package org.homelinux.largo.utils; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
2 |
|
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
3 |
import java.awt.Canvas; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
4 |
import java.awt.Dimension; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
5 |
import java.awt.Image; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
6 |
import java.net.URL; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
7 |
|
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
8 |
import javax.swing.ImageIcon; |
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
9 |
|
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
10 |
public class ImgComponent extends Canvas { |
16
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
11 |
static final long serialVersionUID = 1L; |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
12 |
private Image img; |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
13 |
|
16
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
14 |
public ImgComponent(String sFile) { |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
15 |
ClassLoader cl = getClass().getClassLoader(); |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
16 |
URL url = cl.getResource(sFile); |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
17 |
img = new ImageIcon(url).getImage(); |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
18 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
19 |
|
16
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
20 |
public Image getImage() { |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
21 |
return img; |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
22 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
23 |
|
16
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
24 |
public Dimension getPreferredSize() { |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
25 |
return new Dimension(img.getWidth(this), img.getHeight(this)); |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
26 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
27 |
|
16
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
28 |
public Dimension getMinimumSize() { |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
29 |
return getPreferredSize(); |
55b0d5006e7b
Sourcecode neu formatiert und ins Jahr 2017 migriert
Markus Bröker<broeker.markus@googlemail.com>
parents:
14
diff
changeset
|
30 |
} |
0
e0dbaef72362
svn copy of the chess engine
Markus Bröker <mbroeker@largo.homelinux.org>
parents:
diff
changeset
|
31 |
} |