Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #5417
| From | earlb71 <earlb71@gmail.com> |
|---|---|
| Subject | RE: Layout only works after moving a frame |
| Newsgroups | comp.lang.java.gui |
| References | <ck0dcf$l66$1@online.de> |
| Message-ID | <pKOdnSKbr93dJmrPnZ2dnUVZ_u6dnZ2d@giganews.com> (permalink) |
| Date | 2014-02-09 11:30 -0600 |
Had the same problem with a jpanel that gets dynamically resized.
In the end this is what worked for me (you have to extend the class and enable the force refresh each time you resize):
package util.graphics;
import java.awt.Graphics;
import javax.swing.JPanel;
/**
*
* @author Earl Bosch
*
*/
public abstract class JPanelDynamic extends JPanel {
public boolean forceValidate;
public boolean getForceValidate() {
return forceValidate;
}
public void enableForceValidate() {
forceValidate=true;
}
public void disableForceValidate() {
forceValidate=false;
}
public void toggleForceValidate() {
forceValidate=!forceValidate;
}
@Override
protected void paintChildren(Graphics pGraphics) {
synchronized (getTreeLock()) {
if (forceValidate) {
revalidate();
forceValidate=false;
}
super.paintChildren(pGraphics);
}
}
}
Back to comp.lang.java.gui | Previous | Next | Find similar
RE: Layout only works after moving a frame earlb71 <earlb71@gmail.com> - 2014-02-09 11:30 -0600
csiph-web