Last active
December 20, 2015 00:39
-
-
Save einnocent/6042931 to your computer and use it in GitHub Desktop.
Example of possible Apache Pivot UnprocessedKeyHandler bug in fullscreen mode. Uncomment line 27 to switch between windowed and fullscreen modes. (JRE 1.7.0_21; Mac OS X 10.6.8; Apache Pivot 2.0.2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Color; | |
import java.awt.Font; | |
import org.apache.pivot.collections.Map; | |
import org.apache.pivot.wtk.Application; | |
import org.apache.pivot.wtk.Application.UnprocessedKeyHandler; | |
import org.apache.pivot.wtk.DesktopApplicationContext; | |
import org.apache.pivot.wtk.Display; | |
import org.apache.pivot.wtk.HorizontalAlignment; | |
import org.apache.pivot.wtk.Keyboard.KeyLocation; | |
import org.apache.pivot.wtk.Label; | |
import org.apache.pivot.wtk.VerticalAlignment; | |
import org.apache.pivot.wtk.Window; | |
public class FullScreenKeyDetectionErrorExample implements Application, UnprocessedKeyHandler | |
{ | |
private Window window = null; | |
public static void main(String[] args) | |
{ | |
DesktopApplicationContext.main(FullScreenKeyDetectionErrorExample.class, args); | |
} | |
@Override | |
public void startup(Display display, Map<String, String> properties) | |
{ | |
// DesktopApplicationContext.setFullScreen(true); | |
window = new Window(); | |
Label label = new Label(); | |
label.setText("Press any key to get a line of console output. This does not work in fullscreen mode."); | |
label.getStyles().put("font", new Font("Arial", Font.BOLD, 14)); | |
label.getStyles().put("color", Color.RED); | |
label.getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER); | |
label.getStyles().put("verticalAlignment", VerticalAlignment.CENTER); | |
window.setContent(label); | |
window.setTitle("Hello World!"); | |
window.setMaximized(true); | |
window.open(display); | |
} | |
@Override | |
public boolean shutdown(boolean optional) | |
{ | |
if (window != null) | |
{ | |
window.close(); | |
} | |
return false; | |
} | |
@Override | |
public void suspend() | |
{ | |
} | |
@Override | |
public void resume() | |
{ | |
} | |
@Override | |
public void keyTyped(char character) | |
{ | |
System.out.println("Character typed: " + character); | |
} | |
@Override | |
public void keyPressed(int keyCode, KeyLocation keyLocation) | |
{ | |
System.out.println("Character typed: " + keyCode); | |
} | |
@Override | |
public void keyReleased(int keyCode, KeyLocation keyLocation) | |
{ | |
System.out.println("Character typed: " + keyCode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment