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>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public interface Adapter {
|
||||
public interface PlatformAdapter {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -32,33 +32,38 @@
|
|||
package org.lwjgl;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* An AWT adapter for using AWT to take care of things on platforms where we
|
||||
* know AWT is present.
|
||||
* <p>
|
||||
* A Swing adapter for using Swing to take care of things on platforms where we
|
||||
* know Swing is present.
|
||||
* <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.
|
||||
*
|
||||
* @author cix_foo <cix_foo@users.sourceforge.net>
|
||||
* @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
|
||||
* and an OK button. This method blocks until the dialog is dismissed.
|
||||
* @param title
|
||||
* @param message
|
||||
* @param title Title of alert
|
||||
* @param message Message to show in alert
|
||||
*/
|
||||
public void alert(String title, String message) {
|
||||
JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE);
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch(Exception e) {
|
||||
}
|
||||
JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
}
|
|
@ -78,6 +78,9 @@ public final class Sys {
|
|||
|
||||
/** The native library name */
|
||||
private static String LIBRARY_NAME = "lwjgl";
|
||||
|
||||
/** The platform being executed on */
|
||||
private static String PLATFORM;
|
||||
|
||||
/**
|
||||
* Debug flag.
|
||||
|
@ -86,6 +89,12 @@ public final class Sys {
|
|||
|
||||
static {
|
||||
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);
|
||||
} else {
|
||||
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);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
Sys.log("Unable to display alert using: " + PLATFORM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue