4

with the JPanel defined below (embedded in a JTabPanel in a JSplitPane):

If I maximize, the panel is redrawn correctly to the new dimensions If I minimize the panel is NOT redrawn to the previous dimensions If I drag the corner to increase the size the panel is redrawn to correct dimensions If I drag a corner to decrease size the panel is NOT redrawn to the expected dimensions

container.setLayout(new MigLayout("debug,fillx,wrap 5",
    "[75:75:75][fill][75:75:75][fill][140:140:140,align left]"));
container.add(labelSrcTitle, "span 4");
container.add(buttonAddRef, "");
container.add(srcTitle, "span");
container.add(srcListing, "span,grow");
container.add(sepRef,"span,growx");
container.add(refTitle,"span");
container.add(refListing,"span 4,grow");
container.add(buttonEdit,"split 2");
container.add(buttonDelete,"");
container.add(name,"span 4,growx");
container.add(buttonSEdit,"split 3");
container.add(buttonSDelete);
container.add(buttonSAdd,"");
container.add(lType,"");
container.add(lClaim,"grow");
container.add(lQual,"");
container.add(lNotes,"grow");
container.add(buttonCEdit, "split 3");
container.add(buttonCDelete);
container.add(buttonCAdd, "");

I would like (and expect) that if I maximize then minimize, the screen will get redrawn to its original configuration. what am I missing? If it matters, all the JTextArea fields are line wrap true.

Edited:

Here is a much simpler example - the issue seems to be with JTextArea with linewrap set on. The following code in a JFrame recreates the issue:

    JPanel root = new JPanel(new MigLayout("fill,debug"));
    JTextArea t = new JTextArea();

    t.setLineWrap(true);

    root.add(t,"growx");
    setContentPane(root);
    setLocationRelativeTo(null);
    setSize(200, 200);
ed4becky
  • 1,488
  • 1
  • 17
  • 54
  • I would guess that the "name" component (says "Michaels, Edward") is pushing everything out for some reason. See how it fills its cell, when the other "span 4" components don't? Try taking the growx off of that and see what difference it makes. Depending on the version you've got, push/grow behave a little bit weird in my experience. My understanding is that the "fill" in the row spec equates to a "push" in the cell spec. Maybe it's something like this: http://stackoverflow.com/questions/2475787/miglayout-jtextarea-is-not-shrinking-when-used-with-linewrap-true/2739127#2739127 – Jim Mar 16 '12 at 19:16
  • Problem solved. After identifying the issue to JTextArea and Line Wrap, I determined that it was a symptom of MigLayout and JTextArea documented in several places; and resolved it by changing root.add(t,"growx") to root.add(t,"growx,wmin 10") – ed4becky Mar 18 '12 at 21:47

1 Answers1

3

Problem solved. After identifying the issue to JTextArea and Line Wrap, I determined that it was a symptom of MigLayout and JTextArea Line wrap documented in several places; and resolved it by changing root.add(t,"growx") to root.add(t,"growx,wmin 10")

ed4becky
  • 1,488
  • 1
  • 17
  • 54
  • In my case it's a `JLabel` with html text to enable automatic wrapping inside the label. It cannot calculate the proper length and always occupy the whole width. Adding the component with fixed(`w 200!`)/proper preferred size(`w :200:`) solved the problem. – WesternGun Apr 28 '17 at 07:24