package cz.cuni.mff.inetpaint.dialog;
import cz.cuni.mff.inetpaint.swing.HyperlinkLabel;
import cz.cuni.mff.inetpaint.Program;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ResourceBundle;
/**
* Dialog zobrazující základní informace o programu
* @author Jindřich Helcl
*/
public class AboutDialog extends JDialog {
private static final Dimension SIZE = new Dimension(460, 230);
private void initComponents() {
final ResourceBundle rb = Program.getStringsBundle();
setSize(SIZE);
setResizable(false);
setTitle(rb.getString("aboutTitle"));
JPanel imagePanel = new JPanel() {
@Override
public void paintComponent(Graphics gr) {
gr.drawImage(Program.getImage("about.png") , 0, 0, null);
}
};
JLabel authorLabel = new JLabel(rb.getString("aboutAuthor"));
JLabel descLabel = new JLabel(rb.getString("aboutDescription"));
JLabel nameLabel = new JLabel(rb.getString("aboutName"));
nameLabel.setFont(new Font(getFont().getFontName(), Font.BOLD, 20));
JLabel versionLabel = new JLabel(rb.getString("aboutVersion") + " " + Program.VERSION_MAJOR.toString() + "." + Program.VERSION_MINOR.toString());
HyperlinkLabel websiteLabel = new HyperlinkLabel(Program.URI_WEBPAGE);
HyperlinkLabel documentationLabel = new HyperlinkLabel(Program.URI_DOCUMENTATION);
JButton closeButton = new JButton(rb.getString("closeButton"));
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
processWindowEvent( new WindowEvent( AboutDialog.this, WindowEvent.WINDOW_CLOSING) );
}
});
JSeparator separator = new JSeparator();
JSeparator separator2 = new JSeparator();
GroupLayout layout = new GroupLayout(rootPane);
rootPane.setLayout(layout);
layout.setVerticalGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup()
.addComponent(imagePanel)
.addGroup(layout.createSequentialGroup()
.addComponent(nameLabel)
.addGap(5)
.addComponent(versionLabel)
.addComponent(authorLabel)
.addGap(5)
.addComponent(separator, 5, 5, 5)
.addComponent(descLabel)
.addGap(0, 5, 1000)
.addComponent(websiteLabel)
.addComponent(documentationLabel)
.addGap(10)
.addComponent(separator2, 8, 8, 8)
.addComponent(closeButton)
)
)
.addContainerGap()
);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(imagePanel, 135, 135, 135)
.addGap(10)
.addGroup(layout.createParallelGroup()
.addComponent(nameLabel)
.addComponent(versionLabel)
.addComponent(authorLabel)
.addComponent(separator)
.addComponent(descLabel)
.addComponent(websiteLabel, GroupLayout.Alignment.TRAILING)
.addComponent(documentationLabel, GroupLayout.Alignment.TRAILING)
.addComponent(separator2)
.addComponent(closeButton, GroupLayout.Alignment.TRAILING)
)
.addContainerGap()
);
}
/**
* Vytvoří novou instanci dialogu.
* @param owner Rodičovské okno
*/
public AboutDialog(Frame owner) {
super(owner, true);
initComponents();
}
}