📄 aidaddresslist.java
字号:
, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
this.add(viewButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 1.0
, GridBagConstraints.SOUTHEAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
}
/**
* This class listenes to the AIDAddressList
*
* @author Chris van Aart - Acklin B.V., the Netherlands
* @created April 26, 2002
*/
private class AIDAddressListListener implements ListDataListener {
/**
* Constructor for the AddressListListener object
*/
public AIDAddressListListener() { }
/**
* Description of the Method
*
* @param obj Description of Parameter
* @param arg Description of Parameter
*/
public void register(Object obj, String arg) {
itsAID = (AID)obj;
}
/**
* Description of the Method
*
* @param parm1 Description of Parameter
*/
public void intervalAdded(ListDataEvent parm1) {
DefaultListModel lm = (DefaultListModel)parm1.getSource();
int index = parm1.getIndex0();
String newAddress = (String)lm.elementAt(index);
itsAID.addAddresses(newAddress);
}
/**
* Description of the Method
*
* @param theRemovedAddress Description of Parameter
*/
public void registerRemovedAddress(String theRemovedAddress) {
this.theRemovedAddress = theRemovedAddress;
}
/**
* Description of the Method
*
* @param parm1 Description of Parameter
*/
public void intervalRemoved(ListDataEvent parm1) {
itsAID.removeAddresses(theRemovedAddress);
}
/**
* Description of the Method
*
* @param theChangedAddress Description of Parameter
*/
public void registerChangedAddress(String theChangedAddress) {
this.theChangedAddress = theChangedAddress;
}
/**
* Description of the Method
*
* @param parm1 Description of Parameter
*/
public void contentsChanged(ListDataEvent parm1) {
DefaultListModel lm = (DefaultListModel)parm1.getSource();
int index = parm1.getIndex0();
String currentAddress = (String)lm.getElementAt(index);
itsAID.removeAddresses(currentAddress);
itsAID.addAddresses(theChangedAddress);
}
private String theRemovedAddress, theChangedAddress;
private AID itsAID;
}
/**
* This class show a dialog where the address of an AID can be viewed and
* edited.
*
* @author Chris van Aart - Acklin B.V., the Netherlands
* @created April 26, 2002
*/
private class AIDAddressDialog extends JDialog {
/**
* Constructor for the ACLAddressDialog object
*/
public AIDAddressDialog() {
this.setModal(true);
try {
jbInit();
this.setSize(380, 100);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* Gets the ItsAddress attribute of the ACLAddressDialog object
*
* @return The ItsAddress value
*/
public String getItsAddress() {
return itsAddress;
}
/**
* Gets the OK attribute of the ACLAddressDialog object
*
* @return The OK value
*/
public boolean getOK() {
return userAction.equals(OK);
}
/**
* Sets the Editable attribute of the ACLAddressDialog object
*
* @param theBool The new Editable value
*/
public void setEditable(boolean theBool) {
if (!theBool) {
OK = "CLOSED";
this.cancelButton.setVisible(false);
this.theAddressField.setEnabled(false);
}
}
/**
* Sets the ItsAddress attribute of the ACLAddressDialog object
*
* @param newItsAddress The new ItsAddress value
*/
public void setItsAddress(String newItsAddress) {
itsAddress = newItsAddress;
this.theAddressField.setText(itsAddress);
}
/**
* Description of the Method
*
* @exception Exception Description of Exception
*/
void jbInit() throws Exception {
this.getContentPane().setLayout(gridBagLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", 0, 11));
jLabel1.setText("address");
this.getContentPane().setBackground(Color.white);
theAddressField.setFont(new java.awt.Font("Dialog", 0, 11));
theAddressField.setDisabledTextColor(Color.black);
buttonPanel.setBackground(Color.white);
okButton.setBackground(Color.white);
okButton.setFont(new java.awt.Font("Dialog", 0, 12));
okButton.setText("ok");
okButton.addActionListener(
new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
okButton_actionPerformed(e);
}
});
cancelButton.setBackground(Color.white);
cancelButton.setFont(new java.awt.Font("Dialog", 0, 12));
cancelButton.setText("cancel");
cancelButton.addActionListener(
new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
cancelButton_actionPerformed(e);
}
});
this.getContentPane().add(theAddressField, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
this.getContentPane().add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.getContentPane().add(buttonPanel, new GridBagConstraints(0, 2, 3, 1, 1.0, 0.0
, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
buttonPanel.add(okButton, null);
buttonPanel.add(cancelButton, null);
}
/**
* Description of the Method
*
* @param e Description of Parameter
*/
void cancelButton_actionPerformed(ActionEvent e) {
setUserAction(CANCELLED);
hide();
}
/**
* Description of the Method
*
* @param e Description of Parameter
*/
void okButton_actionPerformed(ActionEvent e) {
setItsAddress(theAddressField.getText());
setUserAction(OK);
hide();
}
/**
* Gets the UserAction attribute of the ACLAddressDialog object
*
* @return The UserAction value
*/
private String getUserAction() {
return userAction;
}
/**
* Sets the UserAction attribute of the ACLAddressDialog object
*
* @param newUserAction The new UserAction value
*/
private void setUserAction(String newUserAction) {
userAction = newUserAction;
}
GridBagLayout gridBagLayout1 = new GridBagLayout();
JTextField theAddressField = new JTextField();
JLabel jLabel1 = new JLabel();
JPanel buttonPanel = new JPanel();
JButton okButton = new JButton();
JButton cancelButton = new JButton();
private String OK = "ok";
private String CANCELLED = "cancelled";
private String userAction;
private String itsAddress;
}
private GridBagLayout gridBagLayout1 = new GridBagLayout();
private JList contentList = new JList();
private JButton viewButton = new JButton();
private JButton addButton = new JButton();
private JButton deleteButton = new JButton();
private DefaultListModel listModel = new DefaultListModel();
private JScrollPane contentScrollPane = new JScrollPane();
private boolean editable = true;
private AIDAddressListListener theDataListener;
private AID theAID;
}
// ***EOF***
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -