Go to the documentation of this file.00001
00002
00003
00004
00005 package ui;
00006
00007 import java.awt.Dimension;
00008
00009 import javax.swing.ImageIcon;
00010 import javax.swing.JLabel;
00011
00012
00013
00014
00015
00016
00017 public class JSecState extends JLabel
00018 {
00019 private static final long serialVersionUID = 1853852857708971435L;
00020
00021
00022
00023
00024 public enum State
00025 {
00026
00027 UNSECURED,
00028
00029
00030 VERIFIED,
00031
00032
00033 UNVERIFIED
00034 };
00035
00036
00037
00038
00039 private State state;
00040
00041
00042
00043 private ImageIcon iconUnsecured;
00044 private ImageIcon iconVerified;
00045 private ImageIcon iconUnverified;
00046
00047
00048
00049
00050 public JSecState( Object resourceOwner )
00051 {
00052 iconUnsecured = JImageButton.loadIcon( resourceOwner, "unsecured.png" );
00053 iconVerified = JImageButton.loadIcon( resourceOwner, "verified.png" );
00054 iconUnverified = JImageButton.loadIcon( resourceOwner, "unverified.png" );
00055
00056 setState( State.UNSECURED );
00057 setMinimumSize( new Dimension( 32, 32 ) );
00058 setMaximumSize( new Dimension( 32, 32 ) );
00059 }
00060
00061
00062
00063
00064 public State getState ()
00065 {
00066 return this.state;
00067 }
00068
00069
00070
00071
00072 public void setState( State newState )
00073 {
00074 this.state = newState;
00075 switch( this.state )
00076 {
00077 case UNSECURED:
00078 setIcon( iconUnsecured );
00079 setToolTipText(
00080 "<html><head></head><body><p><span style='color:red'>"
00081 + "Unsecured and untrusted communication.</span>"
00082 + "<br/>Instant messages will be unciphered and broadcasted to public."
00083 + "</p></body></html>"
00084 );
00085 break;
00086 case UNVERIFIED:
00087 setIcon( iconUnverified );
00088 setToolTipText(
00089 "<html><head></head><body><p><span style='color:#8000FF'>"
00090 + "Secured (encrypted) communication with unverified peer.</span>"
00091 + "<br/>Instant messages will be ciphered and sent to peer only."
00092 + "</p></body></html>"
00093 );
00094 break;
00095 case VERIFIED:
00096 setIcon( iconVerified );
00097 setToolTipText(
00098 "<html><head></head><body><p><span style='color:green'>"
00099 + "Secured communication with the trusted peer.</span>"
00100 + "<br/>Instant messages will be ciphered and sent to peer only."
00101 + "</p></body></html>"
00102 );
00103 break;
00104 }
00105 }
00106 }