📄 registrationstatuspanel.java
字号:
/**
* $Revision: $
* $Date: $
*
* Copyright (C) 2007 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Lesser Public License (LGPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.sparkplugin.ui;
import org.jivesoftware.spark.plugin.phone.resource.PhoneRes;
import net.java.sipmack.softphone.SoftPhoneManager;
import org.jivesoftware.sparkplugin.components.CloseButton;
import org.jivesoftware.sparkplugin.ui.components.RectangleButton;
import net.java.sipmack.softphone.listeners.RegisterEvent;
import net.java.sipmack.sip.NetworkAddressManager;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.component.BackgroundPanel;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
/**
* Used for notifying users of registration and failure to register.
*/
public class RegistrationStatusPanel extends BackgroundPanel implements ActionListener {
private JLabel loadingLabel;
private CloseButton closeButton;
private RectangleButton retryButton;
public RegistrationStatusPanel() {
setLayout(new GridBagLayout());
loadingLabel = new JLabel();
loadingLabel.setIcon(PhoneRes.getImageIcon("NORMAL_PHONE_ICON"));
loadingLabel.setHorizontalAlignment(JLabel.LEFT);
loadingLabel.setFont(new Font("Verdana", Font.BOLD, 11));
add(loadingLabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
retryButton = new RectangleButton();
retryButton.setText(PhoneRes.getIString("phone.tryagain"));
add(retryButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 2, 2, 0), 0, 0));
retryButton.setVisible(false);
closeButton = new CloseButton();
add(closeButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 2), 0, 0));
// Set Border
setBorder(BorderFactory.createLineBorder(new Color(197, 213, 230), 1));
closeButton.addActionListener(this);
retryButton.addActionListener(this);
}
/**
* Call to display registration information.
*/
public void showRegistrationProgress() {
loadingLabel.setText(PhoneRes.getIString("phone.starting"));
loadingLabel.setForeground(new Color(63, 102, 161));
retryButton.setVisible(false);
}
/**
* Call to display failure to register.
*
* @param event the RegistrationEvent with reason.
*/
public void showRegistrationFailed(RegisterEvent event) {
loadingLabel.setForeground(new Color(210, 0, 0));
loadingLabel.setText(PhoneRes.getIString("phone.failed"));
loadingLabel.setIcon(PhoneRes.getImageIcon("NORMAL_PHONE_ICON"));
retryButton.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == closeButton) {
setVisible(false);
} else {
NetworkAddressManager.resetIndex();
showRegistrationProgress();
SoftPhoneManager.getInstance().register();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -