View Javadoc
1 /* 2 * ==================================================================== 3 * 4 * This code is subject to the freebxml License, Version 1.1 5 * 6 * Copyright (c) 2003 freebxml.org. All rights reserved. 7 * 8 * ==================================================================== 9 */ 10 package com.sun.xml.registry.client.browser.registration; 11 12 import java.awt.GridBagConstraints; 13 import java.awt.GridBagLayout; 14 15 import javax.swing.JLabel; 16 import javax.swing.JPanel; 17 import javax.swing.JTextField; 18 import javax.swing.SwingConstants; 19 import javax.xml.registry.JAXRException; 20 21 import com.sun.xml.registry.client.browser.swing.RegistryDocumentListener; 22 import com.sun.xml.registry.client.browser.swing.RegistryMappedPanel; 23 24 /*** 25 * Panel for PersonName 26 * 27 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 28 * @author Fabian Ritzmann 29 */ 30 public class PersonNamePanel extends JPanel { 31 32 private final PersonNameModel model; 33 34 PersonNamePanel(PersonNameModel person) { 35 36 super(); 37 this.model = person; 38 39 GridBagLayout gbl = new GridBagLayout(); 40 GridBagConstraints c = new GridBagConstraints(); 41 setLayout(gbl); 42 43 JLabel firstNameLabel = new JLabel("First name (Given name):", SwingConstants.LEFT); 44 RegistryMappedPanel.setConstraints(firstNameLabel, c, gbl, 45 0, 0, 1, 0.0, 46 GridBagConstraints.NONE, 47 GridBagConstraints.WEST); 48 add(firstNameLabel); 49 50 JTextField firstNameText = new JTextField(); 51 firstNameText.getDocument().addDocumentListener(new FirstNameListener()); 52 RegistryMappedPanel.setConstraints(firstNameText, c, gbl, 53 0, 1, 1, 0.75, 54 GridBagConstraints.BOTH, 55 GridBagConstraints.WEST); 56 add(firstNameText); 57 58 JLabel middleNameLabel = new JLabel("Middle name:", SwingConstants.LEFT); 59 RegistryMappedPanel.setConstraints(middleNameLabel, c, gbl, 60 1, 0, 1, 0.0, 61 GridBagConstraints.NONE, 62 GridBagConstraints.WEST); 63 add(middleNameLabel); 64 65 JTextField middleNameText = new JTextField(); 66 middleNameText.getDocument().addDocumentListener(new MiddleNameListener()); 67 RegistryMappedPanel.setConstraints(middleNameText, c, gbl, 68 1, 1, 1, 0.25, 69 GridBagConstraints.HORIZONTAL, 70 GridBagConstraints.WEST); 71 add(middleNameText); 72 73 JLabel lastNameLabel = new JLabel("Last name (Surname):", SwingConstants.LEFT); 74 RegistryMappedPanel.setConstraints(lastNameLabel, c, gbl, 75 0, 2, 1, 0.0, 76 GridBagConstraints.NONE, 77 GridBagConstraints.WEST); 78 add(lastNameLabel); 79 80 JTextField lastNameText = new JTextField(); 81 lastNameText.getDocument().addDocumentListener(new LastNameListener()); 82 RegistryMappedPanel.setConstraints(lastNameText, c, gbl, 83 0, 3, 2, 0.5, 84 GridBagConstraints.BOTH, 85 GridBagConstraints.WEST); 86 add(lastNameText); 87 } 88 89 90 public PersonNameModel getPersonNameModel() { 91 return this.model; 92 } 93 94 95 public PersonNamePanel getPersonNamePanel() { 96 return this; 97 } 98 99 100 class FirstNameListener extends RegistryDocumentListener { 101 102 public FirstNameListener() { 103 super(getPersonNamePanel(), "Could not set first name: "); 104 } 105 106 protected void setText(String text) throws JAXRException { 107 getPersonNameModel().setFirstName(text); 108 } 109 } 110 111 112 class MiddleNameListener extends RegistryDocumentListener { 113 114 public MiddleNameListener() { 115 super(getPersonNamePanel(), "Could not set middle name: "); 116 } 117 118 protected void setText(String text) throws JAXRException { 119 getPersonNameModel().setMiddleName(text); 120 } 121 } 122 123 124 class LastNameListener extends RegistryDocumentListener { 125 126 LastNameListener() { 127 super(getPersonNamePanel(), "Could not set last name: "); 128 } 129 130 protected void setText(String text) throws JAXRException { 131 getPersonNameModel().setLastName(text); 132 } 133 } 134 135 }

This page was automatically generated by Maven