Post by chriscrawford on May 27, 2016 11:40:15 GMT -8
I suppose that it's not really Java that I hate: it's Swing, the subset of Java used for drawing images on the screen. Swing is insane. It makes no sense. It's a mess. So here I am working with Swing again, and I swear, I will do anything to avoid ever having to do anything with Swing after this project.
Today's problem should be simple. I have just three graphic objects:
1. mainFrame, the window containing the next two objects.
2. dialogPanel, a JPanel containing the interaction
3. historyBookPanel, a JScrollPane.
All I want is for these latter two objects to nestle side-by-side inside mainFrame. Is that asking too much? Obviously, it is asking too much of Java Swing. It insists on inserting a dead space 400 pixels wide between the two objects. I figured that it was just a Layout problem, so I tried BoxLayout. When that didn't work, I tried CardLayout, and FlowLayout, all with the same 400-pixel dead space.
Here's something truly weird: I have set a loud background color to each of the three objects:
mainFrame gets blue
dialogPanel has magenta
historyBookPanel has yellow
And the color of the dead space is.... WHITE! So where in the hell is it coming from!?!?!?!
Getting desperate, I added a RigidArea after dialogPanel and historyBookPanel. Sure enough, that pushed the historyBookPanel off the right edge of the window.
Brace yourself for this next one: I changed the dimensions of the RigidArea from {500, 0} to {-400, 0}. I was just wanting to torment Swing. And Swing obediently placed the historyBookPanel 400 pixels to the left of its original position: exactly where it should be in the first place!!!!!
Like I said, Swing is insane. But historyBookPanel is still behind the dead space. Apparently something in dialogPanel is appending a dead space 400 pixels wide onto the right edge. There's only one way to track this down: to delete graphic elements one by one until the damn dead zone disappears.
I hate Java.
Today's problem should be simple. I have just three graphic objects:
1. mainFrame, the window containing the next two objects.
2. dialogPanel, a JPanel containing the interaction
3. historyBookPanel, a JScrollPane.
All I want is for these latter two objects to nestle side-by-side inside mainFrame. Is that asking too much? Obviously, it is asking too much of Java Swing. It insists on inserting a dead space 400 pixels wide between the two objects. I figured that it was just a Layout problem, so I tried BoxLayout. When that didn't work, I tried CardLayout, and FlowLayout, all with the same 400-pixel dead space.
Here's something truly weird: I have set a loud background color to each of the three objects:
mainFrame gets blue
dialogPanel has magenta
historyBookPanel has yellow
And the color of the dead space is.... WHITE! So where in the hell is it coming from!?!?!?!
Getting desperate, I added a RigidArea after dialogPanel and historyBookPanel. Sure enough, that pushed the historyBookPanel off the right edge of the window.
Brace yourself for this next one: I changed the dimensions of the RigidArea from {500, 0} to {-400, 0}. I was just wanting to torment Swing. And Swing obediently placed the historyBookPanel 400 pixels to the left of its original position: exactly where it should be in the first place!!!!!
Like I said, Swing is insane. But historyBookPanel is still behind the dead space. Apparently something in dialogPanel is appending a dead space 400 pixels wide onto the right edge. There's only one way to track this down: to delete graphic elements one by one until the damn dead zone disappears.
I hate Java.