| 1 | |
package de.glossmaker.gui.gloss.frames; |
| 2 | |
|
| 3 | |
import javax.swing.JFrame; |
| 4 | |
import java.awt.Dimension; |
| 5 | |
import javax.swing.JTextPane; |
| 6 | |
import javax.swing.JPanel; |
| 7 | |
import java.awt.Toolkit; |
| 8 | |
|
| 9 | |
import javax.swing.JButton; |
| 10 | |
import java.awt.Rectangle; |
| 11 | |
import java.awt.event.ActionEvent; |
| 12 | |
import java.awt.event.ActionListener; |
| 13 | |
import java.awt.Color; |
| 14 | |
import java.awt.SystemColor; |
| 15 | |
import java.awt.Point; |
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
public class InfoFrame extends JFrame { |
| 24 | |
private static final long serialVersionUID = -2151183569671877741L; |
| 25 | |
private static final String VERSION = "0.3"; |
| 26 | 0 | private JPanel jMainPanel = null; |
| 27 | 0 | private JTextPane jInfoTextPane = null; |
| 28 | 0 | private JButton jOkButton = null; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
public InfoFrame() { |
| 35 | 0 | super(); |
| 36 | 0 | initialize(); |
| 37 | 0 | displayText(); |
| 38 | 0 | } |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
private void initialize() { |
| 45 | 0 | this.setPreferredSize(new Dimension(400, 220)); |
| 46 | 0 | this.setSize(new Dimension(400, 220)); |
| 47 | 0 | this.setLocation(new Point(0, 0)); |
| 48 | 0 | this.setContentPane(getJMainPanel()); |
| 49 | 0 | this.setResizable(false); |
| 50 | 0 | this.setTitle("GlossMaker"); |
| 51 | 0 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
| 52 | 0 | int top = (screenSize.height - this.getHeight()) / 2; |
| 53 | 0 | int left = (screenSize.width - this.getWidth()) / 2; |
| 54 | 0 | this.setLocation(left, top); |
| 55 | 0 | } |
| 56 | |
|
| 57 | |
private void displayText() { |
| 58 | 0 | String infoText = "<html><body><h1>GlossMaker " + VERSION + "</h1>" + |
| 59 | |
"<p>The icons are taken from http://www.visualpharm.com/icons.html</p>" + |
| 60 | |
"<p><i>Copyright © 2010 - 2011 Markus Flingelli. All Rights Reserved.</i>" + |
| 61 | |
"</p></body></html>"; |
| 62 | 0 | jInfoTextPane.setText(infoText); |
| 63 | 0 | } |
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
private JPanel getJMainPanel() { |
| 70 | 0 | if (jMainPanel == null) { |
| 71 | 0 | jMainPanel = new JPanel(); |
| 72 | 0 | jMainPanel.setLayout(null); |
| 73 | 0 | jMainPanel.add(getJInfoTextPane(), null); |
| 74 | 0 | jMainPanel.add(getJOkButton(), null); |
| 75 | |
} |
| 76 | 0 | return jMainPanel; |
| 77 | |
} |
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
private JTextPane getJInfoTextPane() { |
| 85 | 0 | if (jInfoTextPane == null) { |
| 86 | 0 | jInfoTextPane = new JTextPane(); |
| 87 | 0 | jInfoTextPane.setBounds(new Rectangle(1, 1, 390, 150)); |
| 88 | 0 | jInfoTextPane.setEditable(false); |
| 89 | 0 | jInfoTextPane.setEnabled(true); |
| 90 | 0 | jInfoTextPane.setBackground(SystemColor.control); |
| 91 | 0 | jInfoTextPane.setForeground(Color.blue); |
| 92 | 0 | jInfoTextPane.setContentType("text/html"); |
| 93 | |
} |
| 94 | 0 | return jInfoTextPane; |
| 95 | |
} |
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
private JButton getJOkButton() { |
| 103 | 0 | if (jOkButton == null) { |
| 104 | 0 | jOkButton = new JButton(); |
| 105 | 0 | jOkButton.setBounds(new Rectangle(150, 160, 100, 25)); |
| 106 | 0 | jOkButton.setText("OK"); |
| 107 | 0 | jOkButton.addActionListener(new ActionListener() { |
| 108 | |
|
| 109 | |
@Override |
| 110 | |
public void actionPerformed(ActionEvent event) { |
| 111 | 0 | InfoFrame.this.setVisible(false); |
| 112 | 0 | } |
| 113 | |
}); |
| 114 | |
} |
| 115 | 0 | return jOkButton; |
| 116 | |
} |
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
} |