JDK-6842197 : HeadlessException in KFM on JButton creation with
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: generic
  • Submitted: 2009-05-18
  • Updated: 2012-03-22
  • Resolved: 2009-05-21
Related Reports
Duplicate :  
Relates :  
Description
Following test 

public class TestH {
    public static void main(String[] args) {
       new javax.swing.JButton();
    }
}

throws HeadlessException with latest JDK7 in the headless (-Djava.awt.headless=true) mode:
Exception in thread "main" java.awt.HeadlessException
	at sun.awt.HeadlessToolkit.createKeyboardFocusManagerPeer(HeadlessToolkit.java:184)
	at java.awt.KeyboardFocusManager.initPeer(KeyboardFocusManager.java:454)
	at java.awt.KeyboardFocusManager.<init>(KeyboardFocusManager.java:448)
	at java.awt.DefaultKeyboardFocusManager.<init>(DefaultKeyboardFocusManager.java:64)
	at java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager(KeyboardFocusManager.java:218)
	at java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager(KeyboardFocusManager.java:209)
	at javax.swing.UIManager.initialize(UIManager.java:1442)
	at javax.swing.UIManager.maybeInitialize(UIManager.java:1421)
	at javax.swing.UIManager.getUI(UIManager.java:1009)
	at javax.swing.JButton.updateUI(JButton.java:146)
	at javax.swing.AbstractButton.init(AbstractButton.java:2169)
	at javax.swing.JButton.<init>(JButton.java:136)
	at javax.swing.JButton.<init>(JButton.java:90)
	at TestH.main(TestH.java:3)

Comments
EVALUATION Now you may need to workaround the issue reported in 6799099 with the following patch: MouseEvent.java just to make current problem to appear and to start working on it: static { - cachedNumberOfButtons = MouseInfo.getNumberOfButtons(); + cachedNumberOfButtons = 3; }
18-05-2009