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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
package general;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
/**
* <p>Title: NTools : Network Tools</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: PG Softwares</p>
* @author Guillaume Porta
* @version 1.0
*/
public class InterfaceAProposDe extends JDialog {
private Dimension screenSize;
private JPanel dialogPanel = new JPanel();
private XYLayout xYLayout1 = new XYLayout();
private JPanel generalButtonsPanel = new JPanel();
private JButton okButton = new JButton();
private JTabbedPane mainPane = new JTabbedPane();
private JPanel aboutTab = new JPanel();
private JLabel titre = new JLabel();
private XYLayout xYLayout2 = new XYLayout();
private JLabel copyright = new JLabel();
private JLabel version = new JLabel();
private JPanel infosPanel = new JPanel();
private XYLayout xYLayout3 = new XYLayout();
private JLabel historiqueTitre = new JLabel();
private JScrollPane historiqueScrollsPane = new JScrollPane();
private JTextArea historiqueTextArea = new JTextArea();
private helpImg logoPanel = new helpImg();
private JLabel mailLabel = new JLabel();
private String appliName, appliDesc, appliVersion;
public InterfaceAProposDe(String a, String d, String v) throws HeadlessException {
try {
appliName = a;
appliDesc = d;
appliVersion = v;
jbInit();
lireHisto();
this.setModal( true );
setSize(406,438);
screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screenSize.width - this.getWidth()) / 2, (screenSize.height - this.getHeight()) / 2);
setVisible( true );
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
dialogPanel.setLayout(xYLayout1);
generalButtonsPanel.setBorder(BorderFactory.createRaisedBevelBorder());
generalButtonsPanel.setDebugGraphicsOptions(0);
xYLayout1.setHeight(0);
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
this.setResizable(false);
this.setTitle("A Propos De "+appliName);
dialogPanel.setPreferredSize(new Dimension(400, 430));
okButton.setText("OK");
okButton.addActionListener(new InterfaceAProposDe_okButton_actionAdapter(this));
mainPane.setForeground(SystemColor.desktop);
mainPane.setBorder(null);
mainPane.setDebugGraphicsOptions(0);
mainPane.setDoubleBuffered(false);
aboutTab.setRequestFocusEnabled(true);
aboutTab.setLayout(xYLayout2);
titre.setFont(new java.awt.Font("Dialog", 1, 15));
titre.setForeground(Color.blue);
titre.setHorizontalAlignment(SwingConstants.CENTER);
titre.setText(appliName+ " : "+ appliDesc);
copyright.setFont(new java.awt.Font("Dialog", 0, 10));
copyright.setHorizontalAlignment(SwingConstants.CENTER);
copyright.setText("Copyright (c) 2003 GP-Softwares. All Rights Reserved.");
version.setFont(new java.awt.Font("Dialog", 0, 13));
version.setForeground(Color.blue);
version.setHorizontalAlignment(SwingConstants.CENTER);
version.setText(appliVersion);
infosPanel.setLayout(xYLayout3);
historiqueTitre.setText("Historique des versions :");
historiqueTextArea.setEditable(false);
historiqueTextArea.setText("");
historiqueTextArea.setLineWrap(true);
historiqueTextArea.setTabSize(8);
historiqueTextArea.setWrapStyleWord(true);
mailLabel.setText("guillaume.porta@wanadoo.fr");
mailLabel.setHorizontalAlignment(SwingConstants.CENTER);
mailLabel.setFont(new java.awt.Font("Dialog", 0, 10));
mailLabel.setForeground(Color.blue);
this.getContentPane().add(dialogPanel, BorderLayout.CENTER);
dialogPanel.add(mainPane, new XYConstraints(8, 17, 384, 320));
mainPane.add(aboutTab, "About");
aboutTab.add(titre, new XYConstraints(3, 5, 371, -1));
aboutTab.add(version, new XYConstraints(1, 24, 376, 23));
aboutTab.add(copyright, new XYConstraints(5, 249, 371, 22));
aboutTab.add(mailLabel, new XYConstraints(5, 267, 371, 22));
aboutTab.add(logoPanel, new XYConstraints(30, 91, 314, 70));
mainPane.add(infosPanel, "Infos");
infosPanel.add(historiqueTitre, new XYConstraints(7, 1, 365, 23));
infosPanel.add(historiqueScrollsPane, new XYConstraints(6, 36, 367, 250));
dialogPanel.add(generalButtonsPanel, new XYConstraints(8, 345, 384, 38));
generalButtonsPanel.add(okButton, null);
historiqueScrollsPane.getViewport().add(historiqueTextArea, null);
}
// lire le fichier historique des versions et remplir le texte area du dialogue "a propos de ntools"
private void lireHisto()
{
String tampon;
RandomAccessFile versions;
try {
versions = new RandomAccessFile("infos/"+appliName+"_versions.nvf", "r");
try {
tampon = versions.readLine();
while ( tampon != null)
{
historiqueTextArea.append( tampon + "\n");
tampon = versions.readLine();
}
}
catch (IOException ex1) {
}
}
catch (FileNotFoundException ex) {
System.out.println("Erreur de lecture du fichier historique :\n"+ex);
System.err.println("Erreur de lecture du fichier historique :\n"+ex);
}
}
// evenement boutton OK
void okButton_actionPerformed(ActionEvent e) {
this.dispose();
}
}
class InterfaceAProposDe_okButton_actionAdapter implements java.awt.event.ActionListener {
InterfaceAProposDe adaptee;
InterfaceAProposDe_okButton_actionAdapter(InterfaceAProposDe adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.okButton_actionPerformed(e);
}
}
// classe d'affichage de l'image
class helpImg extends JPanel
{
private ImageIcon fond;
// chargement img
public helpImg()
{
fond = new ImageIcon("icons/ntools.gif");
}
// afficher l'img ds le panneau
public void paintComponent( Graphics g )
{
super.paintComponent( g );
fond.paintIcon( this, g, 0, 0);
}
// retourner les dim de l'img
public Dimension getPreferedSize()
{
return new Dimension( fond.getIconWidth(), fond.getIconHeight() );
}
} |
Partager