001 /** 002 ############################################################################## 003 ## ## 004 ## EnvInfo ## 005 ## ## 006 ## Copyright (C) 2009 Frederic Roudaut <frederic.roudaut@free.fr> ## 007 ## ## 008 ## ## 009 ## This program is free software: you can redistribute it and/or modify ## 010 ## it under the terms of the GNU General Public License as published by ## 011 ## the Free Software Foundation, either version 3 of the License, or ## 012 ## (at your option) any later version. ## 013 ## ## 014 ## This program is distributed in the hope that it will be useful, ## 015 ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## 016 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## 017 ## GNU General Public License for more details. ## 018 ## ## 019 ## You should have received a copy of the GNU General Public License ## 020 ## along with this program. If not, see <http://www.gnu.org/licenses/>. ## 021 ## ## 022 ## ## 023 ############################################################################## 024 **/ 025 026 027 028 package com.envInfo; 029 030 031 import java.awt.BorderLayout; 032 import java.awt.GridBagLayout; 033 import java.awt.GridBagConstraints; 034 import java.awt.event.*; 035 import java.awt.Insets; 036 import java.awt.Font; 037 import java.awt.Dimension; 038 import javax.swing.*; 039 040 import com.awt.GridBagLayoutConstraint; 041 042 043 044 /** 045 * An helpful class for tierce information, for showing User Info ... 046 * 047 */ 048 public class UserInfo extends JFrame 049 { 050 051 private static final long serialVersionUID = 1L; 052 053 /** 054 * Draw a Frame with some useful information on User Characteristics. 055 * 056 */ 057 public UserInfo() { 058 this(new Dimension(500, 300)); 059 } 060 061 /** 062 * Draw a Frame with some useful information on User Characteristics. 063 * @param d the text Panel Dimension. 064 * 065 */ 066 public UserInfo(Dimension d) { 067 super(Info.ressources.getObject("User_Info").toString()); 068 069 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 070 setVisible(true); 071 072 JPanel showUserPanel = new JPanel(new BorderLayout()); 073 JLabel entryText; 074 075 JPanel textPanel = new JPanel(); 076 GridBagLayout gb = new GridBagLayout(); 077 textPanel.setLayout(gb); 078 079 entryText = new JLabel(Info.ressources.getObject("user_name").toString()); 080 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 081 textPanel.add(entryText); 082 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,0,0, 083 new Insets(0,15,0,15))); 084 085 entryText = new JLabel("= " + System.getProperty("user.name")); 086 entryText.setFont(new Font("SansSerif", Font.PLAIN, 10)); 087 textPanel.add(entryText); 088 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,0, 089 new Insets(0,8,0,15))); 090 091 entryText = new JLabel(Info.ressources.getObject("user_home").toString()); 092 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 093 textPanel.add(entryText); 094 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,0,1, 095 new Insets(0,15,0,15))); 096 097 entryText = new JLabel("= " + System.getProperty("user.home")); 098 entryText.setFont(new Font("SansSerif", Font.PLAIN, 10)); 099 textPanel.add(entryText); 100 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,1, 101 new Insets(0,8,0,15))); 102 103 entryText = new JLabel(Info.ressources.getObject("user_dir").toString()); 104 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 105 textPanel.add(entryText); 106 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,0,2, 107 new Insets(0,15,0,15))); 108 109 entryText = new JLabel("= " + System.getProperty("user.dir")); 110 entryText.setFont(new Font("SansSerif", Font.PLAIN, 10)); 111 textPanel.add(entryText); 112 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,2, 113 new Insets(0,8,0,15))); 114 115 entryText = new JLabel(Info.ressources.getObject("user_country").toString()); 116 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 117 textPanel.add(entryText); 118 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,0,3, 119 new Insets(0,15,0,15))); 120 121 entryText = new JLabel("= " + System.getProperty("user.country")); 122 entryText.setFont(new Font("SansSerif", Font.PLAIN, 10)); 123 textPanel.add(entryText); 124 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,3, 125 new Insets(0,8,0,15))); 126 127 entryText = new JLabel(Info.ressources.getObject("user_language").toString()); 128 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 129 textPanel.add(entryText); 130 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,0,4, 131 new Insets(0,15,0,15))); 132 133 entryText = new JLabel("= " + System.getProperty("user.language")); 134 entryText.setFont(new Font("SansSerif", Font.PLAIN, 10)); 135 textPanel.add(entryText); 136 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,4, 137 new Insets(0,8,0,15))); 138 139 entryText = new JLabel(Info.ressources.getObject("user_timezone").toString()); 140 entryText.setFont(new Font("SansSerif", Font.BOLD, 11)); 141 textPanel.add(entryText); 142 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,0,5, 143 new Insets(0,15,0,15))); 144 145 entryText = new JLabel("= " + System.getProperty("user.timezone")); 146 entryText.setFont(new Font("SansSerif", Font.PLAIN, 10)); 147 textPanel.add(entryText); 148 gb.setConstraints(entryText, new GridBagLayoutConstraint(GridBagConstraints.WEST,1,5, 149 new Insets(0,8,0,15))); 150 151 JScrollPane textScrolled = new JScrollPane(textPanel); 152 textScrolled.setPreferredSize(d); 153 154 showUserPanel.add(textScrolled, BorderLayout.WEST); 155 GridBagLayout gbMain = new GridBagLayout(); 156 showUserPanel.setLayout(gbMain); 157 showUserPanel.add(textScrolled); 158 GridBagConstraints gbc = new GridBagLayoutConstraint(GridBagConstraints.EAST,0,0, 159 new Insets(15,15,15,15)); 160 gbc.gridwidth = 2; 161 gbMain.setConstraints(textScrolled, gbc); 162 163 JButton okbutton = new JButton(Info.ressources.getObject("OK").toString()); 164 showUserPanel.add(okbutton); 165 gbMain.setConstraints(okbutton, new GridBagLayoutConstraint(GridBagConstraints.EAST,1,1, 166 new Insets(8,8,8,8))); 167 okbutton.addActionListener(new ActionListener() { 168 public void actionPerformed(ActionEvent e) { 169 setVisible(false); 170 dispose(); 171 } 172 }); 173 174 getContentPane().add(showUserPanel, BorderLayout.CENTER); 175 pack(); 176 setResizable(false); 177 setVisible(true); 178 } 179 180 }