View unanswered posts | View active topics It is currently Wed Apr 26, 2017 1:22 am



Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
 NullPointerException with JTextPane 
Author Message

Joined: Tue Dec 30, 2008 6:26 pm
Posts: 20
Post Re: NullPointerException with JTextPane
Argh, the forum won't let me attach the two patches. Here they are inline.

Patch 1, which bails out:
Code:
--- MigLayout.java      2012-12-08 16:51:49.735523959 +0100
+++ MigLayout.java      2012-12-08 16:58:29.427205887 +0100
@@ -572,10 +572,20 @@
                if (wBounds == null && hBounds == null)
                        return;
 
-               Window win = ((Window) SwingUtilities.getAncestorOfClass(Window.class, (Component) parent.getComponent()));
+               final Component pc = (Component) parent.getComponent();
+
+               Window win = ((Window) SwingUtilities.getAncestorOfClass(Window.class, pc));
                if (win == null)
                        return;
 
+               Container c = pc instanceof Container ? (Container) pc : pc.getParent();
+               for ( ; c != null ; c = c.getParent()) {
+                       final LayoutManager l = c.getLayout();
+                       if (l instanceof BoxLayout || l instanceof OverlayLayout) {
+                               return;
+                       }
+               }
+
                Dimension prefSize = win.getPreferredSize();
                int targW = constrain(checkParent(win), win.getWidth(), prefSize.width, wBounds);
                int targH = constrain(checkParent(win), win.getHeight(), prefSize.height, hBounds);

Patch 2, which invalidates the bad layouts:
Code:
--- MigLayout.java      2012-12-08 16:51:49.735523959 +0100
+++ MigLayout.java      2012-12-08 17:39:22.117399151 +0100
@@ -572,10 +572,20 @@
                if (wBounds == null && hBounds == null)
                        return;
 
-               Window win = ((Window) SwingUtilities.getAncestorOfClass(Window.class, (Component) parent.getComponent()));
+               final Component pc = (Component) parent.getComponent();
+
+               Window win = ((Window) SwingUtilities.getAncestorOfClass(Window.class, pc));
                if (win == null)
                        return;
 
+               Container c = pc instanceof Container ? (Container) pc : pc.getParent();
+               for ( ; c != null ; c = c.getParent()) {
+                       final LayoutManager l = c.getLayout();
+                       if (l instanceof BoxLayout || l instanceof OverlayLayout) {
+                               ((LayoutManager2) l).invalidateLayout(c);
+                       }
+               }
+
                Dimension prefSize = win.getPreferredSize();
                int targW = constrain(checkParent(win), win.getWidth(), prefSize.width, wBounds);
                int targH = constrain(checkParent(win), win.getHeight(), prefSize.height, hBounds);


Sat Dec 08, 2012 8:00 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: NullPointerException with JTextPane
Thank you for the patches and the hard work to find the problem. I will incorporate one of them in the upcoming release. I have pushed that release much more than I intended since I have a lot of work atm. I will release it though but not before Christmas unfortunately.

Cheers,
Mikael


Sun Dec 09, 2012 11:27 am
Profile WWW
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: NullPointerException with JTextPane
Thank you for your patience,

I have applied the second patch though I had already made some other changes so I am unsure if the end solution still fixes your problem. You'll have to test it when the new version comes out i a week or so.

Cheers,
Mikael


Fri Feb 22, 2013 2:59 pm
Profile WWW

Joined: Tue Dec 30, 2008 6:26 pm
Posts: 20
Post Re: NullPointerException with JTextPane
MiG Support wrote:
Thank you for your patience,

I have applied the second patch though I had already made some other changes so I am unsure if the end solution still fixes your problem. You'll have to test it when the new version comes out i a week or so..

I'd be happy to verify whether the problem is solved before you do the next release. Are you planning to add much more over what's in git now before next week?


Fri Feb 22, 2013 5:30 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: NullPointerException with JTextPane
Excellent!

No, I will only commit visual compensation for edges on OS X. All other issues are solved and committed and pushed.

Cheers,
Mikael


Fri Feb 22, 2013 5:39 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 20 posts ]  Go to page Previous  1, 2

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.