Goal:
add a 2X2 table to IM box the box where you type messages to other user.
Approach:
I have been using the following document:
http://www.igniterealtime.org/builds/sparkplug_kit/docs/latest/sparkplug_dev_gui de.html#examples
However, the first half of document is unclear.
Under "Getting Started Writing Pluggings, I added the jar files as told.
This allowed me to write following code for plugin.
But, it doesn’t show up in IM box where you type to other user
Plugin Code:
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import org.jivesoftware.spark.ChatManager;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.plugin.Plugin;
public class Table implements Plugin{
@Override
public boolean canShutDown() {
// TODO Auto-generated method stub
return false;
}
@Override
public void initialize() {
// TODO Auto-generated method stub
addTable();
}
@Override
public void shutdown() {
// TODO Auto-generated method stub
}
@Override
public void uninstall() {
// TODO Auto-generated method stub
}
private void addTable()
{
//Retrieve a ChatManager from SparkManager
ChatManager chatManager = SparkManager.getChatManager();
//JPanel window = new JPanel();
//window.setBackground(Color.cyan);
//window.setSize(100, 100);
JTable table = new JTable(2,2);
table.setBackground(Color.YELLOW);
/*JFrame frame = new JFrame();
frame.getContentPane();
frame.setLayout(new GridLayout(1,2));
frame.add(table);
frame.setBounds(100, 100,300,300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);*/
String chatroom = chatManager.getChatRoom(“testuser2”).toString();
chatManager.getChatRoom(chatroom).add(table);
}
}
Any help appreciated
Thanks