gui: fix tab selection

This commit is contained in:
Skylot
2013-11-26 22:14:49 +04:00
parent b18dabee15
commit b44a1e3a4f
@@ -203,7 +203,7 @@ public class MainWindow extends JFrame {
int id = tabbedPane.getTabCount() - 1;
openTabs.put(cls, id);
tabbedPane.setSelectedIndex(id);
tabbedPane.setTabComponentAt(id, makeTabComponent(cls, panel));
tabbedPane.setTabComponentAt(id, makeTabComponent(cls, panel, id));
}
if (panel != null) {
JTextArea textArea = getTextArea(panel);
@@ -212,7 +212,7 @@ public class MainWindow extends JFrame {
}
}
private Component makeTabComponent(final JClass cls, final Component comp) {
private Component makeTabComponent(final JClass cls, final Component comp, final int id) {
String name = cls.getCls().getFullName();
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 0));
panel.setOpaque(false);
@@ -243,6 +243,8 @@ public class MainWindow extends JFrame {
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON2) {
closeCodeTab(cls, comp);
} else {
tabbedPane.setSelectedIndex(id);
}
}
});