Event Handling in Fullscreen Exclusive Mode???????

WIndows XP SP2
ATI 8500 All-In-Wonder
JDK 1.6
800x600 32dpi 200 refresh
1-6 buffer strategy.
the graphic rendering thread DOESN'T sleep.
Here's my problem. I have a bad trade off. In fullscreen exclusive mode my animation runs <30 fps and jerks when rendering. i.e. stop and go movement (not flickering/jittering just hesitant motion) when the animation is running. I solved this problem by raising the thread priority of the rendering (7-8). . . this resulted in latency/no activity for my input events both key and mouse. For instance closing the program alt-f4 will arbitrarily fail or be successful when the thread priority is raised above 6.
How does one accomplish a >30 fps and Instant event handling simultaneously in Fullscreen Exclusive Mode?
Is there a way to raise thread priority for event handling?
Ultimately I want to be able to perform my animations and handle key and mouse input events without having a visible 'hiccups' on the screen.
Much Appreciated!

If I remember correctly the processor is a 1.4(or)6ghz AMD Duron
Total = 1048048kb
Available = 106084kb
Sys Cache = 211788kb
PF Usage = 1.01 GB
I solved some of the problem after posting this thread. . . .
I inserted a thread.sleep(1) and my alt-f4 operation worked unhindered with the elevated thread priority.
I haven't tested it with mouse event or any other key event but at the moment it looks I may have solved the problem.
If so, my next question will be is there a way to reduce the amount of cpu power needed to run the program.
I'm afraid that the other classes that I'm adding will actually become even more process consuming than the actually rendering thread.
public class RenderScreen extends Thread
  // Screen Rendering status code
  protected final static int RUNNING = 0,
                             PAUSED = -1;
  // frames per second and process time counters
  protected long now = 0, fps = 0, fpsCount = 0, cycTime = 0;
  // thread status
  protected int status = 0;
  protected Screen screen;
  public void setStatus(int i){ status = i; };
  public void setTarget(Screen screen){ this.screen=screen; };
  public void run()
    setName("Screen Render");
    screen.createBufferStrategy(1);
    screen.strategy = screen.getBufferStrategy();
    for(;;)
      if(status == RUNNING)
        now = System.currentTimeMillis();
        while(System.currentTimeMillis() <= now+1000)
          // call system processes
          // fps increment / repaint interface
          fpsCount++;
          screen.renderView();
          try { Thread.sleep(1);}catch(InterruptedException ie){ ie.printStackTrace(); }
        fps = fpsCount;
        cycTime = System.currentTimeMillis() - (now + 1000);
        fpsCount=0;
  public RenderScreen(){};
  public RenderScreen(Screen screen){ this.screen=screen; };
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
public class Screen extends Window
  BufferedImage image = new BufferedImage(800,600,BufferedImage.TYPE_INT_RGB);
  Graphics2D gdd = image.createGraphics();
  MediaTracker tracker = new MediaTracker(this);
  Image bground = getToolkit().getImage("MajorityRule.jpg"),
        bawl = getToolkit().getImage("bawl.gif");
  RenderScreen rScreen = new RenderScreen(this);
  BufferStrategy strategy;
  Graphics g;
  Rectangle rect = new Rectangle(400,0,150,150);
  //Game game = new Game();
  public void renderView()
    g = strategy.getDrawGraphics();
    //--------- Game Procedures [start]
    gdd.drawImage(bground,0,0,this);
    gdd.drawString("fps: ["+rScreen.fps+"] Cycle Time: ["+rScreen.cycTime+"]",0,10);
    //--------- Game Procedures [end]
    //---------test
    gdd.drawImage(bawl,rect.x,rect.y,rect.width,rect.height,this);
    rect.translate(0,1);
    g.drawImage(image,0,0,this);
    //g.dispose();
    strategy.show();
  public Screen(JFrame frame)
    super(frame);
    try
      tracker.addImage(bground,0);
      tracker.addImage(bawl,1);
      tracker.waitForAll();
    catch(InterruptedException ie){ ie.printStackTrace(); }
    setBackground(Color.black);
    setForeground(Color.white);
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MajorityRule extends JFrame
  // Graphic System Handlers
  GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
  GraphicsDevice gd = ge.getDefaultScreenDevice();
  GraphicsConfiguration gc = gd.getDefaultConfiguration();
  Screen screen = new Screen(this);
  Paper paper = new Paper();
  public void windowed()
    paper.setSize(getWidth(),getHeight());
    getContentPane().add(paper);
    setResizable(false);
    setVisible(true);
  public void fullscreen()
    DisplayMode dMode = new DisplayMode(800,600,32,200);
    screen.setBounds(0,0,800,600);
    if (gd.isFullScreenSupported()) gd.setFullScreenWindow(screen);
    if (gd.isDisplayChangeSupported()){ gd.setDisplayMode(dMode); };
    screen.setIgnoreRepaint(true);
    screen.setVisible(true);
    screen.rScreen.setPriority(Thread.MAX_PRIORITY);
    screen.rScreen.start();
    screen.requestFocus();
  public MajorityRule(String args[])
    setTitle("Majority Rule [Testing Block]");
    setBounds(0,0,410,360);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getContentPane().setLayout(null);
    if (args.length > 0 && args[0].equals("-window")) windowed();
    else fullscreen();
  public static void main(String args[])
    new MajorityRule(args);
};

Similar Messages

  • Java 3D and fullscreen exclusive mode

    Hello all. I have the following problem: if I try to set fullscreen exclusive mode by calling
    device.setFullScreenWindow(window);
    then Java renders nothing. If I remove this line of code, everything works perfectly. Any ideas?
    Thanks in advance!

    you can't do that like that! it's a bit more conplicated. if you haven't,take a look at that:
    http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html

  • JMF In Fullscreen Exclusive Mode

    Hello,
    I was wondering if anyone could let me know if JMF is supported inside a Fullscreen Exclusive Application? I seem to have no problem setting up JMF Video output for a standard JFrame/Frame, but when setting a "fullscreenWindow" the Player turns black. I cannot seem to find any posts on whether this is supported or if there are bugs when in Fullscreen Exclusive Mode.
    Thanks
    -Michael Morris

    Never written a fullscreen exclusive application. In fact, I've never even heard of such a thing.
    http://download.oracle.com/javase/tutorial/extra/fullscreen/exclusivemode.html
    "In full-screen exclusive applications, painting is usually done actively by the program itself"
    Ah. So no, I don't think JMF would support that because it's not going to be actively rendering, only passively rendering in response to paint requests. It's AWT/Swing based, after all...
    But, the fact that JMF doesn't support it does not mean JMF can't support it. JMF provides a custom Renderer interface which you could implement to actively render the stuff. It'll essentially give you a copy of the video frame in a Buffer object which you can then turn into an image using the BufferToImage class and then render that however you'd render an image for a full screen exclusive application...

  • How to get out of fullscreen exclusive mode?

    I have a program that runs in full screen exclusive mode, I'd like the program to start up in windowed mode instead.
    I spent several hours trying to make it run in window mode, but I can't seem to figure it out :/
    Here's the code:
            if (graphicsDevice.isFullScreenSupported()) {
                graphicsDevice.setFullScreenWindow(this);
            if (graphicsDevice.isDisplayChangeSupported() == false) {
                return false;
            boolean displayModeAvailable = false;
            DisplayMode[] displayModes = graphicsDevice.getDisplayModes();
            for (DisplayMode mode : displayModes) {
                if (screenWidth == mode.getWidth() && screenHeight == mode.getHeight()
                        && screenColorDepth == mode.getBitDepth()) {
                    displayModeAvailable = true;
            if (displayModeAvailable == false) {
                return false;
            DisplayMode targetDisplayMode =
                    new DisplayMode(screenWidth, screenHeight,
                        screenColorDepth, DisplayMode.REFRESH_RATE_UNKNOWN);
            try {
                graphicsDevice.setDisplayMode(targetDisplayMode);
            } catch (IllegalArgumentException exception) {
                return false;
            if (EventQueue.isDispatchThread() == false) {
                EventQueue.invokeAndWait(new Runnable() {
                    public void run() {
                        createBufferStrategy(2);
            } else {
                createBufferStrategy(2);
            bufferStrategy = getBufferStrategy();
            try {
                graphics2D = (Graphics2D) bufferStrategy.getDrawGraphics();
                gameRender(graphics2D);
                if (drawGameStatistics) {
                    gameStatisticsRecorder.drawStatistics(graphics2D, 0, 0);
                graphics2D.dispose();
            } catch (Exception exception) {
                System.err.println("GameEngine.gameRender: " +
                        "Error cannot render screen:" + exception.toString());
                exception.printStackTrace();
            }Thanks

    Have you read these?
    [http://java.sun.com/docs/books/tutorial/extra/fullscreen/]
    [http://java.sun.com/docs/books/tutorial/extra/fullscreen/exclusivemode.html]
    db

  • Fullscreen Exclusive Mode

    Hi
    I am currently playing around with the new fullscreen api that is included with SDK1.4. But I have a problem. I would like to have images and Swing components showing at the same time and controling when to paint this. I am working with the code from the tutorial http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html . So far I can display the image but no Swing component. Can someone help me?
    * This test takes a number up to 13 as an argument (assumes 2 by
    * default) and creates a multiple buffer strategy with the number of
    * buffers given.  This application enters full-screen mode, if available,
    * and flips back and forth between each buffer (each signified by a different
    * color).
    import java.awt.*;
    import java.awt.image.BufferStrategy;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.*;
    public class MultiBufferTest {
        private static DisplayMode[] BEST_DISPLAY_MODES = new DisplayMode[] {
            new DisplayMode(800, 600, 32, 0),
        Frame mainFrame;
        boolean remove = false;
        public MultiBufferTest(int numBuffers, GraphicsDevice device) {
            try {
                Image image = (new LoadImage("mypic.jpg")).getImage();
                GraphicsConfiguration gc = device.getDefaultConfiguration();
                mainFrame = new Frame(gc);
                mainFrame.setUndecorated(true);
                mainFrame.setIgnoreRepaint(true);
                device.setFullScreenWindow(mainFrame);
                if (device.isDisplayChangeSupported()) {
                    chooseBestDisplayMode(device);
                Rectangle bounds = mainFrame.getBounds();
                mainFrame.createBufferStrategy(2);
                mainFrame.addMouseMotionListener(new MA());
                mainFrame.addMouseListener(new MA());
                JLabel label = new JLabel("hi");
                label.setLocation(new Point(200, 200));
                label.setForeground(new Color(122,23,52));
                mainFrame.add(label);
                BufferStrategy bufferStrategy = mainFrame.getBufferStrategy();
                int x, y;
                x=0;
                y=0;
                boolean done = false;
                while (!done){
                   Graphics g = bufferStrategy.getDrawGraphics();
                   if (!bufferStrategy.contentsLost()) {
                      g.setColor(Color.black);
                      g.fillRect(0,0,bounds.width, bounds.height);
                      mainFrame.paintComponents(g);
                      if (!remove)
                         g.drawImage(image, x, y, 60, 60, mainFrame);
                      bufferStrategy.show();
                      g.dispose();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                device.setFullScreenWindow(null);
        public void removeImage(){
           remove = true;
        private static DisplayMode getBestDisplayMode(GraphicsDevice device) {
            for (int x = 0; x < BEST_DISPLAY_MODES.length; x++) {
                DisplayMode[] modes = device.getDisplayModes();
                for (int i = 0; i < modes.length; i++) {
                    if (modes.getWidth() == BEST_DISPLAY_MODES[x].getWidth()
    && modes[i].getHeight() == BEST_DISPLAY_MODES[x].getHeight()
    && modes[i].getBitDepth() == BEST_DISPLAY_MODES[x].getBitDepth()
    return BEST_DISPLAY_MODES[x];
    return null;
    public static void chooseBestDisplayMode(GraphicsDevice device) {
    DisplayMode best = getBestDisplayMode(device);
    if (best != null) {
    device.setDisplayMode(best);
    public static void main(String[] args) {
    try {
    int numBuffers = 2;
    if (args != null && args.length > 0) {
    numBuffers = Integer.parseInt(args[0]);
    if (numBuffers < 2 || numBuffers > COLORS.length) {
    System.err.println("Must specify between 2 and "
    + COLORS.length + " buffers");
    System.exit(1);
    GraphicsEnvironment env = GraphicsEnvironment.
    getLocalGraphicsEnvironment();
    GraphicsDevice device = env.getDefaultScreenDevice();
    MultiBufferTest test = new MultiBufferTest(numBuffers, device);
    } catch (Exception e) {
    e.printStackTrace();
    System.exit(0);
    public class MA extends MouseInputAdapter{
              public void mouseClicked(MouseEvent e){
              public void mouseEntered(MouseEvent e){
              public void mouseExited(MouseEvent e){
              public void mousePressed(MouseEvent e){
    if (e.getX() < 60 && e.getY() < 60)
    removeImage();
              public void mouseReleased(MouseEvent e){
              public void mouseMoved(MouseEvent e) {
              public void mouseDragged(MouseEvent e) {
    //CLASS LOADIMAGE.JAVA
    import java.awt.*;
    class LoadImage extends Component{
    Image image;
    public LoadImage( String path ){
    Toolkit toolkit = getToolkit();
    MediaTracker tracker = new MediaTracker(this);
    image = toolkit.getImage(path);
    tracker.addImage(image,0);
    try {
    tracker.waitForID(0);
    catch(InterruptedException e){
    System.out.println("fel vid inl�sning av bilder");
    public Image getImage(){
    return image;

    If anyone is interested here is a code that solves the problem.
    * This test takes a number up to 13 as an argument (assumes 2 by
    * default) and creates a multiple buffer strategy with the number of
    * buffers given.  This application enters full-screen mode, if available,
    * and flips back and forth between each buffer (each signified by a different
    * color).
    import java.awt.*;
    import java.awt.image.BufferStrategy;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.*;
    public class MultiBufferTest {
        int x, y;
        private static DisplayMode[] BEST_DISPLAY_MODES = new DisplayMode[] {
            new DisplayMode(800, 600, 32, 0),
            new DisplayMode(800, 600, 16, 0),
        Frame mainFrame;
        boolean remove = false;
        public MultiBufferTest(int numBuffers, GraphicsDevice device) {
            try {
                Image image = (new LoadImage("backmask.jpg")).getImage();
                GraphicsConfiguration gc = device.getDefaultConfiguration();
                mainFrame = new Frame(gc);
                mainFrame.setUndecorated(true);
                mainFrame.setIgnoreRepaint(true);
                device.setFullScreenWindow(mainFrame);
                if (device.isDisplayChangeSupported())
                    chooseBestDisplayMode(device);
                Rectangle bounds = mainFrame.getBounds();
                mainFrame.createBufferStrategy(2);
                mainFrame.addMouseMotionListener(new MA());
                mainFrame.addMouseListener(new MA());
                JButton button = new JButton("ASDFJKSADFKASDFJK");
                button.setBounds(200, 200, 200, 200);
                mainFrame.add(button);
                BufferStrategy bufferStrategy = mainFrame.getBufferStrategy();
                x=0;
                y=0;
                boolean done = false;
                while (!done){
                   Graphics g = bufferStrategy.getDrawGraphics();
                   if (!bufferStrategy.contentsLost()) {
                      g.setColor(Color.black);
                      g.fillRect(0,0,bounds.width, bounds.height);
                      g.drawImage(image, x, y, 60, 60, mainFrame);
                      mainFrame.paint(g);
                      bufferStrategy.show();
                      g.dispose();                
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                device.setFullScreenWindow(null);
        public void removeImage(){
           remove = true;
        private static DisplayMode getBestDisplayMode(GraphicsDevice device) {
            for (int x = 0; x < BEST_DISPLAY_MODES.length; x++) {
                DisplayMode[] modes = device.getDisplayModes();
                for (int i = 0; i < modes.length; i++) {
                    if (modes.getWidth() == BEST_DISPLAY_MODES[x].getWidth()
    && modes[i].getHeight() == BEST_DISPLAY_MODES[x].getHeight()
    && modes[i].getBitDepth() == BEST_DISPLAY_MODES[x].getBitDepth()
    return BEST_DISPLAY_MODES[x];
    return null;
    public static void chooseBestDisplayMode(GraphicsDevice device) {
    DisplayMode best = getBestDisplayMode(device);
    if (best != null) {
    device.setDisplayMode(best);
    public static void main(String[] args) {
    try {
    GraphicsEnvironment env = GraphicsEnvironment.
    getLocalGraphicsEnvironment();
    GraphicsDevice device = env.getDefaultScreenDevice();
    MultiBufferTest test = new MultiBufferTest(2, device);
    } catch (Exception e) {
    e.printStackTrace();
    System.exit(0);
    public class MA extends MouseInputAdapter{
              public void mouseClicked(MouseEvent e){
    x = e.getX();
    y = e.getY();
              public void mouseEntered(MouseEvent e){
              public void mouseExited(MouseEvent e){
              public void mousePressed(MouseEvent e){
    x = e.getX();
    y = e.getY();
              public void mouseReleased(MouseEvent e){
    x = e.getX();
    y = e.getY();
              public void mouseMoved(MouseEvent e) {
    x = e.getX();
    y = e.getY();
              public void mouseDragged(MouseEvent e) {
    x = e.getX();
    y = e.getY();

  • Exiting programs that have use the fullscreen exclusive mode

    I have lots of problems, this is one of them:
    When making a program that uses fullscreen mode, the program does not exit by itself when it comes to the end of the program. In fact the only way I can get it to exit is through System.exit(0);
    And I don't want to use that for numerous reasons.
    try
    gd.setFullScreenWindow(jw);
    gd.setDisplayMode(dm[theDisplayMode]);
    finally
    gd.setDisplayMode(oldDisplayMode);
    gd.setFullScreenWindow(null);
    end of program......
              }

    I have lots of problems, this is one of them:
    When making a program that uses fullscreen mode, the program does not exit by itself when it comes to the end of the program. In fact the only way I can get it to exit is through System.exit(0);
    And I don't want to use that for numerous reasons.
    try
    gd.setFullScreenWindow(jw);
    gd.setDisplayMode(dm[theDisplayMode]);
    finally
    gd.setDisplayMode(oldDisplayMode);
    gd.setFullScreenWindow(null);
    end of program......
              }

  • Is it possible to use fullscreen and exclusive mode with a jfilechooser?

    is there a way to use them together? while in fullscreen exclusive mode the jfilechooser doesn't attach to fullscreen window and it halts the program.. I've tried setting the parent frame as the fullscreen frame but it's all glitched.. am I missing something?
    thank you,
    best regards,
    Jacopo

    For reference, the cross-post can be found here:
    Is it possible to use network devices (cDAQ-9188) with a PXI Real Time system?
    Jayme W.
    Applications Engineer
    National Instruments

  • Swing Components and Fullscreen Exclusive

    Hi, I am trying to write a program that can switch between full screen and windowed mode seamlessly, while still being able to use standard swing components. I have never worked with the full screen exclusive mode before and am having trouble getting the components to repaint properly.
    The following code works fine in the windowed and undecorated modes, however when I switch to fullscreen exclusive mode all components disappear and only repaint upon mouseover or other interaction. Calls to repaint do not make any difference.
    import java.awt.Dimension;
    import java.awt.DisplayMode;
    import java.awt.FlowLayout;
    import java.awt.GraphicsDevice;
    import java.awt.GraphicsEnvironment;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.WindowConstants;
    public class FullscreenTests {
         private static boolean hwlast = false;
         private static GraphicsDevice dev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
         public static void main(String[] args) {
              final JFrame fMain = new JFrame("Title");
              fMain.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              fMain.getRootPane().setLayout(new FlowLayout());
              JButton win = new JButton("Windowed");
              win.addActionListener(new ActionListener () {
                   public void actionPerformed (ActionEvent e) {
                        setWindowed(fMain);
              fMain.getRootPane().add(win);
              JButton ful = new JButton("Fullscreen");
              ful.addActionListener(new ActionListener () {
                   public void actionPerformed (ActionEvent e) {
                        setFullscreen(fMain);
              fMain.getRootPane().add(ful);
              JButton hw = new JButton("HW Fullscreen");
              hw.addActionListener(new ActionListener () {
                   public void actionPerformed (ActionEvent e) {
                        setHWFullscreen(fMain);
              fMain.getRootPane().add(hw);
              setWindowed(fMain);
         public static void setWindowed(JFrame f) {
              if (hwlast == true) {
                   dev.setFullScreenWindow(null);
                   hwlast = false;
              f.dispose();
              f.setIgnoreRepaint(false);
              f.setUndecorated(false);
              Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
              f.setSize(new Dimension(808,634));
              f.setMinimumSize(new Dimension(808,634));
              f.setLocation((d.width-f.getWidth())/2, (d.height-f.getHeight())/2);
              f.setVisible(true);
         public static void setHWFullscreen(JFrame f) {
              hwlast = true;
              f.dispose();
              f.setUndecorated(true);
              f.setIgnoreRepaint(true);
              f.setVisible(true);
              dev.setFullScreenWindow(f);
              dev.setDisplayMode(new DisplayMode(800, 600, 32, DisplayMode.REFRESH_RATE_UNKNOWN));
         public static void setFullscreen(JFrame f) {
              if (hwlast == true) {
                   dev.setFullScreenWindow(null);
                   hwlast = false;
              f.dispose();
              f.setIgnoreRepaint(false);
              f.setUndecorated(true);
              f.setSize(Toolkit.getDefaultToolkit().getScreenSize());
              f.setLocation(0,0);
              f.setVisible(true);
    }On the same note, if there are better ways of doing this I would be glad to know. This is just a quick test so I haven't done any checks etc when switching to fullscreen exclusive.

       public static void setHWFullscreen (JFrame f) {
          hwlast = true;
          f.dispose ();
          f.setUndecorated (true);
          f.setIgnoreRepaint (true);
          // add this
          Graphics g = f.getGraphics ();
          f.paintAll (g);
          f.setVisible (true);
          dev.setFullScreenWindow (f);
          dev.setDisplayMode (new DisplayMode (800, 600, 32, DisplayMode.REFRESH_RATE_UNKNOWN));
       }db

  • AWT Popup Menu in Fullscreen Exclusive + JOGL

    Our application runs in Fullscreen Exclusive mode and uses JOGL. We want the user to be able to access right-click Popup menus like in other applications. (Obviously, this isn't a game; but I figured I'd post here because game developers are the only ones likely to be familiar with Fullscreen Exclusive.)
    On Windows, I was pleasantly suprised to find that popupMenu.show() just works when I'm in Fullscreen Exclusive. The menu appears, works correctly, etc.
    On Mac OS X 10.3+, the menu does not appear. I've developed a clumsy workaround (basically, go out of fullscreen exclusive to show the menu, and then go back in when mouse events start coming again). Frankly, the way it works on a Mac is what I expected on the PC. I wouldn't expect a Popup Menu (being another window) to be able to appear over a fullscreen exclusive window.
    My question is this: Is the Windows behavior a bug? Is it video driver dependent? (It seems to work OK with all the machines we've tested on... ATI, NVIDIA, Intel) Should I be doing my Mac hack on the Windows platform to avoid some unforseen problem?
    Also, any idea what Linux or other platforms would do?

    I am not sure why that works in one OS and not the others.
    All I can say is that if it was a game, we would draw the popup menu ourself within the frame in our rendering loop, that is garunteed to work in all OS's. But your probably using AWT or SWING components. Sounds like it may be a compadibility issue, I would check the bug lists to see if that is a known issue that is being worked on.

  • JMF video while in Fullscreen Exclusive

    I am trying to show a video (using JMF) in my window while in fullscreen exclusive mode. Its for a game. It works occasionally. What I've done is turned of the repetitive rendering (from the game loop), and just added the visual component to the window (it can do its own painting). Sometimes it works fine, other times you just hear the sound, and other times its just grey or black.
    Does anybody have any idea how to get the current frame, and draw it so that I can keep the repetitive rendering (from the game loop) running.
    Any other ideas are appreciated too.

    Never written a fullscreen exclusive application. In fact, I've never even heard of such a thing.
    http://download.oracle.com/javase/tutorial/extra/fullscreen/exclusivemode.html
    "In full-screen exclusive applications, painting is usually done actively by the program itself"
    Ah. So no, I don't think JMF would support that because it's not going to be actively rendering, only passively rendering in response to paint requests. It's AWT/Swing based, after all...
    But, the fact that JMF doesn't support it does not mean JMF can't support it. JMF provides a custom Renderer interface which you could implement to actively render the stuff. It'll essentially give you a copy of the video frame in a Buffer object which you can then turn into an image using the BufferToImage class and then render that however you'd render an image for a full screen exclusive application...

  • Popups in fullscreen exclusive?

    My game is running in fullscreen exclusive mode but I need to open the occasional dialog box which new shows in front of the fullscreen main frame. Is there any way of making popups such as Dialogs or other frames appear in fullscreen exclusive mode?

    Since when did any game you ever played written in even the most powerful languages and 2d/3d api's ever display a popup during the programs run in fullscreen exclusive mode? (Error popup dialogs that end the game dont count. Unless you 'wanted' your app to end after a popup of course... o_O)
    Now, as for a more efficient/robust/intuitive/cooler etc way to display important information to the user, perhaps your game (I'm assuming its a game due to where this is posted) should draw its own frame lookalike that could function just like a popup, only it resided in the game, and had its own look and feel. ( a look that should undoubtly be way more apealing to your audience than a standard dialog...)

  • How come full screen exclusive mode is so slow?

    Hi. I am currently working on customer facing point-of-sale application. This application has a lot of animation going on and so needs quite speedy graphics performance. When I first investigated this it looked like I could do it in pure Java 2D which would be a lot easier than resorting to DirectX or OpenGL and mixing languages.
    Unfortunately as the app has moved closer to functional complete the graphics performance appears to have deteriorated to the point where it is unusable. So I have gone back to the beginning and written a test program to identify the problem .
    The tests I have done indicate that full screen exclusive mode runs about ten times slower than windowed mode. Which is mind boggling. Normally - say in DirectX - you would expect a full screen exclusive version of a games/graphics app to run a little bit quicker than a windowed version since it doesn't have to mess around with clip regions and moving vram pointers.
    My test program creates a 32 bit image and blits it to the screen a variable number of times in both windowed and full screen mode. Edited results look like this:
    iter wndw fscrn performance
         10 16.0 298.0 1862% slower
         20 47.0 610.0 1297% slower
         30 94.0 923.0 981% slower
         40 141.0 1205.0 854% slower
         50 157.0 1486.0 946% slower
         60 204.0 1877.0 920% slower
         70 234.0 2127.0 908% slower
         80 266.0 2425.0 911% slower
         90 297.0 2722.0 916% slower
         100 344.0 3253.0 945% slower
    The results are substantially the same with the openGL hint turned on (although I don't have that option on the release hardware). I am assuming that the images end up as managed since they are created through BufferedImage and the system is running under 1.5.
    Is there a way to get the full screen version running as fast as the windowed version?
    Here's the test prog:
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.JFrame;
    public class BlittingTest extends JFrame {
         BufferedImage     blankImage;
         BufferedImage     testImage;
         boolean               fullscreen;
         int                    frameNum;
         public BlittingTest( boolean fullscreen ) throws HeadlessException {
              super();
              // window setup. Escape to exit!
              addKeyListener ( new KeyAdapter() {
                   public void keyPressed( KeyEvent ke ) {
                        if (ke.getKeyCode() == KeyEvent.VK_ESCAPE ) {
                             System.exit(0);
              this.fullscreen=fullscreen;
              if ( fullscreen ) {
                   setUndecorated ( true );
              } else {
                   setTitle( "BlittingTest - <esc> to exit)");
                   setSize( 800, 600 );
              setVisible(true);
              setIgnoreRepaint(true);
              // strategy setup
              if ( fullscreen ) {
                   GraphicsDevice gdev =
                        GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
                   DisplayMode newDisplayMode = new DisplayMode (800, 600, 32,
                                                 DisplayMode.REFRESH_RATE_UNKNOWN);
                   DisplayMode oldDisplayMode = gdev.getDisplayMode();               
                   gdev.setFullScreenWindow(this);
                   gdev.setDisplayMode(newDisplayMode);
                   createBufferStrategy(2);
              // create assets
              testImage = new BufferedImage ( 50, 50, BufferedImage.TYPE_INT_ARGB );
              Graphics2D g = testImage.createGraphics();
              for ( int i = 0; i < 50; i ++ ) {
                   g.setColor( new Color ( 0, (50 - i) * 3, 0, i * 3 ));
                   g.drawLine( i, 0, i, 49 );
              g.dispose();
              blankImage = new BufferedImage ( 50, 50, BufferedImage.TYPE_INT_ARGB );
              g = blankImage.createGraphics();
              g.setColor ( Color.WHITE );
              g.fillRect( 0, 0, 50, 50 );
              g.dispose();
              frameNum = -1;
         public void init() {
              // blank both screen buffers
              for ( int i = 0; i < 2; i++ ) {
                   Graphics g2 = getBufferStrategy().getDrawGraphics();
                   g2.setColor ( Color.WHITE );
                   g2.fillRect( 0, 0, 800, 600 );
                   g2.dispose();
                   getBufferStrategy().show();
         public long testFrame ( int numBlits ) {
              int          x, y;
              long     timeIn, timeOut;
              frameNum++;
              Graphics g = getBufferStrategy().getDrawGraphics();
              g.drawImage( testImage, 0, 0, null );
              // blank previous draw
              if ( fullscreen ) {
                   if ( frameNum > 1 ) {
                        x = frameNum - 2;
                        y = frameNum - 2;
                        g.drawImage ( blankImage, x, y, null);
              } else {
                   if ( frameNum > 0 ) {
                        x = frameNum - 1;
                        y = frameNum - 1;
                        g.drawImage ( blankImage, x, y, null);                    
              x = (int) frameNum;
              y = (int) frameNum;
              timeIn = System.currentTimeMillis();
              for ( int i = 0; i < numBlits; i++ ) {
                   g.drawImage ( blankImage, x, y, null);
                   g.drawImage ( testImage, x, y, null);
              timeOut = System.currentTimeMillis();
              g.dispose();
              getBufferStrategy().show();
              return     timeOut - timeIn;
         public static void main(String[] args) {
              boolean error = false;
              BlittingTest window = null;
              double []     windowedTest = new double [101];
              double []     fullscreenTest = new double [101];
              window = new BlittingTest ( false );     
              window.init();
              for ( int f = 1; f <= 100; f++ ) {
                   windowedTest[f] = window.testFrame( f * 10 );
              window.setVisible(false);
              window.dispose();
              window = new BlittingTest ( true );     
              window.init();
              for ( int f = 1; f <= 100; f++ ) {
                   fullscreenTest[f] = window.testFrame( f * 10 );
              window.setVisible(false);
              window.dispose();
              for ( int f = 10; f <= 100; f++ ) {
                   System.out.println ( "\t" + f + "\t" + windowedTest[f] +
                             "\t" + fullscreenTest[f] +
                             "\t" + (int) ( (fullscreenTest[f]/windowedTest[f])*100.0) + "% slower");
    }

    Well I could do...
    The problem is that I am compositing multiple layers of alpha transparent images. If I just render straight to the screen I get nasty flicker where I see glimpses of the background before the top layer(s) get rendered. So I would have to render to an offscreen buffer and then blit the assembled image into the screen. Even then there will be some tearing as you can never sync to the screen refresh in windowed mode.
    And the thing is - there ought to be a 'proper' solution, g*dd*mm*t. Surely the core team didn't put together a solution that is ten times slower than it should be and then say 'What the heck, we'll release it anyway'.
    I mean, if you can't believe in Sun engineering what can you believe in?

  • Anyone have a example for useing volitile image in exclusive mode with

    i need a example of how to use a volitile image in exclusive mode with active rendering .
    anyone know of one or even partial code of how to do it ive been racking my brain trying to figure out how to do it.
    or even a example of fullscreen that i can use to draw to the screen in exclusive fullscreen mode.
    and im not talking about the sun tutorial no one can even answer my question about it when i asked in the java forum

    by the way, here's a commented version of the example I gave earlier in case the puzzle pieces are upside down for you...
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    /* Goes into FullScreen with 640x480 16 bit
    * Not all proper checks are made (like getting available DisplayModes),
    * But you can always look at the doc for the rest of the checks. Besides,
    * What computer doesn't have 640x480...?
    public class Example extends Frame implements Runnable, KeyListener {
         VolatileImage v;
         int w,h,x,size; // x and size are for the moving ball
         boolean done; // when this is true, the program exits
         public Example() {
              /* Sets up the frame to be used for fullscreen */
              super(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration());
              GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
              /* the below 2 methods aren't required
              * but using them results in best performance.*/
              setUndecorated(true);
              setIgnoreRepaint(true);
              /* A few mandatorial checks */
              if (device.isFullScreenSupported()) {
                   device.setFullScreenWindow(this);
              if (device.isDisplayChangeSupported()) {
                   device.setDisplayMode(new DisplayMode(640,480,16,0));
              /* our frame must be showing before we
              * we create our BufferStrategy or image,
              * in this case a VolatileImage.
              * Showing our frame also switches to
              * fullscreen mode.
              show();
              w = getSize().width;
              h = getSize().height;
              x = 0;
              size = 30;
              v = createVolatileImage(w,h); // creates volatile image (duh)
              done = false; // program exits when true
              addKeyListener(this); // used for exiting
              new Thread(this).start(); // starts the thread
         public void run() {
              while (!done) {
                   x += 2; // increase ball location
                   if (x >= w-size) x = 0; // back to left if all the way right
                   /* You could also use repaint() here,
                   * but you won't get a screen update
                   * until the system decides it's time.
                   * calling paint(getGraphics()) is much faster
                   paint(getGraphics());
                   /* Pausing of the thread... */
                   try {
                        Thread.sleep(1);
                   catch (InterruptedException e) {
                        done = true; // exit if there was some error
              System.exit(0); // this won't be called until done is true
         public void paint(Graphics g) {
              /* this attempts to get the graphics
              * from VolatileImage */
              Graphics gfx = v.getGraphics();
              /* If VolatileImage has no image memory,
              * we restore it and get the graphics for it */
              while (v.contentsLost()) {
                   if (v.validate(getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE) {
                        v = createVolatileImage(w,h);
                   gfx = v.createGraphics();
              /* this paints the ball etc */
              gfx.setColor(Color.black);
              gfx.fillRect(0,0,w,h);
              gfx.setColor(Color.cyan);
              gfx.fillOval(x,h/2-(size/2),size,size);
              g.drawImage(v,0,0,null); // draw the VolatileImage
         public void update(Graphics g) { // used for no blinking
              paint(g);
         public void keyPressed(KeyEvent e) {
              if (!done) done = true; // program exits on any key press
         public void keyReleased(KeyEvent e) {}
         public void keyTyped(KeyEvent e) {}
         public static void main(String[] args) {
              new Example();
    }

  • Unable to get automatic event handling for OK button.

    Hello,
    I have created a form using creatobject. This form contains an edit control and Search, Cancel buttons. I have set the Search buttons UID to "1" so it can handle the Enter key hit event. Instead its caption changes to Update when i start typing in the edit control and it does not respond to the Enter key hit. Cancel happens when Esc is hit.
    My code looks like this -
    Dim oCreationParams As SAPbouiCOM.FormCreationParams
            oCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)
            oCreationParams.UniqueID = "MySearchForm"
            oCreationParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Sizable
                    Dim oForm As SAPbouiCOM.Form = SBO_Application.Forms.AddEx(oCreationParams)
    oForm.Visible = True
    '// set the form properties
            oForm.Title = "Search Form"
            oForm.Left = 300
            oForm.ClientWidth = 500
            oForm.Top = 100
            oForm.ClientHeight = 240
            '// Adding Items to the form
            '// and setting their properties
            '// Adding an Ok button
            '// We get automatic event handling for
            '// the Ok and Cancel Buttons by setting
            '// their UIDs to 1 and 2 respectively
            oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            oItem.Left = 5
            oItem.Width = 65
            oItem.Top = oForm.ClientHeight - 30
            oItem.Height = 19
            oButton = oItem.Specific
            oButton.Caption = "Search"
            '// Adding a Cancel button
            oItem = oForm.Items.Add("2", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            oItem.Left = 75
            oItem.Width = 65
            oItem.Top = oForm.ClientHeight - 30
            oItem.Height = 19
            oButton = oItem.Specific
            oButton.Caption = "Cancel"
    oItem = oForm.Items.Add("NUM", SAPbouiCOM.BoFormItemTypes.it_EDIT)
            oItem.Left = 105
            oItem.Width = 140
            oItem.Top = 20
            oItem.Height = 16
            Dim oEditText As SAPbouiCOM.EditText = oItem.Specific
    What changes do i have to make to get the enter key to work?
    Thanks for your help.
    Regards,
    Sheetal

    Hello Felipe,
    Thanks for pointing me to the correct direction.
    So on refering to the documentation i tried out a few things. But I am still missing something here.
    I made the following changes to my code -
    oForm.AutoManaged = True
    oForm.SupportedModes = 1 ' afm_Ok
    oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            oItem.Left = 5
            oItem.Width = 65
            oItem.Top = oForm.ClientHeight - 30
            oItem.Height = 19
    oItem.SetAutoManagedAttribute(SAPbouiCOM.BoAutoManagedAttr.ama_Visible, 1, SAPbouiCOM.BoModeVisualBehavior.mvb_Default)
            oButton = oItem.Specific
            oButton.Caption = "OK"
    AND
    oForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE
    oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
            oItem.Left = 5
            oItem.Width = 65
            oItem.Top = oForm.ClientHeight - 30
            oItem.Height = 19
    oItem.AffectsFormMode = False
    I get the same behaviour OK button changes to update and enter key does not work.
    Could you please tell me find what is it that i am doing wrong?
    Regards,
    Sheetal

  • JInternalFrame Full Screen Exclusive mode lag Windows 7?

    <font size=2>Hi everyone I'm not sure if i'm posting this question in the right category so feel free to move it. I recently have been playing around with full screen exclusive mode and JInternalFrames. Now what iv'e noticed is on every platform i've tried it works fine. When clicking and dragging the JInternalFrame to a new location it is quick and responsive. However when doing this same operation in Windows 7 the JInternalFrame lags significantly behind the mouse location as i'm dragging the internal frame. I haven't had a chance to test this on any other Windows platforms such as Vista or XP but I don't think it happens on those platforms, at least I don't remember this ever happening when I had Windows Vista and it doesn't occur in Mac OS 10.6.
    The following are the circumstances i've found that produce this problem:
    *1. The program is set to Full Screen Exclusive mode.*
    *2. You are using Windows 7 (possibly other Windows platforms)*
    *3. Click and drag a JInternalFrame to a new location.*
    I've tried several things to see if it fixes the problem such as setting the look and feel to cross platform but nothing helps. In fact when the LAF is set to cross platform it is even worse.
    Now i'm new to Full Screen Exclusive mode so i'm guessing (hoping) this is a problem caused by an error on my part. Here is the source code, i'd appreciate it if you give it a try. My question is how do I fix this lag so that the JInternalFrame is quick and responsive to the user dragging the window and i'm also wondering if this only happens on Windows 7 so if anyone could also tell me if they experience the problem I am describing and the OS you are using that would be great. Thank you guys :)
    Also any input about wether i'm setting up full screen exclusive mode correctly would be much appreciated too.</font>
    package lag;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    public class InternalFrameLag
        public static void main(String[] args) {
            SwingUtilities.invokeLater( new Runnable() {
                public void run() {
                    new InternalFrameLag();
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] devices = env.getScreenDevices();
        GraphicsDevice device;
        JFrame frame = new JFrame("Internal Frame Lag");
        JDesktopPane pane = new JDesktopPane();
        JInternalFrame internalFrame = new JInternalFrame("Internal Frame", true, true, true, true);
        JButton exit = new JButton("Exit");
        public InternalFrameLag() {
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setUndecorated(true);
            exit.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.exit(0);
            exit.setPreferredSize(new Dimension(250,23));
            internalFrame.setLayout(new FlowLayout());
            internalFrame.setBounds(100,100,500,300);
            internalFrame.add(exit);
            pane.add(internalFrame);
            frame.add(pane);
            // get device that supports full screen
            for(int i = 0; i<devices.length; i++) {
                if(devices.isFullScreenSupported()) {
    device = devices[i];
    break;
    if(device!=null) {
    device.setFullScreenWindow(frame);
    internalFrame.setVisible(true);
    } else {
    System.exit(0);
    Edit: Decided to make the font size bigger. Eyestrain is killing me.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Darryl Burke wrote:
    neptune692 wrote:
    <font size=2>
    Edit: Decided to make the font size bigger. Eyestrain is killing me.Hopefully that will carry over to my response and I won't have to edit to add it ;)
    I don't see the lag you describe. There's some flicker when moving the internal frame around rapidly (it looks as if the borders follow the content a split second later, but can't be caught in a screen capture) but that's no different when I show the internal frame in a normal (not full screen) window.
    <tt>Microsoft Windows [Version 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation. All rights reserved.
    C:\Users\Darryl>java -version
    java version "1.6.0_17"
    Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
    Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)</tt>
    db<font size=2>Thanks for your reply and thanks for testing out my code. Could this lag be something wrong with my VM on Windows 7, cause the lag is extremely bad as in it takes a couple seconds for the internal frame to catch up with the mouse. I also just noticed that any other components in full screen exclusive mode on Windows 7 lag as well. Such as scrolling though a large amount of text, the scroll bar will lag far behind the mouse location and take a couple of seconds to catch up even when the mouse is moving fairly slow. I was hoping it was something in the code I was doing wrong but I guess not? Any suggestions on how I could fix this problem? It really makes my applications appear sluggish. For example when you click on a normal window such as in Windows Explorer and drag it to a new location the mouse stays in a fixed position on the window while you are dragging it. However with this lag the mouse appears to be "detatched" from the window and does not stay in the same location on the window while dragging. Does anyone else experience this or is this normal? I'm using Windows 7 64bit but I don't think that would make any difference. I'd also like to point out that I'm using Java 6 update 21 I don't know if that would make a difference opposed to update 17.
    Thanks again.</Font>
    Edited by: neptune692 on Oct 2, 2010 10:23 AM

Maybe you are looking for