AboutDialog.java
2.63 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
87
88
89
90
91
92
93
94
95
96
97
package morfeusz;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
@SuppressWarnings("serial")
public class AboutDialog extends JPanel
{
private static final String INFO = "<html><center><h3>Morfeusz</h3></center><br/>" +
"<center>Analizator morfologiczny dla j\u0119zyka polskiego.<br/><br/>" +
"Wersja: " + pl.sgjp.morfeusz.Morfeusz.getVersion() + "</center></html>";
private JDialog dialog;
private JCheckBox pr = new JCheckBox("Program");
private JCheckBox dict = new JCheckBox("S\u0142ownik");
private JTextArea ta = new JTextArea(14, 58);
private Rectangle rect = new Rectangle(0, 0, 0, 0);
private String copyrights;
private String dictCopyrights;
public AboutDialog(pl.sgjp.morfeusz.Morfeusz morfeusz)
{
super(new BorderLayout());
JLabel label = new JLabel(INFO);
JPanel panel = new JPanel();
JScrollPane sp = new JScrollPane(ta);
ButtonGroup group = new ButtonGroup();
Box vbox = Box.createVerticalBox();
Box hbox = Box.createHorizontalBox();
setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
vbox.setBorder(BorderFactory.createEmptyBorder(16, 0, 0, 0));
ta.setMargin(new Insets(4, 4, 4, 4));
ta.setEditable(false);
ta.setFont(Morfeusz.plainFont);
panel.add(label);
add(panel, BorderLayout.CENTER);
label = new JLabel("Prawa autorskie: ");
hbox.add(label);
hbox.add(pr);
hbox.add(dict);
hbox.add(Box.createHorizontalGlue());
group.add(pr);;
group.add(dict);
pr.setSelected(true);
vbox.add(hbox);
vbox.add(sp);
add(vbox, BorderLayout.SOUTH);
pr.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
setText();
}
});
dict.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
setText();
}
});
copyrights = pl.sgjp.morfeusz.Morfeusz.getCopyright();
copyrights = copyrights.replaceFirst("Science\n", "Sciences\n");
copyrights = copyrights.replaceFirst("\n$", "");
dictCopyrights = morfeusz.getDictCopyright();
dictCopyrights = dictCopyrights.replaceFirst("\n$", "");
setText();
}
public void setText()
{
if (pr.isSelected()) ta.setText(copyrights);
else ta.setText(dictCopyrights);
EventQueue.invokeLater(new Runnable() {
public void run()
{
ta.scrollRectToVisible(rect);
}
});
}
public void doDialog()
{
dialog = new JDialog();
dialog.setModal(true);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setTitle("Informacje o programie");
dialog.setResizable(false);
dialog.getContentPane().add(this);
dialog.pack();
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
}
}