Getting Exception connecting Yahoo server
package session;
import java.io.FileWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;
import org.openymsg.network.FireEvent;
import org.openymsg.network.Session;
import org.openymsg.network.SessionState;
import org.openymsg.network.event.SessionListener;
public class BotGUI extends javax.swing.JFrame implements SessionListener{
/** Creates new form BotGUI */
FileWriter fw;
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
public BotGUI() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
uNameTextField = new javax.swing.JTextField();
uPassPasswordField = new javax.swing.JPasswordField();
jButton1 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel3.setBackground(new java.awt.Color(51, 51, 51));
jLabel1.setBackground(new java.awt.Color(0, 0, 255));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("Yahoo Login Panel");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
开发者_JAVA技巧 jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(532, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
);
jPanel2.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 710, 30));
jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel2.setText("Username");
jPanel4.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, 60, 20));
jLabel3.setText("Password");
jPanel4.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 20, 60, 20));
jPanel4.add(uNameTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 20, 140, 20));
jPanel4.add(uPassPasswordField, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 20, 140, -1));
jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton1.setText("Login");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel4.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 15, 90, -1));
jPanel2.add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 30, 710, 60));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(293, Short.MAX_VALUE))
);
jMenu1.setText("Option");
jMenuItem1.setText("Logout");
jMenu1.add(jMenuItem1);
jMenuItem2.setText("Load CSV");
jMenu1.add(jMenuItem2);
jMenuItem3.setText("Exit");
jMenu1.add(jMenuItem3);
jMenuBar1.add(jMenu1);
jMenu2.setText("Help");
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
public void handleConnectionClosed() {
connectionClosed = true;
loggedIn = false;
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if(!uNameTextField.getText().equals("") && !uPassPasswordField.getText().equals("")){
Yahoo_login(uNameTextField.getText(),uPassPasswordField.getText());
}else{
JOptionPane.showMessageDialog(null, "Plese Enter User Id and Password");
}
}
Session yahooMessengerSession;
MySessionListener mySessionListener;
boolean loggedIn = false;
boolean connectionClosed = false;
public void Yahoo_login(String uName, String pass) {
connectionClosed = false;
if (loggedIn == false) {
yahooMessengerSession = new Session();
mySessionListener = new MySessionListener(this);
yahooMessengerSession.addSessionListener(mySessionListener);
try {
if ((uName.equals("")) || (pass.equals("")))
{
System.out.println("User name/password is blank");
}
else{
//initialized a file writer for log file
System.out.println("Login start........");
yahooMessengerSession.login(uName, pass, true);
//checks whether user was succesful in login in
if (yahooMessengerSession!=null && yahooMessengerSession.getSessionStatus()== SessionState.LOGGED_ON) {
//this loop is reached when the user has been successfully logined
System.out.println("Login Success");
fw.write("User (" + uName + ") logged in at : " + dateFormat.format("09.05.10") + " \n");
fw.close();
} else {
yahooMessengerSession.reset();
}
}
} catch(Exception e){ }
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new BotGUI().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JTextField uNameTextField;
private javax.swing.JPasswordField uPassPasswordField;
// End of variables declaration
public void dispatch(FireEvent fe) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
===========================================================================================
i have to find the error
SEVERE: error during the dispatch of event: FireEvent [org.openymsg.network.event.SessionListEvent to:null from:null message:null timestamp:0 status:0 list type:Friends size:2 LIST] java.lang.UnsupportedOperationException: Not supported yet. at yahoomessangerbot.MySessionListener.dispatch(MySessionListener.java:131) at org.openymsg.network.EventDispatcher.runEventNOW(EventDispatcher.java:133) at org.openymsg.network.EventDispatcher.run(EventDispatcher.java:114)
http://jymsg9.sourceforge.net/docs/ymsg/network/Session.html
This will help u..
精彩评论