diff --git a/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java b/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java index d7389d9f1..ab4b01154 100644 --- a/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java @@ -22,8 +22,6 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Cursor; import java.awt.FlowLayout; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.BorderFactory; @@ -36,7 +34,7 @@ import javax.swing.border.BevelBorder; * * @author JPEXS */ -public final class BinaryPanel extends JPanel implements ComponentListener { +public final class BinaryPanel extends JPanel { public HexView hexEditor = new HexView(); @@ -58,7 +56,15 @@ public final class BinaryPanel extends JPanel implements ComponentListener { JPanel buttonsPanel = new JPanel(new FlowLayout()); bottomPanel.add(buttonsPanel, BorderLayout.EAST); add(bottomPanel, BorderLayout.SOUTH); - addComponentListener(this); + + // todo: honfika: dynamically resize the hex data + /*addComponentListener(new ComponentAdapter() { + + @Override + public void componentResized(ComponentEvent e) { + setBinaryData(binaryDataTag); + } + });*/ swfInsidePanel = new JPanel(); swfInsidePanel.setBackground(new Color(253, 205, 137)); swfInsidePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); @@ -88,24 +94,8 @@ public final class BinaryPanel extends JPanel implements ComponentListener { hexEditor.setData(new byte[0], null, null); swfInsidePanel.setVisible(false); } + hexEditor.revalidate(); hexEditor.repaint(); } - - @Override - public void componentResized(ComponentEvent e) { - setBinaryData(binaryDataTag); - } - - @Override - public void componentMoved(ComponentEvent ce) { - } - - @Override - public void componentShown(ComponentEvent ce) { - } - - @Override - public void componentHidden(ComponentEvent ce) { - } } diff --git a/src/com/jpexs/decompiler/flash/gui/ButtonsPanel.java b/src/com/jpexs/decompiler/flash/gui/ButtonsPanel.java index 9d2f14646..dd456f4c8 100644 --- a/src/com/jpexs/decompiler/flash/gui/ButtonsPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ButtonsPanel.java @@ -1,16 +1,16 @@ /* * Copyright (C) 2010-2015 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 . */ @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui; import java.awt.Component; import java.awt.FlowLayout; +import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.ContainerEvent; @@ -36,15 +37,7 @@ public class ButtonsPanel extends JPanel { public ButtonsPanel() { super(new FlowLayout()); - listener = new ComponentListener() { - - @Override - public void componentResized(ComponentEvent e) { - } - - @Override - public void componentMoved(ComponentEvent e) { - } + listener = new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { diff --git a/src/com/jpexs/decompiler/flash/gui/controls/JPersistentSplitPane.java b/src/com/jpexs/decompiler/flash/gui/controls/JPersistentSplitPane.java index d7455b996..f83100a6d 100644 --- a/src/com/jpexs/decompiler/flash/gui/controls/JPersistentSplitPane.java +++ b/src/com/jpexs/decompiler/flash/gui/controls/JPersistentSplitPane.java @@ -18,6 +18,8 @@ package com.jpexs.decompiler.flash.gui.controls; import com.jpexs.decompiler.flash.configuration.ConfigurationItem; import java.awt.Component; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; import java.beans.PropertyChangeEvent; import javax.swing.JSplitPane; @@ -40,14 +42,42 @@ public class JPersistentSplitPane extends JSplitPane { initialize(config); } + private double getConfigValue(ConfigurationItem config) { + double pos = config.get() / 100.0; + if (pos < 0) { + pos = 0; + } else if (pos > 1) { + pos = 1; + } + + return pos; + } + private void initialize(ConfigurationItem config) { - setResizeWeight(0.5); + double pos = getConfigValue(config); + setDividerLocation(pos); + setResizeWeight(0); + + addComponentListener(new ComponentAdapter() { + + @Override + public void componentResized(ComponentEvent e) { + double pos = getConfigValue(config); + setDividerLocation(pos); + } + + @Override + public void componentShown(ComponentEvent e) { + componentResized(e); + } + }); addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, (PropertyChangeEvent pce) -> { if (getLeftComponent().isVisible() && getRightComponent().isVisible()) { - int width = ((JSplitPane) pce.getSource()).getWidth(); + JPersistentSplitPane pane = (JPersistentSplitPane) pce.getSource(); + int width = pane.getWidth() - pane.getDividerSize(); if (width != 0) { - int p = Math.round((100.0f * (Integer) pce.getNewValue() / width)); + int p = Math.round(100.0f * (Integer) pce.getNewValue() / width); config.set(p); } }