closeTabPopup = new JPopupMenu();
JMenuItem closeItem = new JMenuItem("Close");
closeItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
View mainView = (View) BuildPanel.this.tabbedPane
.getSelectedComponent();
BuildPanel.this.removeMainView(mainView);
}
});
closeTabPopup.add(closeItem);
this.tabbedPane.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3
&& !BuildPanel.this.tabbedPane.getSelectedComponent().equals(
BuildPanel.this.primaryMainView)) {
closeTabPopup.show(BuildPanel.this.tabbedPane, e.getX(), e.getY());
}
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
});
this.tabbedPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
View activeView = (View) BuildPanel.this.tabbedPane
.getSelectedComponent();
activeView.notifyListeners();
}
});
treeView.setPreferredSize(new Dimension(WIDTH / 10, HEIGHT / 2));