From 84f67f1fcd87f0b3042364086551ce8597fbe0cc Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 23 Jul 2014 12:07:42 +0200 Subject: [PATCH] * TablesPanel - Fixed that restoring of divider positions did not work properly. --- .../java/mage/client/table/TablesPanel.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java index 7d9f337394..4a88375ce4 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java @@ -40,6 +40,8 @@ import java.awt.HeadlessException; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.ActionEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; import java.io.File; import java.text.DateFormat; @@ -51,6 +53,10 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JComponent; @@ -59,6 +65,7 @@ import javax.swing.JInternalFrame; import javax.swing.JLayeredPane; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; +import javax.swing.JSplitPane; import javax.swing.SwingWorker; import javax.swing.table.AbstractTableModel; import mage.cards.decks.importer.DeckImporterUtil; @@ -82,6 +89,7 @@ import mage.view.MatchView; import mage.view.TableView; import mage.view.UsersView; import org.apache.log4j.Logger; +import org.mage.plugins.card.dl.beans.PropertyChangeSupport; /** * @@ -104,7 +112,10 @@ public class TablesPanel extends javax.swing.JPanel { private Session session; private List messages; private int currentMessage; - + + private static final ScheduledExecutorService timeoutExecutor = Executors.newScheduledThreadPool(1); + private ScheduledFuture setDividerLocation; + /** Creates new form TablesPanel */ public TablesPanel() { @@ -198,8 +209,7 @@ public class TablesPanel extends javax.swing.JPanel { } }; - Action closedTableAction; - + Action closedTableAction; closedTableAction = new AbstractAction() { @Override @@ -229,8 +239,8 @@ public class TablesPanel extends javax.swing.JPanel { } } }; - - + + // adds action buttons to the table panel (don't delete this) new ButtonColumn(tableTables, openTableAction, TableTableModel.ACTION_COLUMN); new ButtonColumn(tableCompleted, closedTableAction, MatchesTableModel.ACTION_COLUMN); @@ -269,6 +279,7 @@ public class TablesPanel extends javax.swing.JPanel { } } } + public Map getUIComponents() { Map components = new HashMap<>(); @@ -368,7 +379,15 @@ public class TablesPanel extends javax.swing.JPanel { reloadMessages(); MageFrame.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable); - this.restoreDividerLocations(); + + // divider locations have to be set with delay else values set are overwritten with system defaults + setDividerLocation = timeoutExecutor.schedule(new Runnable() { + @Override + public void run() { + restoreDividerLocations(); + } + }, 300, TimeUnit.MILLISECONDS); + } protected void reloadMessages() { @@ -680,7 +699,7 @@ private void chkShowCompletedActionPerformed(java.awt.event.ActionEvent evt) {// private javax.swing.JTable tableCompleted; private javax.swing.JTable tableTables; // End of variables declaration//GEN-END:variables - + } class TableTableModel extends AbstractTableModel {