1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 03:02:22 -05:00

Revert LookAndFeel changes, switch to System.setProperty to set default LAF

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1685 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-05-16 20:37:36 +00:00
parent fa536e0824
commit d66b1c68b9
10 changed files with 22 additions and 49 deletions

View File

@ -46,7 +46,6 @@ public class AboutFrame extends JFrame {
* About frame.
*/
public AboutFrame() {
DavGatewayTray.setLookAndFeel();
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setTitle(BundleMessage.format("UI_ABOUT_DAVMAIL"));
setIconImage(DavGatewayTray.getFrameIcon());

View File

@ -70,7 +70,6 @@ public class AcceptCertificateDialog extends JDialog {
* @param certificate certificate sent by server
*/
public AcceptCertificateDialog(X509Certificate certificate) {
DavGatewayTray.setLookAndFeel();
setAlwaysOnTop(true);
String sha1Hash = DavGatewayX509TrustManager.getFormattedHash(certificate);
DateFormat formatter = DateFormat.getDateInstance(DateFormat.MEDIUM);

View File

@ -57,7 +57,6 @@ public class NotificationDialog extends JDialog {
}
public NotificationDialog(String to, String cc, String subject) {
DavGatewayTray.setLookAndFeel();
setModal(true);
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setTitle(BundleMessage.format("UI_CALDAV_NOTIFICATION"));

View File

@ -52,7 +52,6 @@ public class PasswordPromptDialog extends JDialog {
* @param prompt password prompt from PKCS11 module
*/
public PasswordPromptDialog(String prompt) {
DavGatewayTray.setLookAndFeel();
setAlwaysOnTop(true);
setTitle(BundleMessage.format("UI_PASSWORD_PROMPT"));

View File

@ -559,7 +559,6 @@ public class SettingsFrame extends JFrame {
* DavMail settings frame.
*/
public SettingsFrame() {
DavGatewayTray.setLookAndFeel();
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setTitle(BundleMessage.format("UI_DAVMAIL_SETTINGS"));
setIconImage(DavGatewayTray.getFrameIcon());

View File

@ -175,22 +175,8 @@ public class AwtGatewayTray implements DavGatewayTrayInterface {
});
}
boolean lookAndFeelSet;
public void setLookAndFeel() {
if (!lookAndFeelSet) {
lookAndFeelSet = true;
// set native look and feel
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
DavGatewayTray.warn(new BundleMessage("LOG_UNABLE_TO_SET_SYSTEM_LOOK_AND_FEEL"), e);
}
}
}
protected void createAndShowGUI() {
setLookAndFeel();
System.setProperty("swing.defaultlaf", UIManager.getSystemLookAndFeelClassName());
// get the SystemTray instance
SystemTray tray = SystemTray.getSystemTray();

View File

@ -292,7 +292,4 @@ public final class DavGatewayTray {
return result;
}
public static void setLookAndFeel() {
davGatewayTray.setLookAndFeel();
}
}

View File

@ -68,8 +68,4 @@ public interface DavGatewayTrayInterface {
*/
void init();
/**
* Set Look and Feel to system LAF
*/
void setLookAndFeel();
}

View File

@ -253,22 +253,8 @@ public class FrameGatewayTray implements DavGatewayTrayInterface {
menu.add(exitItem);
}
boolean lookAndFeelSet;
public void setLookAndFeel() {
if (!lookAndFeelSet) {
lookAndFeelSet = true;
// set native look and feel
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
DavGatewayTray.warn(new BundleMessage("LOG_UNABLE_TO_SET_SYSTEM_LOOK_AND_FEEL"), e);
}
}
}
protected void createAndShowGUI() {
setLookAndFeel();
System.setProperty("swing.defaultlaf", UIManager.getSystemLookAndFeelClassName());
image = DavGatewayTray.loadImage("tray.png");
image2 = DavGatewayTray.loadImage(AwtGatewayTray.TRAY_ACTIVE_PNG);

View File

@ -182,11 +182,13 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
lafClassName = UIManager.getCrossPlatformLookAndFeelClassName();
// replace AWT event queue Gdk error handler to avoid application crash
Toolkit.getDefaultToolkit().getSystemEventQueue().push(new SwtAwtEventQueue());
SwtAwtEventQueue.registerErrorHandler();
UIManager.setLookAndFeel(lafClassName);
SwtAwtEventQueue.handleGdkError();
//SwtAwtEventQueue.registerErrorHandler();
//UIManager.setLookAndFeel(lafClassName);
//SwtAwtEventQueue.handleGdkError();
System.setProperty("swing.defaultlaf", lafClassName);
} else {
UIManager.setLookAndFeel(lafClassName);
//UIManager.setLookAndFeel(lafClassName);
System.setProperty("swing.defaultlaf", lafClassName);
}
} catch (Exception e) {
DavGatewayTray.warn(new BundleMessage("LOG_UNABLE_TO_SET_LOOK_AND_FEEL"));
@ -194,11 +196,24 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
}
}
/**
* Create tray icon and register frame listeners.
*/
public void init() {
try {
String lafClassName = UIManager.getSystemLookAndFeelClassName();
// workaround for bug when SWT and AWT both try to access Gtk
if (lafClassName.indexOf("gtk") > 0) {
lafClassName = UIManager.getCrossPlatformLookAndFeelClassName();
// replace AWT event queue Gdk error handler to avoid application crash
Toolkit.getDefaultToolkit().getSystemEventQueue().push(new SwtAwtEventQueue());
System.setProperty("swing.defaultlaf", lafClassName);
} else {
System.setProperty("swing.defaultlaf", lafClassName);
}
} catch (Exception e) {
DavGatewayTray.warn(new BundleMessage("LOG_UNABLE_TO_SET_LOOK_AND_FEEL"));
}
new Thread("SWT") {
@Override
@ -300,7 +315,6 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
Logger rootLogger = Logger.getRootLogger();
LF5Appender lf5Appender = (LF5Appender) rootLogger.getAppender("LF5Appender");
if (lf5Appender == null) {
setLookAndFeel();
logBrokerMonitor = new LogBrokerMonitor(LogLevel.getLog4JLevels()) {
@Override
protected void closeAfterConfirm() {
@ -330,7 +344,6 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
if (Settings.isFirstStart()) {
// create frame on first call
if (settingsFrame == null) {
setLookAndFeel();
settingsFrame = new SettingsFrame();
}
settingsFrame.setVisible(true);