1 19 package org.openharmonise.him.authentication.gui; 20 21 import java.awt.BorderLayout ; 22 import java.awt.Color ; 23 import java.awt.Component ; 24 import java.awt.Container ; 25 import java.awt.Dialog ; 26 import java.awt.Dimension ; 27 import java.awt.Font ; 28 import java.awt.Frame ; 29 import java.awt.GraphicsConfiguration ; 30 import java.awt.HeadlessException ; 31 import java.awt.LayoutManager ; 32 import java.awt.event.ActionEvent ; 33 import java.awt.event.ActionListener ; 34 import java.awt.event.KeyEvent ; 35 import java.awt.event.KeyListener ; 36 37 import javax.swing.BorderFactory ; 38 import javax.swing.ImageIcon ; 39 import javax.swing.JButton ; 40 import javax.swing.JDialog ; 41 import javax.swing.JFrame ; 42 import javax.swing.JLabel ; 43 import javax.swing.JPanel ; 44 import javax.swing.border.LineBorder ; 45 import javax.swing.border.TitledBorder ; 46 47 import org.openharmonise.vfs.gui.*; 48 49 50 57 public class ChangePasswordDialog extends JDialog implements KeyListener , LayoutManager , ActionListener { 58 59 62 private JLabel m_logo = null; 63 64 67 private JLabel m_logoBuildings = null; 68 69 72 private JLabel m_logoPeople = null; 73 74 77 private JLabel m_logoFiles = null; 78 79 82 private ChangePasswordPanel m_entryPanel = null; 83 84 87 private JButton m_okButton = null; 88 89 92 private JButton m_cancelButton = null; 93 94 97 private JLabel m_information = null; 98 99 102 private JPanel m_panel = null; 103 104 107 private int m_nEntryPanelHeight = 250; 108 109 112 private int m_nDialogPanelHeight = 420; 113 114 120 public ChangePasswordDialog(Frame frame) throws HeadlessException { 121 super(frame, true); 122 this.setup(); 123 } 124 125 129 private void setup() { 130 131 this.setResizable(false); 132 133 m_panel = new JPanel (); 134 m_panel.setLayout(this); 135 this.getContentPane().setLayout(new BorderLayout ()); 136 this.getContentPane().add(m_panel); 137 138 this.setTitle("Harmonise"); 139 this.setSize(500,400); 140 m_panel.setBackground(new Color (224,224,224)); 141 142 int x = this.getGraphicsConfiguration().getBounds().width/2-this.getSize().width/2; 143 int y = this.getGraphicsConfiguration().getBounds().height/2-this.getSize().height/2; 144 145 this.setLocation(x, y); 146 147 m_logo = new JLabel (); 148 m_logo.setToolTipText("Connecting people and information to create knowledge"); 149 m_logo.setIcon( IconManager.getInstance().getIcon("login-sim-logo.png") ); 150 m_panel.add(m_logo); 151 152 m_logoBuildings = new JLabel (); 153 m_logoBuildings.setToolTipText("Conecting organisations"); 154 m_logoBuildings.setIcon( IconManager.getInstance().getIcon("login-sim-buildings.png") ); 155 m_panel.add(m_logoBuildings); 156 157 m_logoPeople = new JLabel (); 158 m_logoPeople.setToolTipText("Conecting people"); 159 m_logoPeople.setIcon( IconManager.getInstance().getIcon("login-sim-people.png") ); 160 m_panel.add(m_logoPeople); 161 162 m_logoFiles = new JLabel (); 163 m_logoFiles.setToolTipText("Conecting information"); 164 m_logoFiles.setIcon( IconManager.getInstance().getIcon("login-sim-files.png") ); 165 m_panel.add(m_logoFiles); 166 167 m_entryPanel = new ChangePasswordPanel(this); 168 String fontName = "Dialog"; 169 int fontSize = 11; 170 Font font = new Font (fontName, Font.PLAIN, fontSize); 171 m_entryPanel.setBackground(new Color (224,224,224)); 172 173 LineBorder lineBorder = (LineBorder ) BorderFactory.createLineBorder(Color.BLACK); 174 TitledBorder border = BorderFactory.createTitledBorder(lineBorder, 175 "Enter the old and new log in details", 176 TitledBorder.DEFAULT_JUSTIFICATION, 177 TitledBorder.DEFAULT_POSITION, 178 font, 179 Color.BLACK); 180 181 m_entryPanel.setBorder( border ); 182 m_panel.add(m_entryPanel); 183 184 m_okButton = new JButton ("OK"); 185 m_okButton.setActionCommand("OK"); 186 m_okButton.setFont(font); 187 m_okButton.addActionListener(this); 188 m_panel.add(m_okButton); 189 190 m_cancelButton = new JButton ("Cancel"); 191 m_cancelButton.setActionCommand("CANCEL"); 192 m_cancelButton.setFont(font); 193 m_cancelButton.addActionListener(this); 194 m_panel.add(m_cancelButton); 195 } 196 197 202 public void setInformationText(String sText) { 203 String fontName = "Dialog"; 204 int fontSize = 11; 205 Font font = new Font (fontName, Font.PLAIN, fontSize); 206 this.m_information = new JLabel (sText); 207 this.m_information.setFont(font); 208 m_panel.add(this.m_information); 209 this.setSize(500,430); 210 } 211 212 public static void main(String [] args) { 213 JFrame tempFrame = new JFrame (); 214 tempFrame.setIconImage( ((ImageIcon )IconManager.getInstance().getIcon("32-sim-logo.gif")).getImage() ); 215 216 ChangePasswordDialog dialog = new ChangePasswordDialog(tempFrame); 217 dialog.show(); 218 219 dialog = new ChangePasswordDialog(tempFrame); 220 dialog.setInformationText("Some information text..."); 221 dialog.show(); 222 223 System.exit(0); 224 } 225 226 227 228 229 230 231 232 233 234 239 public String getNewPassword() { 240 return this.m_entryPanel.getNewPassword(); 241 } 242 243 247 private ChangePasswordDialog(Dialog arg0) throws HeadlessException { 248 super(arg0); 249 } 250 251 256 private ChangePasswordDialog(Dialog arg0, boolean arg1) throws HeadlessException { 257 super(arg0, arg1); 258 } 259 260 264 private ChangePasswordDialog() throws HeadlessException { 265 super(); 266 } 267 268 273 private ChangePasswordDialog(Frame arg0, boolean arg1) throws HeadlessException { 274 super(arg0, arg1); 275 } 276 277 282 private ChangePasswordDialog(Dialog arg0, String arg1) throws HeadlessException { 283 super(arg0, arg1); 284 } 285 286 292 private ChangePasswordDialog(Dialog arg0, String arg1, boolean arg2) 293 throws HeadlessException { 294 super(arg0, arg1, arg2); 295 } 296 297 302 private ChangePasswordDialog(Frame arg0, String arg1) throws HeadlessException { 303 super(arg0, arg1); 304 } 305 306 312 private ChangePasswordDialog(Frame arg0, String arg1, boolean arg2) 313 throws HeadlessException { 314 super(arg0, arg1, arg2); 315 } 316 317 324 private ChangePasswordDialog( 325 Dialog arg0, 326 String arg1, 327 boolean arg2, 328 GraphicsConfiguration arg3) 329 throws HeadlessException { 330 super(arg0, arg1, arg2, arg3); 331 } 332 333 339 private ChangePasswordDialog( 340 Frame arg0, 341 String arg1, 342 boolean arg2, 343 GraphicsConfiguration arg3) { 344 super(arg0, arg1, arg2, arg3); 345 } 346 347 350 public void removeLayoutComponent(Component arg0) { 351 } 352 353 356 public void layoutContainer(Container arg0) { 357 m_logo.setLocation(10,10); 358 m_logo.setSize(new Dimension (200,50)); 359 360 m_logoBuildings.setLocation(320,10); 361 m_logoBuildings.setSize(new Dimension (50,50)); 362 363 m_logoPeople.setLocation(375,10); 364 m_logoPeople.setSize(new Dimension (50,50)); 365 366 m_logoFiles.setLocation(430,10); 367 m_logoFiles.setSize(new Dimension (50,50)); 368 369 int nHeight = 70; 370 371 if(this.m_information!=null) { 372 this.m_information.setLocation(10, nHeight); 373 this.m_information.setSize(470, 20); 374 nHeight = nHeight+30; 375 } 376 377 m_entryPanel.setLocation(10, nHeight); 378 m_entryPanel.setSize(new Dimension (470, m_nEntryPanelHeight)); 379 nHeight = nHeight+m_nEntryPanelHeight+10; 380 381 m_okButton.setLocation(330, nHeight); 382 m_okButton.setSize(70,20); 383 384 m_cancelButton.setLocation(410, nHeight); 385 m_cancelButton.setSize(70,20); 386 this.setSize(500,m_nDialogPanelHeight); 387 } 388 389 394 public String getUsername() { 395 return this.m_entryPanel.getUsername(); 396 } 397 398 404 public void setUsername(String sUsername) { 405 LineBorder lineBorder = (LineBorder ) BorderFactory.createLineBorder(Color.BLACK); 406 String fontName = "Dialog"; 407 int fontSize = 11; 408 Font font = new Font (fontName, Font.PLAIN, fontSize); 409 TitledBorder border = BorderFactory.createTitledBorder(lineBorder, 410 "Enter the new log in details", 411 TitledBorder.DEFAULT_JUSTIFICATION, 412 TitledBorder.DEFAULT_POSITION, 413 font, 414 Color.BLACK); 415 this.m_entryPanel.setUsername(sUsername); 416 this.m_nEntryPanelHeight = this.m_nEntryPanelHeight-50; 417 this.m_nDialogPanelHeight = this.m_nDialogPanelHeight-40; 418 this.setSize(500,m_nDialogPanelHeight); 419 } 420 421 426 public String getPassword() { 427 return this.m_entryPanel.getPassword(); 428 } 429 430 436 public void setPassword(String sPassword) { 437 LineBorder lineBorder = (LineBorder ) BorderFactory.createLineBorder(Color.BLACK); 438 String fontName = "Dialog"; 439 int fontSize = 11; 440 Font font = new Font (fontName, Font.PLAIN, fontSize); 441 TitledBorder border = BorderFactory.createTitledBorder(lineBorder, 442 "Enter the new log in details", 443 TitledBorder.DEFAULT_JUSTIFICATION, 444 TitledBorder.DEFAULT_POSITION, 445 font, 446 Color.BLACK); 447 448 m_entryPanel.setBorder( border ); 449 450 this.m_entryPanel.setPassword(sPassword); 451 this.m_nEntryPanelHeight = this.m_nEntryPanelHeight-50; 452 this.m_nDialogPanelHeight = this.m_nDialogPanelHeight-40; 453 this.setSize(500,m_nDialogPanelHeight); 454 } 455 456 459 public void addLayoutComponent(String arg0, Component arg1) { 460 } 461 462 465 public Dimension minimumLayoutSize(Container arg0) { 466 return new Dimension (500,250); 467 } 468 469 472 public Dimension preferredLayoutSize(Container arg0) { 473 return new Dimension (500,250); 474 } 475 476 479 public void actionPerformed(ActionEvent ae) { 480 if(ae.getActionCommand().equals("OK")) { 481 } else if(ae.getActionCommand().equals("CANCEL")) { 483 484 } 485 this.getOwner().setVisible(false); 487 this.hide(); 488 } 489 490 493 public void keyPressed(KeyEvent ke) { 494 if(ke.getKeyCode()==KeyEvent.VK_ENTER) { 495 this.getOwner().setVisible(false); 497 this.hide(); 498 } 499 } 500 501 504 public void keyReleased(KeyEvent arg0) { 505 } 506 507 510 public void keyTyped(KeyEvent arg0) { 511 } 512 513 } 514 | Popular Tags |