Menu

[r3]: / trunk / src / diffstats / DiffFrame.java  Maximize  Restore  History

Download this file

83 lines (60 with data), 1.8 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
package diffstats;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public class DiffFrame extends JFrame {
private TextPanel textPanel;
private ButtonPanel buttonPanel;
public DiffFrame(String fileName){
initComponents(fileName);
layoutDialog();
initDialog();
if(fileName != null)
new Analyze(textPanel, new File(fileName)).process();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}
private void initDialog() {
this.setTitle("DiffStats");
this.setIconImage(new ImageIcon(this.getClass().getResource("/images/Code_icon.png")).getImage());
this.setResizable(false);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
// Determine the new location of the window
int w = getSize().width;
int h = getSize().height;
int x = (dim.width-w)/2;
int y = (dim.height-h)/2;
// Move the window
setLocation(x, y);
}
private void initComponents(String fileName) {
textPanel = new TextPanel(fileName);
buttonPanel = new ButtonPanel(this);
}
private void layoutDialog() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(5, 5, 5, 5);
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 3;
c.anchor = GridBagConstraints.PAGE_START;
panel.add(textPanel, c);
c.gridx = 3;
c.gridwidth = 1;
c.anchor = GridBagConstraints.PAGE_START;
panel.add(buttonPanel, c);
getContentPane().add(panel);
}
public TextPanel getTextPanel() {
return textPanel;
}
}