diff --git a/src/com/jpexs/decompiler/flash/gui/LazyCardLayout.java b/src/com/jpexs/decompiler/flash/gui/LazyCardLayout.java
new file mode 100644
index 000000000..b5282b974
--- /dev/null
+++ b/src/com/jpexs/decompiler/flash/gui/LazyCardLayout.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010-2016 JPEXS
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.jpexs.decompiler.flash.gui;
+
+import java.awt.CardLayout;
+import java.awt.Component;
+import java.awt.Container;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * @author JPEXS
+ */
+public class LazyCardLayout extends CardLayout {
+
+ private final Map registeredComponents = new HashMap<>();
+
+ @Override
+ public void show(Container parent, String name) {
+
+ Component component = registeredComponents.get(name);
+ if (component != null && component.getParent() != parent) {
+ parent.add(component, name);
+ }
+
+ super.show(parent, name);
+ }
+
+ public void registerLayout(Component component, String card) {
+ registeredComponents.put(card, component);
+ }
+}
diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java
index 324ff73bb..fdddb5bf5 100644
--- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java
+++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java
@@ -684,9 +684,12 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
});
searchPanel.add(closeSearchButton, BorderLayout.EAST);
searchPanel.setVisible(false);
- treePanel = new JPanel(new CardLayout());
- treePanel.add(createResourcesViewCard(), RESOURCES_VIEW);
- treePanel.add(createDumpViewCard(), DUMP_VIEW);
+
+ LazyCardLayout treePanelLayout = new LazyCardLayout();
+ treePanelLayout.registerLayout(createResourcesViewCard(), RESOURCES_VIEW);
+ treePanelLayout.registerLayout(createDumpViewCard(), DUMP_VIEW);
+ treePanel = new JPanel(treePanelLayout);
+
//treePanel.add(searchPanel, BorderLayout.SOUTH);
//searchPanel.setVisible(false);
filterField.getDocument().addDocumentListener(new DocumentListener() {
@@ -719,13 +722,12 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
timelineViewPanel = new TimelineViewPanel();
- CardLayout cl3 = new CardLayout();
- contentPanel = new JPanel(cl3);
+ contentPanel = new JPanel(new CardLayout());
contentPanel.add(welcomePanel, WELCOME_PANEL);
contentPanel.add(splitPane1, SPLIT_PANE1);
contentPanel.add(timelineViewPanel, TIMELINE_PANEL);
add(contentPanel);
- cl3.show(contentPanel, WELCOME_PANEL);
+ showContentPanelCard(WELCOME_PANEL);
tagTree.addKeyListener(new KeyAdapter() {
@Override
@@ -846,8 +848,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
if (isWelcomeScreen) {
- CardLayout cl = (CardLayout) (contentPanel.getLayout());
- cl.show(contentPanel, SPLIT_PANE1);
+ showContentPanelCard(SPLIT_PANE1);
isWelcomeScreen = false;
}
@@ -883,8 +884,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
View.checkAccess();
if (!isWelcomeScreen && swfs.isEmpty()) {
- CardLayout cl = (CardLayout) (contentPanel.getLayout());
- cl.show(contentPanel, WELCOME_PANEL);
+ showContentPanelCard(WELCOME_PANEL);
isWelcomeScreen = true;
closeTagTreeSearch();
}
@@ -3157,27 +3157,35 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
return r;
}
- public boolean showView(int view) {
-
+ private void showContentPanelCard(String card) {
CardLayout cl = (CardLayout) (contentPanel.getLayout());
- CardLayout cl2 = (CardLayout) (treePanel.getLayout());
+ cl.show(contentPanel, card);
+ }
+
+ private void showTreePanelCard(String card) {
+ CardLayout cl = (CardLayout) (treePanel.getLayout());
+ cl.show(treePanel, card);
+ }
+
+ public boolean showView(int view) {
+ View.checkAccess();
setTreeModel(view);
switch (view) {
case VIEW_DUMP:
if (!isWelcomeScreen) {
- cl.show(contentPanel, SPLIT_PANE1);
+ showContentPanelCard(SPLIT_PANE1);
}
- cl2.show(treePanel, DUMP_VIEW);
+ showTreePanelCard(DUMP_VIEW);
treePanelMode = TreePanelMode.DUMP_TREE;
showDetail(DETAILCARDEMPTYPANEL);
reload(true);
return true;
case VIEW_RESOURCES:
if (!isWelcomeScreen) {
- cl.show(contentPanel, SPLIT_PANE1);
+ showContentPanelCard(SPLIT_PANE1);
}
- cl2.show(treePanel, RESOURCES_VIEW);
+ showTreePanelCard(RESOURCES_VIEW);
treePanelMode = TreePanelMode.TAG_TREE;
@@ -3204,7 +3212,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
} else {
timelineViewPanel.setTimelined(swf);
}
- cl.show(contentPanel, TIMELINE_PANEL);
+ showContentPanelCard(TIMELINE_PANEL);
return true;
}
return false;
diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java
index 7bc064c9e..590ac854d 100644
--- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java
+++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java
@@ -477,7 +477,9 @@ public class ActionPanel extends JPanel implements SearchListener {
+ setSourceCompleted(asm, htext, innerActions);
+ });
}
return null;