Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Albireo » CTRL-C stack overflow
CTRL-C stack overflow [message #572917] Wed, 10 October 2007 17:35
James Peltzer is currently offline James PeltzerFriend
Messages: 43
Registered: July 2009
Member
I have noticed an interesting problem when you are using a Swing editor.
In a text field in the editor, hit CTRL-C. Open another editor. Watch the
stack overflow errors pile up.

Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
at java.util.Arrays.mergeSort(Arrays.java:1270)
at java.util.Arrays.sort(Arrays.java:1210)
at java.util.Collections.sort(Collections.java:159)
at
javax.swing.SortingFocusTraversalPolicy.enumerateAndSortCycl e(SortingFocusTr
aversalPolicy.java:119)
at
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
salPolicy.java:434)
at
javax.swing.LayoutFocusTraversalPolicy.getFirstComponent(Lay outFocusTraversa
lPolicy.java:148)
at
javax.swing.DefaultFocusManager.getFirstComponent(DefaultFoc usManager.java:9
9)
at
javax.swing.LegacyGlueFocusTraversalPolicy.getFirstComponent (LegacyGlueFocus
TraversalPolicy.java:115)
at
javax.swing.LegacyGlueFocusTraversalPolicy.getDefaultCompone nt(LegacyGlueFoc
usTraversalPolicy.java:133)
at
javax.swing.SortingFocusTraversalPolicy.getFirstComponent(So rtingFocusTraver
salPolicy.java:447)
...

I was able to fix this by moving the focus policy from the frame down to the
JApplet. I notice your article code says to 'consider' this in its
comments, is there any reason why you didn't do it?

-James

Modified code (inside addRootPaneContainer):
...
JApplet applet = new JApplet();

// In JRE 1.4, the JApplet makes itself a focus cycle root. This
// interferes with the focus handling installed on the parent frame,
so
// change it back to a non-root here.
// TODO: consider moving the focus policy from the Frame down to the
JApplet

EmbeddedChildFocusTraversalPolicy policy = new
EmbeddedChildFocusTraversalPolicy(awtHandler);
applet.setFocusTraversalPolicy(policy);
frame.add(applet);

return applet;
Previous Topic:From the SWT/Swing artical proposal in Bugzilla
Next Topic:Advice on getting started?
Goto Forum:
  


Current Time: Tue Sep 25 22:42:06 GMT 2018

Powered by FUDForum. Page generated in 0.02429 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top