* on Mac setting Frame.IconImage will override the default preview behaviour (which is bad)

This commit is contained in:
Reinhard Pointner 2014-10-18 15:52:35 +00:00
parent a2dcb4dc84
commit 60c7d298e5
4 changed files with 20 additions and 44 deletions

View File

@ -9,6 +9,7 @@ import static net.filebot.util.ui.SwingUI.*;
import java.awt.Desktop;
import java.awt.Dialog.ModalityType;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@ -30,6 +31,8 @@ import java.security.PermissionCollection;
import java.security.Permissions;
import java.security.Policy;
import java.security.ProtectionDomain;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import java.util.Scanner;
@ -275,12 +278,21 @@ public class Main {
}
});
// window settings
// configure main window
if (isMacApp()) {
// Mac OS X specific configuration
MacAppUtilities.initializeApplication();
MacAppUtilities.setWindowCanFullScreen(frame);
} else {
// Windows / Linux specific configuration
List<Image> images = new ArrayList<Image>(3);
for (String i : new String[] { "window.icon.large", "window.icon.medium", "window.icon.small" }) {
images.add(ResourceManager.getImage(i));
}
frame.setIconImages(images);
}
frame.setLocationByPlatform(true);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// start application
frame.setVisible(true);

View File

@ -5,7 +5,6 @@ import static net.filebot.util.ui.SwingUI.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dialog.ModalExclusionType;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
@ -16,9 +15,7 @@ import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.script.Bindings;
@ -52,12 +49,6 @@ public class GroovyPad extends JFrame {
public GroovyPad() throws IOException {
super("Groovy Pad");
List<Image> images = new ArrayList<Image>(3);
for (String i : new String[] { "window.icon.large", "window.icon.medium", "window.icon.small" }) {
images.add(ResourceManager.getImage(i));
}
setIconImages(images);
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, createEditor(), createOutputLog());
splitPane.setResizeWeight(0.7);

View File

@ -10,7 +10,6 @@ import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dialog.ModalExclusionType;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetAdapter;
import java.awt.dnd.DropTargetDragEvent;
@ -20,8 +19,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -40,7 +37,6 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import net.filebot.Analytics;
import net.filebot.ResourceManager;
import net.filebot.Settings;
import net.filebot.cli.GroovyPad;
import net.filebot.mac.MacAppUtilities;
@ -68,13 +64,6 @@ public class MainFrame extends JFrame {
public MainFrame() {
super(Settings.getApplicationName());
// set taskbar / taskswitch icons
List<Image> images = new ArrayList<Image>(3);
for (String i : new String[] { "window.icon.large", "window.icon.medium", "window.icon.small" }) {
images.add(ResourceManager.getImage(i));
}
setIconImages(images);
try {
// restore selected panel
selectionList.setSelectedIndex(Integer.parseInt(persistentSelectedPanel.getValue()));

View File

@ -1,49 +1,33 @@
package net.filebot.ui;
import java.awt.Image;
import java.awt.datatransfer.Transferable;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JFrame;
import net.filebot.ResourceManager;
import net.filebot.ui.transfer.TransferablePolicy;
import net.filebot.ui.transfer.TransferablePolicy.TransferAction;
import net.filebot.util.ExceptionUtilities;
import net.miginfocom.swing.MigLayout;
public class SinglePanelFrame extends JFrame {
private final JComponent panel;
public SinglePanelFrame(PanelBuilder builder) {
super(builder.getName());
panel = builder.create();
// set taskbar / taskswitch icons
List<Image> images = new ArrayList<Image>(3);
for (String i : new String[] { "window.icon.large", "window.icon.medium", "window.icon.small" }) {
images.add(ResourceManager.getImage(i));
}
setIconImages(images);
JComponent c = (JComponent) getContentPane();
c.setLayout(new MigLayout("insets 0, nogrid, fill", "fill", "fill"));
c.add(panel);
setSize(760, 480);
}
public SinglePanelFrame publish(Transferable transferable) {
TransferablePolicy policy = (TransferablePolicy) panel.getClientProperty("transferablePolicy");
try {
if (policy != null && policy.accept(transferable)) {
policy.handleTransferable(transferable, TransferAction.ADD);
@ -51,7 +35,7 @@ public class SinglePanelFrame extends JFrame {
} catch (Exception e) {
throw ExceptionUtilities.asRuntimeException(e);
}
return this;
}
}