-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGPictWindow.java
More file actions
64 lines (56 loc) · 1.58 KB
/
GPictWindow.java
File metadata and controls
64 lines (56 loc) · 1.58 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
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import javax.swing.*;
public class GPictWindow extends JDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
String name;
MyLabel3 label;
GPictWindow(PCARD owner, String name, BufferedImage bi, String windowType, boolean visible) {
super(owner);
this.name = name;
//パネルを追加する
if(bi!=null){
label = new MyLabel3(name, bi);
getContentPane().add(label);
}
if(windowType.equalsIgnoreCase("rect") || windowType.equalsIgnoreCase("shadow")){
setUndecorated(true);
setBounds(owner.getX()+owner.getWidth()/2-bi.getWidth()/2,owner.getY()+owner.getHeight()/2-bi.getHeight()/2,bi.getWidth(),bi.getHeight()/*+owner.getInsets().top*/);
setResizable(false);
}
else{
setBounds(owner.getX()+owner.getWidth()/2-bi.getWidth()/2,owner.getY()+owner.getHeight()/2-bi.getHeight()/2,bi.getWidth(),bi.getHeight()+owner.getInsets().top);
//setResizable(false);
}
setVisible(visible);
}
}
class MyLabel3 extends JLabel {
/**
*
*/
private static final long serialVersionUID = 1L;
BufferedImage bi;
float scale;
MyLabel3(String fname, BufferedImage bi){
super();
this.bi = bi;
this.scale = 1f;
//this.setIcon(new ImageIcon(bi));
}
@Override
protected void paintComponent(Graphics g) {
if(bi==null){
g.setColor(Color.WHITE);
Rectangle r = g.getClipBounds();
g.fillRect(r.x, r.y, r.width, r.height);
return;
}
g.drawImage(bi,0,0,(int)(bi.getWidth()*scale),(int)(bi.getHeight()*scale), this);
}
}