-
Bug
-
Resolution: Fixed
-
P3
-
6u10
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2184351 | 7 | Andrei Dmitriev | P4 | Closed | Fixed | b123 |
FULL PRODUCT VERSION :
java version "1.6.0_10-beta"
Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b24)
Java HotSpot(TM) Client VM (build 11.0-b12, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
Microsoft Windows 2003 Server
EXTRA RELEVANT SYSTEM CONFIGURATION :
My graphic card is Intel 865G, but I think this problem has nothing to do with graphic card.
A DESCRIPTION OF THE PROBLEM :
Screen flickers when a JFrame switches to fullscreen mode. My program works properly in J2SE5, J2SE6update2, J2SE6Update5, therefore I conclude that it's J2SE6 Update 10's problem.
I guess the possible cause is: 1. the repaint event was not handled properly.
2. SetVisble(false) does not work propoerly.
I have to write a demo program to show this problem. hope it will be helpful.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Save the source code as "AppMain.java"
2. Compile it.
3. Run it with J2SE6U10: "java AppMain"
4. Choose the Menu "File-->FullScreen(Esc to cancel)"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The screen should switch to fullscreen immediately and smoothly.
ACTUAL -
The screen does not switch to full screen mode smoothly.
It flickers several times.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
public class AppMain {
public static void main (String[] args) {
// define frame, its size and make it visible
int arg0=-1;
AppletFrame myFrame = new AppletFrame();
myFrame.setVisible(true);
} // end main method
} // end class
class AppletFrame extends JFrame implements ActionListener, WindowListener, MouseListener, MouseMotionListener, KeyListener {
private MenuBar mb=null;
private SpringLayout layout=null;
private Dimension d0=null, d1=null;
private boolean fullscreenOn=false;
private int itemcounter=0;
private boolean noSnapShot= true;
private String[] xmlname;
private String[] trackname;
private int[] initTrack;
private int trackCounter=1;
private boolean fromlocaldir=false;
private String[] localfilelist=null;
private String autoplay="enable";
private String strokemode="disable";
private boolean debug=false;
private ImageIcon jtvicon=null;
private JFileChooser _fileChooser1;
public AppletFrame(boolean debug)
{
super("SlidePlayer"); // use SlidePlay as window title
this.debug=debug;
initFrame();
}
public AppletFrame()
{
super("SlidePlayer"); // use SlidePlay as window title
initFrame();
}
public void initFrame() {
this.getContentPane().setBackground(Color.black);
// define Menubar
mb = new MenuBar();
// mb.setFont(new Font("Helvetica", Font.PLAIN, 13));
setMenuBar(mb);
// Define File menu and with Exit menu item
Menu fileMenu = new Menu("File");
MenuItem exitMenuItem = new MenuItem("Exit");
MenuItem fullscreenMenuItem = new MenuItem("Fullscreen (Esc to cancel)");
//exitMenuItem.setAccelerator( KeyStroke.getKeyStroke("alt F4") );
fileMenu.add(exitMenuItem);
fileMenu.add(fullscreenMenuItem);
// respond to file exit/fullscreen menu
exitMenuItem.addActionListener(this);
fullscreenMenuItem.addActionListener(this);
// respond to window events
addWindowListener(this);
addKeyListener(this); // Respond to keystroke
mb.add(fileMenu);
JLabel t1= new JLabel("Hello");
this.add(t1);
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(640, 480));
pack();
getContentPane().setBackground(Color.blue);
d0= this.getSize();
System.out.println("d0:"+ d0);
setVisible(true); // usual step to make frame visible
requestFocus();
requestFocusInWindow();
requestFocus();
setResizable(false);
} // end main
public void destroy()
{
System.exit(1);
}
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() instanceof MenuItem) {
String menuLabel = ((MenuItem)evt.getSource()).getLabel();
if(menuLabel.equals("Exit")) {
// close application, when exit is selected
dispose();
System.exit(0);
} // end if
if(menuLabel.equals("Fullscreen (Esc to cancel)")) {
setVisible(false);
setMenuBar(null);
dispose();
setUndecorated(true);
// switching to fullscreen mode
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(this);
// getting display resolution: width and height
int w = this.getWidth();
int h = this.getHeight();
setPreferredSize(new Dimension(w, h));
getContentPane().setBackground(Color.blue);
this.setVisible(true);
// requestFocus();
// requestFocusInWindow();
// requestFocus();
repaint();
fullscreenOn=true;
} // end if
}
} // end ActionPerformed
public void keyPressed(KeyEvent evt) {
int key = evt.getKeyCode();
// escape key to exit from fullscreen mode
if (key == KeyEvent.VK_ESCAPE) { // switching to window when press Escape key
if(fullscreenOn==true)
{
// switching to window mode
setVisible(false);
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(null);
setMenuBar(mb);
dispose();
setUndecorated(false);
this.setLayout(new BorderLayout());
this.setPreferredSize(d0);
pack();
// window should be visible
this.setVisible(true);
fullscreenOn=false;
repaint();
}
}
}
public void keyReleased(KeyEvent evt) {}
public void keyTyped(KeyEvent evt) {}
public void windowClosing(WindowEvent e) {
System.exit(1);
}
public void windowClosed(WindowEvent e) {
//This will only be seen on standard output.
}
public void windowOpened(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void mouseDragged(MouseEvent e) {}
public void mouseMoved(MouseEvent e) {}
// detect double click and single click
public void mouseClicked( MouseEvent e ) {}
public void mouseEntered( MouseEvent e ) { }
public void mouseExited( MouseEvent e ) { }
public void mousePressed( MouseEvent e ) { }
public void mouseReleased( MouseEvent e ) { }
} // end class
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround so far. I have to use J2SE6 Update 5
Release Regression From : 6u5
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
java version "1.6.0_10-beta"
Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b24)
Java HotSpot(TM) Client VM (build 11.0-b12, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
Microsoft Windows 2003 Server
EXTRA RELEVANT SYSTEM CONFIGURATION :
My graphic card is Intel 865G, but I think this problem has nothing to do with graphic card.
A DESCRIPTION OF THE PROBLEM :
Screen flickers when a JFrame switches to fullscreen mode. My program works properly in J2SE5, J2SE6update2, J2SE6Update5, therefore I conclude that it's J2SE6 Update 10's problem.
I guess the possible cause is: 1. the repaint event was not handled properly.
2. SetVisble(false) does not work propoerly.
I have to write a demo program to show this problem. hope it will be helpful.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Save the source code as "AppMain.java"
2. Compile it.
3. Run it with J2SE6U10: "java AppMain"
4. Choose the Menu "File-->FullScreen(Esc to cancel)"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The screen should switch to fullscreen immediately and smoothly.
ACTUAL -
The screen does not switch to full screen mode smoothly.
It flickers several times.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
public class AppMain {
public static void main (String[] args) {
// define frame, its size and make it visible
int arg0=-1;
AppletFrame myFrame = new AppletFrame();
myFrame.setVisible(true);
} // end main method
} // end class
class AppletFrame extends JFrame implements ActionListener, WindowListener, MouseListener, MouseMotionListener, KeyListener {
private MenuBar mb=null;
private SpringLayout layout=null;
private Dimension d0=null, d1=null;
private boolean fullscreenOn=false;
private int itemcounter=0;
private boolean noSnapShot= true;
private String[] xmlname;
private String[] trackname;
private int[] initTrack;
private int trackCounter=1;
private boolean fromlocaldir=false;
private String[] localfilelist=null;
private String autoplay="enable";
private String strokemode="disable";
private boolean debug=false;
private ImageIcon jtvicon=null;
private JFileChooser _fileChooser1;
public AppletFrame(boolean debug)
{
super("SlidePlayer"); // use SlidePlay as window title
this.debug=debug;
initFrame();
}
public AppletFrame()
{
super("SlidePlayer"); // use SlidePlay as window title
initFrame();
}
public void initFrame() {
this.getContentPane().setBackground(Color.black);
// define Menubar
mb = new MenuBar();
// mb.setFont(new Font("Helvetica", Font.PLAIN, 13));
setMenuBar(mb);
// Define File menu and with Exit menu item
Menu fileMenu = new Menu("File");
MenuItem exitMenuItem = new MenuItem("Exit");
MenuItem fullscreenMenuItem = new MenuItem("Fullscreen (Esc to cancel)");
//exitMenuItem.setAccelerator( KeyStroke.getKeyStroke("alt F4") );
fileMenu.add(exitMenuItem);
fileMenu.add(fullscreenMenuItem);
// respond to file exit/fullscreen menu
exitMenuItem.addActionListener(this);
fullscreenMenuItem.addActionListener(this);
// respond to window events
addWindowListener(this);
addKeyListener(this); // Respond to keystroke
mb.add(fileMenu);
JLabel t1= new JLabel("Hello");
this.add(t1);
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(640, 480));
pack();
getContentPane().setBackground(Color.blue);
d0= this.getSize();
System.out.println("d0:"+ d0);
setVisible(true); // usual step to make frame visible
requestFocus();
requestFocusInWindow();
requestFocus();
setResizable(false);
} // end main
public void destroy()
{
System.exit(1);
}
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() instanceof MenuItem) {
String menuLabel = ((MenuItem)evt.getSource()).getLabel();
if(menuLabel.equals("Exit")) {
// close application, when exit is selected
dispose();
System.exit(0);
} // end if
if(menuLabel.equals("Fullscreen (Esc to cancel)")) {
setVisible(false);
setMenuBar(null);
dispose();
setUndecorated(true);
// switching to fullscreen mode
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(this);
// getting display resolution: width and height
int w = this.getWidth();
int h = this.getHeight();
setPreferredSize(new Dimension(w, h));
getContentPane().setBackground(Color.blue);
this.setVisible(true);
// requestFocus();
// requestFocusInWindow();
// requestFocus();
repaint();
fullscreenOn=true;
} // end if
}
} // end ActionPerformed
public void keyPressed(KeyEvent evt) {
int key = evt.getKeyCode();
// escape key to exit from fullscreen mode
if (key == KeyEvent.VK_ESCAPE) { // switching to window when press Escape key
if(fullscreenOn==true)
{
// switching to window mode
setVisible(false);
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(null);
setMenuBar(mb);
dispose();
setUndecorated(false);
this.setLayout(new BorderLayout());
this.setPreferredSize(d0);
pack();
// window should be visible
this.setVisible(true);
fullscreenOn=false;
repaint();
}
}
}
public void keyReleased(KeyEvent evt) {}
public void keyTyped(KeyEvent evt) {}
public void windowClosing(WindowEvent e) {
System.exit(1);
}
public void windowClosed(WindowEvent e) {
//This will only be seen on standard output.
}
public void windowOpened(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void mouseDragged(MouseEvent e) {}
public void mouseMoved(MouseEvent e) {}
// detect double click and single click
public void mouseClicked( MouseEvent e ) {}
public void mouseEntered( MouseEvent e ) { }
public void mouseExited( MouseEvent e ) { }
public void mousePressed( MouseEvent e ) { }
public void mouseReleased( MouseEvent e ) { }
} // end class
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround so far. I have to use J2SE6 Update 5
Release Regression From : 6u5
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
- backported by
-
JDK-2184351 Screen flickers when a JFrame switches to fullscreen mode
- Closed
- relates to
-
JDK-6822409 PIT : Making the fullScreen frame to once again switch to fullscreen results in flickering.
- Open
-
JDK-6587847 PIT: D3D: FullScreen window fails to render AWT components, WinXP
- Closed