Skip to content

Commit 5b28ca1

Browse files
hansonrhansonr
authored andcommitted
faster console clearing; Number.min/max/sum
working on menuSelected()
1 parent cdc91a7 commit 5b28ca1

File tree

13 files changed

+749
-182
lines changed

13 files changed

+749
-182
lines changed
1.62 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190404154041
1+
20190408233032
1.62 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190404154041
1+
20190408233032
1.61 KB
Binary file not shown.

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,7 @@ public static void convertPointToScreen(Point p,Component c) {
382382
int x,y;
383383
boolean done = false;
384384
do {
385-
if(c instanceof JComponent) {
386-
x = ((JComponent)c).getX();
387-
y = ((JComponent)c).getY();
388-
} else if((done = c.isWindowOrJSApplet())) {
385+
if((done = c.isWindowOrJSApplet())) {
389386
try {
390387
Point pp = c.getLocationOnScreen();
391388
x = pp.x;
@@ -417,10 +414,7 @@ public static void convertPointFromScreen(Point p,Component c) {
417414
int x,y;
418415

419416
do {
420-
if(c instanceof JComponent) {
421-
x = ((JComponent)c).getX();
422-
y = ((JComponent)c).getY();
423-
} else if(c.isWindowOrJSApplet()) {
417+
if(c.isWindowOrJSApplet()) {
424418
try {
425419
Point pp = c.getLocationOnScreen();
426420
x = pp.x;
@@ -429,7 +423,7 @@ public static void convertPointFromScreen(Point p,Component c) {
429423
x = c.getX();
430424
y = c.getY();
431425
}
432-
} else {
426+
} else {
433427
x = c.getX();
434428
y = c.getY();
435429
}

sources/net.sf.j2s.java.core/src/swingjs/jquery/j2sMenu.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ try{
137137
n||(n = me.active || me.activeMenu);
138138
if (n.is(".ui-state-disabled"))
139139
return;
140+
140141
n = e.extend({of:n},me.options.position);
142+
143+
var ui = me.activeMenu && me.activeMenu[0] && me.activeMenu[0]["data-ui"];
144+
ui && ui.processJ2SMenuCmd$OA([trigger,me,e,t,n,why]);
145+
146+
141147
clearMe(me.timer, trigger);
142148
me.refresh("_openSubmenu",n);
143149
var v = me.element.find(".ui-j2smenu").not(t.parents(".ui-j2smenu"));
@@ -149,7 +155,7 @@ try{
149155
} catch(err){
150156
System.out.println("j2sMenu error: " + err);
151157
}
152-
break;
158+
return;
153159
case "_activate":
154160
me.active.is(".ui-state-disabled")||(me.active.children(".a[aria-haspopup='true']").length?me.expand(t):me.select(t));
155161
break;
@@ -299,6 +305,7 @@ try{
299305
}
300306
break;
301307
}
308+
302309
var ui = me.activeMenu && me.activeMenu[0] && me.activeMenu[0]["data-ui"];
303310
ui && ui.processJ2SMenuCmd$OA([trigger,me,e,t,n,why]);
304311
}

sources/net.sf.j2s.java.core/src/test/JalviewJSTest.java

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.awt.Dimension;
88
import java.awt.Font;
99
import java.awt.GridLayout;
10+
import java.awt.Insets;
1011
import java.awt.Label;
1112
import java.awt.MediaTracker;
1213
import java.awt.event.ActionEvent;
@@ -40,6 +41,7 @@
4041
import javax.swing.MenuSelectionManager;
4142
import javax.swing.SwingConstants;
4243
import javax.swing.WindowConstants;
44+
import javax.swing.border.CompoundBorder;
4345
import javax.swing.border.LineBorder;
4446
import javax.swing.border.TitledBorder;
4547
import javax.swing.event.MenuEvent;
@@ -280,14 +282,29 @@ public void actionPerformed(ActionEvent e) {
280282
l2.setFont(font);
281283
l2.setHorizontalTextPosition(SwingConstants.LEADING);
282284
l2.setHorizontalAlignment(SwingConstants.LEFT);
283-
285+
l2.setBorder(new LineBorder(Color.red, 7));
286+
284287
JButton b1 = new JButton("right left");
285288
b1.setIcon(getImage("test2.png"));
286289
b1.setFont(font);
287-
b1.setBorder(new LineBorder(Color.red, 5));
290+
// totally ignored
291+
//b1.setMargin(new Insets(5,35,5,5));
292+
//b1.setBorder(null);
288293
b1.setHorizontalTextPosition(SwingConstants.RIGHT);
289294
b1.setHorizontalAlignment(SwingConstants.LEFT);
295+
Insets i = (b1.getBorder() instanceof CompoundBorder ?
296+
((CompoundBorder) b1.getBorder()).getOutsideBorder().getBorderInsets(b1) :
297+
b1.getInsets());
298+
299+
Insets ii = (b1.getBorder() instanceof CompoundBorder ?
300+
((CompoundBorder) b1.getBorder()).getInsideBorder().getBorderInsets(b1) :
301+
null);
290302

303+
System.out.println(b1.getBorder() + "\n" +
304+
305+
i + "\n" + ii + "\n" + b1.getInsets() + "\n" + b1.getMargin());
306+
307+
System.out.println(b1.getPreferredSize());
291308
JCheckBox cb3 = new JCheckBox("leading,left-to-right,rt");
292309
cb3.setFont(font);
293310
cb3.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
@@ -360,6 +377,7 @@ public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager
360377
super.processKeyEvent(e, path, m);
361378
}
362379
};
380+
363381
cb5m.setFont(font);
364382
cb5m.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
365383
cb5m.setHorizontalTextPosition(SwingConstants.TRAILING);
@@ -426,6 +444,25 @@ public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager
426444
}
427445
}
428446
;
447+
m1.addMenuListener(new MenuListener() {
448+
449+
@Override
450+
public void menuSelected(MenuEvent e) {
451+
System.out.println("JalviewJSTest menu selected");
452+
}
453+
454+
@Override
455+
public void menuDeselected(MenuEvent e) {
456+
System.out.println("JalviewJSTest menu deselected");
457+
}
458+
459+
@Override
460+
public void menuCanceled(MenuEvent e) {
461+
System.out.println("JalviewJSTest menu canceled");
462+
}
463+
464+
});
465+
429466
m1.setMnemonic('l');
430467
m1.setFont(font);
431468
m1.addMenuListener(this);
@@ -475,7 +512,8 @@ public void actionPerformed(ActionEvent e) {
475512

476513
JPanel theTab = new JPanel();
477514

478-
firstColumn.add(new JButton("<html>remove <i>testbtn</i></html>") {
515+
516+
JButton bh = new JButton("<html>remove <i>testbtn</i></html>") {
479517
{
480518
this.addActionListener(new ActionListener() {
481519

@@ -487,7 +525,9 @@ public void actionPerformed(ActionEvent e) {
487525

488526
});
489527
}
490-
});
528+
};
529+
bh.setBorder(new LineBorder(Color.red, 14));
530+
firstColumn.add(bh);
491531
firstColumn.add(new JButton("add 'testbtn'") {
492532
{
493533
this.addActionListener(new ActionListener() {

sources/net.sf.j2s.java.core/src/test/Test_Event.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ private static void logClass(String name) {
6161
logger.addHandler(consoleHandler);
6262
}
6363

64-
private static boolean allowLogging = false;
65-
private static boolean allowEventInfo = false;
64+
private static boolean allowLogging = true;
65+
private static boolean allowEventInfo = true;
6666

6767
private void setLogging() {
6868
if ((/** @j2sNative false && */

0 commit comments

Comments
 (0)