Skip to content

Commit 12092e6

Browse files
hansonrhansonr
authored andcommitted
PopupMenu efficiencies, Slider, j2sClazz
j2sClazz refines Clazz.getStackTrace(n < 0), where this also shows arguments. (Via swingjs.JSUtil.getStackTrace(-3), for example)
1 parent 37e561f commit 12092e6

25 files changed

+937
-316
lines changed
2.01 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190121215259
1+
20190123102751
2.01 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190121215259
1+
20190123102751
1.98 KB
Binary file not shown.

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,7 +2679,7 @@ protected void invalidateComp() {
26792679
if (!isMaximumSizeSet()) {
26802680
maxSize = null;
26812681
}
2682-
if (parent != null) {
2682+
if (parent != null && !_j2sInvalidateOnAdd) {
26832683
parent.invalidateIfValid();
26842684
}
26852685
// }
@@ -5046,7 +5046,9 @@ protected final void disableEvents(long eventsToDisable) {
50465046
* @see #isCoalescingEnabled
50475047
* @see #checkCoalescing
50485048
*/
5049-
transient private boolean coalescingEnabled = checkCoalescing();
5049+
transient private boolean coalescingEnabled = checkCoalescing();
5050+
5051+
public boolean _j2sInvalidateOnAdd = true; // not for menu items?
50505052

50515053
/**
50525054
* Weak map of known coalesceEvent overriders. Value indicates whether
@@ -5827,7 +5829,8 @@ protected void addNotifyComp() {
58275829
// relocateComponent();
58285830
// }
58295831
// }
5830-
invalidate();
5832+
if (_j2sInvalidateOnAdd )
5833+
invalidate();
58315834

58325835
// int npopups = (popups != null? popups.size() : 0);
58335836
// SwingJS TODO

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import java.awt.event.WindowAdapter;
4646
import java.awt.event.WindowEvent;
4747
import java.beans.PropertyChangeListener;
48+
49+
import javax.swing.JPopupMenu.Separator;
4850
import javax.swing.event.ChangeEvent;
4951
import javax.swing.event.ChangeListener;
5052
import javax.swing.event.EventListenerList;
@@ -755,7 +757,9 @@ public void insertSeparator(int index) {
755757
}
756758

757759
ensurePopupMenuCreated();
758-
popupMenu.insert( new JPopupMenu.Separator(), index );
760+
Separator sep = new JPopupMenu.Separator();
761+
sep._j2sInvalidateOnAdd = false;
762+
popupMenu.insert(sep, index );
759763
}
760764

761765
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public String getUIClassID() {
187187
*/
188188
@Override
189189
protected void init(String text, Icon icon) {
190+
_j2sInvalidateOnAdd = false;
190191
updateUI();
191192
if (text != null)
192193
setText(text);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ public void setLabel(String label) {
482482
* Appends a new separator at the end of the menu.
483483
*/
484484
public void addSeparator() {
485-
add( new JPopupMenu.Separator() );
485+
Separator sep = new JPopupMenu.Separator();
486+
sep._j2sInvalidateOnAdd = false;
487+
add(sep);
486488
}
487489

488490
/**

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ public boolean getSnapToTicks() {
991991
* @return true if the value snaps to the nearest slider value, else false
992992
* @see #setSnapToValue
993993
*/
994-
boolean getSnapToValue() {
994+
public boolean getSnapToValue() {
995995
return snapToValue;
996996
}
997997

@@ -1369,10 +1369,12 @@ public JSliderLabelUIResource(String text, int alignment) {
13691369
@Override
13701370
public Font getFont() {
13711371
Font font = super.getFont();
1372-
if (font != null && !(font instanceof UIResource)) {
1372+
boolean isUI = font instanceof UIResource;
1373+
if (font != null && !isUI) {
13731374
return font;
13741375
}
1375-
return JSlider.this.getFont();
1376+
Font f = JSlider.this.getFont();
1377+
return (f == null ? font : f);
13761378
}
13771379

13781380
@Override

0 commit comments

Comments
 (0)