powered by Jive Software

Adding a tab on spark workspace

I was using the tutorial Sparkplug Development Guide. I tried the addTabToSpark() function to add a tab on the workspace but didn’t work. I have used the code below instead and it worked. Is it a change in the API? I am using sparkplug kit 2_0_7.

/**

  • Adds a tab to Spark

*/

private void addTabToSpark(){

// Get Workspace UI from SparkManager

Workspace workspace = SparkManager.getWorkspace();

// Retrieve the Tabbed Pane from the WorkspaceUI.

SparkTabbedPane tabbedPane = workspace.getWorkspacePane();

// Add own Tab.

tabbedPane.addTab(“My Plugin”, new ImageIcon(), new JButton(“Hello”));

}

Hi, Can you share with me your complete code. .java file. I could not complie it. My file is as follows.

ExamplePlugin.java

package org.jivesoftware.spark.examples;
package org.jivesoftware.spark.Workspace;

import org.jivesoftware.spark.plugin.Plugin;

/**

  • Implements the Spark Plugin framework to display the different possibilities using
  • Spark.
    */

public class ExamplePlugin implements Plugin {

/**
* Called after Spark is loaded to initialize the new plugin. */

public void initialize() {
System.out.println(“Welcome To Spark”);

}

/**
 * Adds a tab to Spark
 */
private void addTabToSpark(){

Workspace workspace = SparkManager.getWorkspace();
JButton button = new JButton(“HELLO SPARK USERS”);
workspace.getWorkspacePane().addTab(“MyPlugin”, button);
}

/**
* Called when Spark is shutting down to allow for persistence of information
* or releasing of resources. */

public void shutdown() {

}

/**
* Return true if the Spark can shutdown on users request.
* @return true if Spark can shutdown on users request. */

public boolean canShutDown() {

return true;
}

/**
* Is called when a user explicitly asked to uninstall this plugin.
* The plugin owner is responsible to clean up any resources and
* remove any components install in Spark. */

public void uninstall(){
// Remove all resources belonging to this plugin.
}
}