-
Bug
-
Resolution: Fixed
-
P2
-
6
-
b94
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b84)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b84, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux fly 2.6.12-10-386 #1 Fri Apr 28 13:13:44 UTC 2006 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Exception is thrown when displaying application with JInternalFrame if GTK LAF is used. This happens with various GTK themes.
The reason of this exception is that there is a bug in parsing Metacity theme file (metacity-theme-1.xml). Details:
Current code assumes (see com.sun.java.swing.plaf.gtk.Metacity#updateFrameGeometry(SynthContext context)), that in theme file exists 'frame_style_set' tag with 'name' attribute equals 'normal'. This is invalid assumption because 'name' attribute value is up to theme maker (although usually such tag exists...).
To fix this bug code should check for 'window' tag with attribute 'type' equals 'normal' and then read 'style_set' attribute from tag, which points to proper 'frame_style_set'.
Example from New-Human Blue metacity-theme-1.xml:
<frame_style_set name="frame_style_set_normal">
<frame focus="yes" state="normal" resize="both" style="frame_style_normal_focused"/>
<frame focus="no" state="normal" resize="both" style="frame_style_normal_unfocused"/>
<frame focus="yes" state="maximized" style="frame_style_normal_focused"/>
<frame focus="no" state="maximized" style="frame_style_normal_unfocused"/>
<frame focus="yes" state="shaded" style="frame_style_normal_focused"/>
<frame focus="no" state="shaded" style="frame_style_normal_unfocused"/>
<frame focus="yes" state="maximized_and_shaded" style="frame_style_normal_focused"/>
<frame focus="no" state="maximized_and_shaded" style="frame_style_normal_unfocused"/>
</frame_style_set>
<window type="normal" style_set="frame_style_set_normal"/>
Fix should be trivial here, just change code in updateFrameGeometry() method from:
if (frame_style_set == null)
{
frame_style_set = getNode("frame_style_set", new String[] { "name", "normal" });
}
to:
if (frame_style_set == null)
{
Node window = getNode("window", new String[] {"type", "normal"});
if (window != null)
frame_style_set = getNode("frame_style_set", new String[] {"name", getStringAttr(window, "style_set")});
}
Anyway, some fallback mechanism is needed in case of invalid Metacity theme file...
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Select New-Human Blue theme, run SwingSet2 demo, switch to GTK LAF, or run testcase.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.sun.java.swing.plaf.gtk.Metacity.getBorderInsets(Metacity.java:1393)
at com.sun.java.swing.plaf.gtk.GTKPainter.getInsets(GTKPainter.java:81)
at com.sun.java.swing.plaf.gtk.GTKStyle.getInsets(GTKStyle.java:261)
at javax.swing.plaf.synth.SynthStyle.installDefaults(SynthStyle.java:876)
at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(SynthLookAndFeel.java:252)
at javax.swing.plaf.synth.SynthInternalFrameUI.updateStyle(SynthInternalFrameUI.java:75)
at javax.swing.plaf.synth.SynthInternalFrameUI.installDefaults(SynthInternalFrameUI.java:51)
at javax.swing.plaf.basic.BasicInternalFrameUI.installUI(BasicInternalFrameUI.java:92)
at javax.swing.JComponent.setUI(JComponent.java:611)
at javax.swing.JInternalFrame.setUI(JInternalFrame.java:370)
at javax.swing.JInternalFrame.updateUI(JInternalFrame.java:386)
at javax.swing.JInternalFrame.<init>(JInternalFrame.java:333)
at javax.swing.JInternalFrame.<init>(JInternalFrame.java:251)
at TestFrame.<init>(TestFrame.java:12)
at TestFrame$1.run(TestFrame.java:34)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:598)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
public class TestFrame extends JFrame
{
public TestFrame()
{
JDesktopPane desktop = new JDesktopPane();
JInternalFrame frame = new JInternalFrame();
frame.setVisible(true);
frame.setSize(300, 300);
desktop.add(frame);
setContentPane(desktop);
setSize(500, 500);
}
public static void main(String[] args) throws Exception
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {}
new TestFrame().setVisible(true);
}
});
}
}
---------- END SOURCE ----------
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b84)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b84, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux fly 2.6.12-10-386 #1 Fri Apr 28 13:13:44 UTC 2006 i686 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Exception is thrown when displaying application with JInternalFrame if GTK LAF is used. This happens with various GTK themes.
The reason of this exception is that there is a bug in parsing Metacity theme file (metacity-theme-1.xml). Details:
Current code assumes (see com.sun.java.swing.plaf.gtk.Metacity#updateFrameGeometry(SynthContext context)), that in theme file exists 'frame_style_set' tag with 'name' attribute equals 'normal'. This is invalid assumption because 'name' attribute value is up to theme maker (although usually such tag exists...).
To fix this bug code should check for 'window' tag with attribute 'type' equals 'normal' and then read 'style_set' attribute from tag, which points to proper 'frame_style_set'.
Example from New-Human Blue metacity-theme-1.xml:
<frame_style_set name="frame_style_set_normal">
<frame focus="yes" state="normal" resize="both" style="frame_style_normal_focused"/>
<frame focus="no" state="normal" resize="both" style="frame_style_normal_unfocused"/>
<frame focus="yes" state="maximized" style="frame_style_normal_focused"/>
<frame focus="no" state="maximized" style="frame_style_normal_unfocused"/>
<frame focus="yes" state="shaded" style="frame_style_normal_focused"/>
<frame focus="no" state="shaded" style="frame_style_normal_unfocused"/>
<frame focus="yes" state="maximized_and_shaded" style="frame_style_normal_focused"/>
<frame focus="no" state="maximized_and_shaded" style="frame_style_normal_unfocused"/>
</frame_style_set>
<window type="normal" style_set="frame_style_set_normal"/>
Fix should be trivial here, just change code in updateFrameGeometry() method from:
if (frame_style_set == null)
{
frame_style_set = getNode("frame_style_set", new String[] { "name", "normal" });
}
to:
if (frame_style_set == null)
{
Node window = getNode("window", new String[] {"type", "normal"});
if (window != null)
frame_style_set = getNode("frame_style_set", new String[] {"name", getStringAttr(window, "style_set")});
}
Anyway, some fallback mechanism is needed in case of invalid Metacity theme file...
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Select New-Human Blue theme, run SwingSet2 demo, switch to GTK LAF, or run testcase.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.sun.java.swing.plaf.gtk.Metacity.getBorderInsets(Metacity.java:1393)
at com.sun.java.swing.plaf.gtk.GTKPainter.getInsets(GTKPainter.java:81)
at com.sun.java.swing.plaf.gtk.GTKStyle.getInsets(GTKStyle.java:261)
at javax.swing.plaf.synth.SynthStyle.installDefaults(SynthStyle.java:876)
at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(SynthLookAndFeel.java:252)
at javax.swing.plaf.synth.SynthInternalFrameUI.updateStyle(SynthInternalFrameUI.java:75)
at javax.swing.plaf.synth.SynthInternalFrameUI.installDefaults(SynthInternalFrameUI.java:51)
at javax.swing.plaf.basic.BasicInternalFrameUI.installUI(BasicInternalFrameUI.java:92)
at javax.swing.JComponent.setUI(JComponent.java:611)
at javax.swing.JInternalFrame.setUI(JInternalFrame.java:370)
at javax.swing.JInternalFrame.updateUI(JInternalFrame.java:386)
at javax.swing.JInternalFrame.<init>(JInternalFrame.java:333)
at javax.swing.JInternalFrame.<init>(JInternalFrame.java:251)
at TestFrame.<init>(TestFrame.java:12)
at TestFrame$1.run(TestFrame.java:34)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:598)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
public class TestFrame extends JFrame
{
public TestFrame()
{
JDesktopPane desktop = new JDesktopPane();
JInternalFrame frame = new JInternalFrame();
frame.setVisible(true);
frame.setSize(300, 300);
desktop.add(frame);
setContentPane(desktop);
setSize(500, 500);
}
public static void main(String[] args) throws Exception
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {}
new TestFrame().setVisible(true);
}
});
}
}
---------- END SOURCE ----------