Skip to content

Commit 53772b2

Browse files
hansonrhansonr
authored andcommitted
adds move for fdrag, giving splitpane cursor
1 parent 4824978 commit 53772b2

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed
239 Bytes
Binary file not shown.

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
//import java.awt.Canvas;
3131
import java.awt.event.MouseEvent;
32+
import java.awt.event.MouseMotionListener;
3233

3334
import javajs.api.JSFunction;
3435
import java.awt.Color;
@@ -190,6 +191,8 @@ public Dimension getPreferredSize() {
190191

191192
private int pressedLocation;
192193

194+
private boolean isHorizontal;
195+
193196
// /**
194197
// * Creates a new BasicSplitPaneUI instance
195198
// */
@@ -224,18 +227,20 @@ public void installUI(JComponent jc) {
224227
}
225228

226229
protected void fHandleDrag(Object xyev, int type) {
227-
boolean isHorizontal = (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT);
228-
if (cursor == null)
229-
cursor = Toolkit.getDefaultToolkit().createCustomCursor(null, null, isHorizontal ? "col-resize" : "row-resize");
230+
isHorizontal = (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT);
231+
getCursor();
230232
switch (type) {
233+
case MouseEvent.MOUSE_MOVED:
234+
divider.setCursor(cursor);
235+
break;
231236
case MouseEvent.MOUSE_PRESSED:
232237
this.xyev = xyev;
233238
this.pressedLocation = splitPane.getDividerLocation();
234239
divider.setCursor(cursor);
235240
DOMNode.setCursor(getCursorName(cursor), null);
236241
break;
237242
case MouseEvent.MOUSE_DRAGGED:
238-
int d = this.pressedLocation + /** @j2sNative (isHorizontal ? xyev.dx : xyev.dy) || */ 0;
243+
int d = this.pressedLocation + /** @j2sNative (this.isHorizontal ? xyev.dx : xyev.dy) || */ 0;
239244
int max = getMaximumDividerLocation(splitPane);
240245
int min = getMinimumDividerLocation(splitPane);
241246
d = Math.max(min, Math.min(max, d));
@@ -248,10 +253,18 @@ protected void fHandleDrag(Object xyev, int type) {
248253
}
249254
}
250255

256+
private Cursor getCursor() {
257+
if (cursor == null) {
258+
cursor = Toolkit.getDefaultToolkit().createCustomCursor(null, null, isHorizontal ? "col-resize" : "row-resize");
259+
}
260+
return cursor;
261+
}
262+
251263
private void setupDivider() {
252264
divider = new SplitPaneDivider(this);
253265
JSFunction fDrag = null;
254266
JSSplitPaneUI me = this;
267+
255268
/**
256269
* @j2sNative
257270
*

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.beans.PropertyChangeListener;
77

88
import javax.swing.JApplet;
9+
import javax.swing.JComboBox;
10+
import javax.swing.JLabel;
911
import javax.swing.JPanel;
1012
import javax.swing.JSplitPane;
1113

@@ -41,12 +43,19 @@ public void init() {
4143
p.setSize(500, 400);
4244
p.setDividerLocation(0.24);
4345
p.setDividerSize(3);
46+
JComboBox cb = new JComboBox();
47+
48+
cb.addItem("test1");
49+
cb.addItem("test2");
50+
cb.addItem("test3");
51+
right.add(cb);
4452
p.addPropertyChangeListener(new PropertyChangeListener() {
4553

4654
@Override
4755
public void propertyChange(PropertyChangeEvent evt) {
4856
switch (evt.getPropertyName()) {
4957
case "dividerLocation":
58+
cb.setEnabled(false);
5059
if (p.getDividerLocation() > p.getWidth() * 0.75)
5160
p.setDividerLocation(0.75);
5261
break;

sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,7 +2769,8 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
27692769
}, drag = function(ev) {
27702770
// we will move the frame's parent node and take the frame along
27712771
// with it
2772-
if (tag.isDragging && J2S._dmouseOwner == tag) {
2772+
var mode = (tag.isDragging ? 506 : 503);
2773+
if (!J2S._dmouseOwner || tag.isDragging && J2S._dmouseOwner == tag) {
27732774
x = pageX0 + (dx = ev.pageX - pageX);
27742775
y = pageY0 + (dy = ev.pageY - pageY);
27752776
if (fDrag) {
@@ -2779,9 +2780,9 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
27792780
dx : dx,
27802781
dy : dy,
27812782
ev : ev
2782-
}, 506);
2783+
}, mode);
27832784
} else if (target) {
2784-
var frame = target(506, x, y);
2785+
var frame = target(mode, x, y);
27852786
if (frame)
27862787
$(frame).css({ top : y + 'px', left : x + 'px'})
27872788
}

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13425,7 +13425,8 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
1342513425
}, drag = function(ev) {
1342613426
// we will move the frame's parent node and take the frame along
1342713427
// with it
13428-
if (tag.isDragging && J2S._dmouseOwner == tag) {
13428+
var mode = (tag.isDragging ? 506 : 503);
13429+
if (!J2S._dmouseOwner || tag.isDragging && J2S._dmouseOwner == tag) {
1342913430
x = pageX0 + (dx = ev.pageX - pageX);
1343013431
y = pageY0 + (dy = ev.pageY - pageY);
1343113432
if (fDrag) {
@@ -13435,9 +13436,9 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
1343513436
dx : dx,
1343613437
dy : dy,
1343713438
ev : ev
13438-
}, 506);
13439+
}, mode);
1343913440
} else if (target) {
13440-
var frame = target(506, x, y);
13441+
var frame = target(mode, x, y);
1344113442
if (frame)
1344213443
$(frame).css({ top : y + 'px', left : x + 'px'})
1344313444
}

0 commit comments

Comments
 (0)