-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
6
-
sparc
-
solaris_10
FULL PRODUCT VERSION :
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
SunOS bagdad 5.10 Generic_118855-33 i86pc i386 i86pc
A DESCRIPTION OF THE PROBLEM :
- Create a JFrame containing a JPanel (BorderLayout) containing a JToolBar (North) and another component (Center)
- Remove the panel from the frame
- Put it in an undecorated frame
- Make the undecorated frame full screen
-> toolbar is gone
See attached program to reproduce
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached sample program and press the button
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A full screen frame containing the label and the toolbar with the button
ACTUAL -
A full screen frame containing only the label
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.EventQueue;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
public class FullScreenTest {
public static void main( String[] args ) {
try {
EventQueue.invokeAndWait( new Runnable() {
public void run() {
final JFrame testFrame = new JFrame( "TestFrame" );
final JPanel contents = new JPanel( new BorderLayout( ) );
contents.add( new JLabel( "A label in the center"), BorderLayout.CENTER );
JToolBar toolBar = new JToolBar();
JButton button = new JButton( "Switch to full screen" );
button.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println("Switching to full screen");
//remove contents from parent
Container parentContainer = contents.getParent();
if ( parentContainer != null ){
parentContainer.remove( contents );
}
//create full screen frame
JFrame fullScreenFrame = new JFrame( "Full screen");
fullScreenFrame.setUndecorated( true );
fullScreenFrame.getContentPane().setLayout( new BorderLayout( ) );
//add contents to full screen frame
fullScreenFrame.getContentPane().add( contents, BorderLayout.CENTER );
//make it full screen
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.getDefaultScreenDevice().setFullScreenWindow( fullScreenFrame );
//make the full screen frame visible and the other one invisible
fullScreenFrame.setVisible( true );
testFrame.setVisible( false );
//request focus in full screen frame
fullScreenFrame.requestFocusInWindow();
( ( JButton ) e.getSource() ).setEnabled( false );
}
} );
toolBar.add( button );
contents.add( button, BorderLayout.NORTH );
testFrame.getContentPane().add( contents );
testFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
testFrame.pack();
testFrame.setVisible( true );
}
} );
} catch ( InterruptedException e ) {
e.printStackTrace();
} catch ( InvocationTargetException e ) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
SunOS bagdad 5.10 Generic_118855-33 i86pc i386 i86pc
A DESCRIPTION OF THE PROBLEM :
- Create a JFrame containing a JPanel (BorderLayout) containing a JToolBar (North) and another component (Center)
- Remove the panel from the frame
- Put it in an undecorated frame
- Make the undecorated frame full screen
-> toolbar is gone
See attached program to reproduce
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached sample program and press the button
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A full screen frame containing the label and the toolbar with the button
ACTUAL -
A full screen frame containing only the label
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.EventQueue;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.InvocationTargetException;
public class FullScreenTest {
public static void main( String[] args ) {
try {
EventQueue.invokeAndWait( new Runnable() {
public void run() {
final JFrame testFrame = new JFrame( "TestFrame" );
final JPanel contents = new JPanel( new BorderLayout( ) );
contents.add( new JLabel( "A label in the center"), BorderLayout.CENTER );
JToolBar toolBar = new JToolBar();
JButton button = new JButton( "Switch to full screen" );
button.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println("Switching to full screen");
//remove contents from parent
Container parentContainer = contents.getParent();
if ( parentContainer != null ){
parentContainer.remove( contents );
}
//create full screen frame
JFrame fullScreenFrame = new JFrame( "Full screen");
fullScreenFrame.setUndecorated( true );
fullScreenFrame.getContentPane().setLayout( new BorderLayout( ) );
//add contents to full screen frame
fullScreenFrame.getContentPane().add( contents, BorderLayout.CENTER );
//make it full screen
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.getDefaultScreenDevice().setFullScreenWindow( fullScreenFrame );
//make the full screen frame visible and the other one invisible
fullScreenFrame.setVisible( true );
testFrame.setVisible( false );
//request focus in full screen frame
fullScreenFrame.requestFocusInWindow();
( ( JButton ) e.getSource() ).setEnabled( false );
}
} );
toolBar.add( button );
contents.add( button, BorderLayout.NORTH );
testFrame.getContentPane().add( contents );
testFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
testFrame.pack();
testFrame.setVisible( true );
}
} );
} catch ( InterruptedException e ) {
e.printStackTrace();
} catch ( InvocationTargetException e ) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------