我创建了一个带有 3 个选项卡的 JTabbedPane。当我切换到不同的标签时 stateChang 不响应点击。当我在 public void 中将调试标记添加到我的代码时stateChanged(ChangeEvent e) { }
,单击后我看不到任何效果。
可能是什么原因,我该如何解决?
public class TabbedPanChangeListener implements ChangeListener {
ConfigToolScannersPanel panel;
List<String> artikels = GenericsUtil.makeList();
public TabbedPanChangeListener(ConfigToolScannersPanel configToolScannersPanel) {
this.panel = configToolScannersPanel;
}
public void stateChanged(ChangeEvent e) {
WebTabbedPane sourceTabbedPane = (WebTabbedPane) e.getSource();
int index = sourceTabbedPane.getSelectedIndex();
String titel = sourceTabbedPane.getTitleAt(index);
File dirconfig = new File("C:\\tmp\\config");
File dirPictures = new File("C:\\tmp\\Pictures");
File diraxi = new File("C:\\tmp\\");
File artikels = new File("C:\\tmp\\artikels.csv");
if (dirconfig.exists()) {
if (titel.equalsIgnoreCase("ftp")) {
panel.updateUI();
} else if (titel.equalsIgnoreCase("Picture")) {
setSelectedFileToNull();
BorderLayout layout = (BorderLayout) panel.pictureTabPanel.getLayout();
panel.pictureTabPanel.remove(layout.getLayoutComponent(BorderLayout.WEST));
panel.pictureTabPanel.add(FileList.getGui(dirPictures.listFiles(), true, panel), BorderLayout.WEST);
panel.pictureTabPanel.remove(layout.getLayoutComponent(BorderLayout.NORTH));
panel.pictureTabPanel.add(FileList.getGui(diraxi.listFiles(), false, panel), BorderLayout.NORTH);
panel.pictureTabPanel.remove(layout.getLayoutComponent(BorderLayout.CENTER));
// *** Add and remove from tool bar ***
visibaleInvisibale(false);
panel.btnDelete.setVisible(true);
panel.btnDelete.setAction(new DeletePictureAction(panel));
panel.btnAdd.setVisible(true);
panel.btnAdd.setAction(new AddPictureAction(panel));
panel.updateUI();
} else if (titel.equalsIgnoreCase("dienst")) {
}
}
}