Skip to content

Commit 2661842

Browse files
hansonrhansonr
authored andcommitted
JLayerPane issue when resizing pallette-depth frames
1 parent 5b48017 commit 2661842

File tree

5 files changed

+17
-27
lines changed

5 files changed

+17
-27
lines changed

sources/net.sf.j2s.java.core/src/java/awt/Container.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,12 @@ private void addDelicately(Component comp, Container curParent, int index) {
808808
checkTreeLock();
809809

810810
// Check if moving between containers
811-
if (curParent != this) {
811+
if (curParent == this) {
812+
if (index < component.size()) {
813+
component.set(index, comp);
814+
_childTainted = true;
815+
}
816+
} else {
812817
//index == -1 means add to the end.
813818
if (index == -1) {
814819
component.add(comp);
@@ -823,11 +828,6 @@ private void addDelicately(Component comp, Container curParent, int index) {
823828
adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
824829
comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK));
825830
adjustDescendants(comp.countHierarchyMembers());
826-
} else {
827-
if (index < component.size()) {
828-
component.set(index, comp);
829-
_childTainted = true;
830-
}
831831
}
832832

833833
invalidateIfValid();

sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,18 @@ public boolean isBackgroundSet() {
284284
}
285285

286286
protected void updateUIZOrder() {
287-
if (uiClassID != "DesktopPaneUI")
288-
return;
287+
288+
// developer could have created their own LayeredPane
289+
// if (uiClassID != "DesktopPaneUI")
290+
// return;
291+
289292
// set the n by their position in the component list using the
290293
// same z orders that are already there - probably something like
291294
// 10000, 11000, 12000
292295
int n = ((Container) this).getComponentCount();
293-
JSComponent[] components = (JSComponent[]) getChildArray((Container) this);
294296
if (n < 2)
295297
return;
298+
JSComponent[] components = (JSComponent[]) getChildArray((Container) this);
296299
int[] zorders = new int[n];
297300
for (int i = 0; i < n; i++)
298301
zorders[i] = ((JSComponentUI) components[i].getUI()).getZIndex(null);

sources/net.sf.j2s.java.core/src/javax/swing/JComponent.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ protected void paintChildren(Graphics g) {
698698
jsg.setColor(jc.getForeground());
699699
jsg.setFont(jc.getFont());
700700
boolean shouldSetFlagBack = false;
701-
// System.out.println("JC Painting " + comp.getName() + " " + cr);
702701
try {
703702
// if (isJComponent) {
704703
// if (getFlag(ANCESTOR_USING_BUFFER)) {
@@ -3511,7 +3510,7 @@ void setUIProperty(String propertyName, Object value) {
35113510
// }
35123511
} else {
35133512
// SwingJS throw new IllegalArgumentException
3514-
System.out.println(JSToolkit.getClassNameForObject(this) + " property \""
3513+
System.out.println(getClass().getName() + " property \""
35153514
+ propertyName + "\" cannot be set using this method"
35163515
+ JSUtil.getStackTrace(5));
35173516
}
@@ -3788,10 +3787,6 @@ boolean rectangleIsObscured(int x, int y, int width, int height) {
37883787
&& (y + height) <= (cy + ch) && child.isVisible()) {
37893788

37903789
if (child instanceof JComponent) {
3791-
// System.out.println("A) checking opaque: " +
3792-
// ((JComponent)child).isOpaque() + " " + child);
3793-
// System.out.print("B) ");
3794-
// Thread.dumpStack();
37953790
return ((JComponent) child).isOpaque();
37963791
} else {
37973792
/**
@@ -4227,7 +4222,6 @@ public void revalidate() {
42274222
// internal structural change.
42284223
if (ui != null)
42294224
((JSComponentUI)ui).setTainted();
4230-
// System.out.println("revalidate on " + this);
42314225
if (getParent() == null) {
42324226
// Note: We don't bother invalidating here as once added
42334227
// to a valid parent invalidate will be invoked (addImpl
@@ -4238,11 +4232,9 @@ public void revalidate() {
42384232
return;
42394233
}
42404234
if (SwingUtilities.isEventDispatchThread()) {
4241-
// System.out.println("JC revalidate invalidating dispatch " + this);
42424235
invalidate();
42434236
RepaintManager.currentManager(this).addInvalidComponent(this);
42444237
} else {
4245-
// System.out.println("JC revalidate checking flag " +
42464238
// getFlag(REVALIDATE_RUNNABLE_SCHEDULED) + " " + this);
42474239
// To avoid a flood of Runnables when constructing GUIs off
42484240
// the EDT, a flag is maintained as to whether or not
@@ -4253,15 +4245,13 @@ public void revalidate() {
42534245
}
42544246
setFlag(REVALIDATE_RUNNABLE_SCHEDULED, true);
42554247
}
4256-
// System.out.println("JC revalidate invoking later " + this);
42574248
// final Object me = this;
42584249
Runnable callRevalidate = new Runnable() {
42594250
@Override
42604251
public void run() {
42614252
synchronized (JComponent.this) {
42624253
setFlag(REVALIDATE_RUNNABLE_SCHEDULED, false);
42634254
}
4264-
// System.out.println("JC revalidating " + me);
42654255
revalidate();
42664256
}
42674257
};
@@ -4422,8 +4412,6 @@ void _paintImmediately(int x, int y, int w, int h) {
44224412
paintImmediatelyClip.width = w;
44234413
paintImmediatelyClip.height = h;
44244414

4425-
// System.out.println("1) ************* in _paintImmediately for " + this);
4426-
44274415
boolean ontop = alwaysOnTop() && isOpaque();
44284416
if (ontop) {
44294417
SwingUtilities.computeIntersection(0, 0, getWidth(), getHeight(),

sources/net.sf.j2s.java.core/src/javax/swing/JLayeredPane.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ public void setLayer(Component c, int layer, int position) {
381381
layerObj = getObjectForLayer(layer);
382382

383383
if(layer == getLayer(c) && position == getPosition(c)) {
384+
updateUIZOrder();
384385
//SwingJS - not necessary repaint(c.getBounds());
385386
return;
386387
}
@@ -392,13 +393,11 @@ public void setLayer(Component c, int layer, int position) {
392393
getComponentToLayer().put((Component)c, layerObj);
393394

394395
if(c.getParent() == null || c.getParent() != this) {
395-
//SwingJS not necessary repaint(c.getBounds());
396+
//SwingJS not necessary: repaint(c.getBounds());
396397
return;
397398
}
398399

399-
int index = insertIndexForLayer(c, layer, position);
400-
401-
setComponentZOrder(c, index);
400+
setComponentZOrder(c, insertIndexForLayer(c, layer, position));
402401
// SwingJS not necessary repaint(c.getBounds());
403402
}
404403

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSTableUI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void setTainted() {
153153
@Override
154154
public void propertyChange(PropertyChangeEvent e) {
155155
String prop = e.getPropertyName();
156-
System.out.println("JSTableUI prop=" + e);
156+
System.out.println("JSTableUI prop=" + prop);
157157
switch (prop) {
158158
case "model":
159159
currentRowMin = currentRowMax = -1;

0 commit comments

Comments
 (0)