PLATFORM now specifiable from properties
AWTAdapter renamed to SwingAdapter Adapter renamed to PlatformAdapter
This commit is contained in:
parent
39140f1072
commit
27f67d1ffa
|
@ -40,7 +40,7 @@ package org.lwjgl;
|
||||||
* @author cix_foo <cix_foo@users.sourceforge.net>
|
* @author cix_foo <cix_foo@users.sourceforge.net>
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
public interface Adapter {
|
public interface PlatformAdapter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spawn a "modal" dialog in the centre of the screen with a message in it
|
* Spawn a "modal" dialog in the centre of the screen with a message in it
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002 Lightweight Java Game Library Project
|
* Copyright (c) 2002-2004 Lightweight Java Game Library Project
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -32,33 +32,38 @@
|
||||||
package org.lwjgl;
|
package org.lwjgl;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
* <p>
|
||||||
* An AWT adapter for using AWT to take care of things on platforms where we
|
* A Swing adapter for using Swing to take care of things on platforms where we
|
||||||
* know AWT is present.
|
* know Swing is present.
|
||||||
* <p><em>Note</em> To compile LWJGL applications with Excelsior JET that use JetPerfect
|
* <p><em>Note</em> To compile LWJGL applications with Excelsior JET that use JetPerfect
|
||||||
* and that have no dependencies on AWT, do not include this class in your
|
* and that have no dependencies on Swing, do not include this class in your
|
||||||
* JET project.
|
* JET project.
|
||||||
*
|
*
|
||||||
* @author cix_foo <cix_foo@users.sourceforge.net>
|
* @author cix_foo <cix_foo@users.sourceforge.net>
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
final class AWTAdapter implements Adapter {
|
final class SwingAdapter implements PlatformAdapter {
|
||||||
/**
|
/**
|
||||||
* C'tor
|
* Constructs a new SwingAdapter
|
||||||
*/
|
*/
|
||||||
AWTAdapter() {
|
SwingAdapter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spawn a "modal" dialog in the centre of the screen with a message in it
|
* Spawn a "modal" dialog in the centre of the screen with a message in it
|
||||||
* and an OK button. This method blocks until the dialog is dismissed.
|
* and an OK button. This method blocks until the dialog is dismissed.
|
||||||
* @param title
|
* @param title Title of alert
|
||||||
* @param message
|
* @param message Message to show in alert
|
||||||
*/
|
*/
|
||||||
public void alert(String title, String message) {
|
public void alert(String title, String message) {
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
|
} catch(Exception e) {
|
||||||
|
}
|
||||||
JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE);
|
JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -79,6 +79,9 @@ public final class Sys {
|
||||||
/** The native library name */
|
/** The native library name */
|
||||||
private static String LIBRARY_NAME = "lwjgl";
|
private static String LIBRARY_NAME = "lwjgl";
|
||||||
|
|
||||||
|
/** The platform being executed on */
|
||||||
|
private static String PLATFORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug flag.
|
* Debug flag.
|
||||||
*/
|
*/
|
||||||
|
@ -86,6 +89,12 @@ public final class Sys {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
|
// check platform name, and default to awt
|
||||||
|
PLATFORM = System.getProperty("org.lwjgl.Sys.platform");
|
||||||
|
if(PLATFORM == null) {
|
||||||
|
PLATFORM = "org.lwjgl.SwingAdapter";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,10 +217,10 @@ public final class Sys {
|
||||||
nAlert(title, message);
|
nAlert(title, message);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Adapter adapter = (Adapter) Class.forName("org.lwjgl.AWTAdapter").newInstance(); // This avoids a Jet error message
|
PlatformAdapter adapter = (PlatformAdapter) Class.forName(PLATFORM).newInstance(); // This avoids a Jet error message
|
||||||
adapter.alert(title, message);
|
adapter.alert(title, message);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace(System.err);
|
Sys.log("Unable to display alert using: " + PLATFORM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue