Create a Tool Window

Hi. I'm trying to make a tool window and the only place describing how to do so is here. Just adding the XML and a ToolWindow Factory doesn't seem to do anything, I'd use the sample they refer to, but it doesn't exist.

Any help is appreciated.

2 comments
Comment actions Permalink

I deleted my plugin.xml and started with a fresh one and the xml in the linked page works fine, however I have no idea how I'm supposed to give this window any form of interface.

0
Comment actions Permalink

The ToolWindowFactory interface has a createToolWindowContent(Project project, ToolWindow toolWindow) method. ToolWindow has a getComponent() method which has a add() method to add another component, such as a JPanel from a generated GUI Form.

public class Objectives implements ToolWindowFactory{

  @Override public void createToolWindowContent(Project project, ToolWindow toolWindow){
    toolWindow.getComponent().add(new ObjectivesGUI().getPanel1());
  }
}


public class ObjectivesGUI{
  private JPanel panel1;
  private JTextField textField1;

  public ObjectivesGUI(){
    JFrame frame = new JFrame("ObjectivesGUI");
    frame.setContentPane(panel1);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }

  public JPanel getPanel1(){
    return panel1;
  }
}

0

Please sign in to leave a comment.