Skip to main content

GUI called by a plugin is not created

2 replies [Last post]
angeloulivieri
Offline
Joined: 2010-04-23

Hi,
I cannot solve this problem. I have a class GraphCreate and a class GraphCreateGUI.
Main can do some operations activable by GraphCreateGUI. All the project is in a package that I've inserted as a plugin in a software (Cytoscape).
If I start my program by compiler (Eclipse) it works well. If I insert it as a plugin the GUI doesn't start (The frame is created empty and all the program blocked).
I write the functions I used to insert it as a plugin and to have a menù in the sw (as I read on the software instructions).
Is this a Java problem?

This is the constructor that adds a menu item (It works! ):
public GraphCreate() {
//create a new action to respond to menu activation
GraphCreateAction action = new GraphCreateAction();
//set the preferred menu
action.setPreferredMenu("Plugins");
//and add it to the menus
Cytoscape.getDesktop().getCyMenus().addAction(action);

}

/ This class gets attached to the menu item.
public class GraphCreateAction extends CytoscapeAction {
private static final long serialVersionUID = 1L;//Version Number
* The constructor sets the text that should appear on the menu item.
*/
public GraphCreateAction() {
super("GraphCreate");
}

/**
* This method is called when the user selects the menu item.
*/
public void actionPerformed(ActionEvent ae) {
gui=new GraphCreateGUI();//I don't know if the problem is here!
startOperationsNewGUI();
}
}

public static void startOperationsNewGUI(){
try{
//This while says to the program to wait until a start button in the gui is pressed
while(true){
while(!gui.start){
Thread.sleep(100);

}
gui.start=false;
inizializza(gui);//Start computations using parameters on the GUI
}
}
catch(InterruptedException exc){
}

}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
walterln
Offline
Joined: 2007-04-17

Most likely Cytoscape calls you plugin on the EDT, so you're while loop blocks all painting. Better make you GUI a modal (blocking) dialog and the loop is not needed.

Search for 'java swing concurrency tutorial' and 'java swing modal dialog tutorial' for more information.

angeloulivieri
Offline
Joined: 2010-04-23

The problem is that of managing a GUI from the software.
I never used GUIs with java so I don't understand how to implement a construction in which you have two classes. A class with the GUI and a class that can do a computation with parameters taken from the GUI.
When you click on the start button the main class is called....
How can I do it in java? How many threads I need?
Thanks for reading