Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adds move for fdrag, giving splitpane cursor
  • Loading branch information
hansonr authored and hansonr committed Nov 17, 2018
commit 53772b2e7de1a785d3736dc9d47ff9ae1b3a815b
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
21 changes: 17 additions & 4 deletions sources/net.sf.j2s.java.core/src/swingjs/plaf/JSSplitPaneUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

//import java.awt.Canvas;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

import javajs.api.JSFunction;
import java.awt.Color;
Expand Down Expand Up @@ -190,6 +191,8 @@ public Dimension getPreferredSize() {

private int pressedLocation;

private boolean isHorizontal;

// /**
// * Creates a new BasicSplitPaneUI instance
// */
Expand Down Expand Up @@ -224,18 +227,20 @@ public void installUI(JComponent jc) {
}

protected void fHandleDrag(Object xyev, int type) {
boolean isHorizontal = (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT);
if (cursor == null)
cursor = Toolkit.getDefaultToolkit().createCustomCursor(null, null, isHorizontal ? "col-resize" : "row-resize");
isHorizontal = (splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT);
getCursor();
switch (type) {
case MouseEvent.MOUSE_MOVED:
divider.setCursor(cursor);
break;
case MouseEvent.MOUSE_PRESSED:
this.xyev = xyev;
this.pressedLocation = splitPane.getDividerLocation();
divider.setCursor(cursor);
DOMNode.setCursor(getCursorName(cursor), null);
break;
case MouseEvent.MOUSE_DRAGGED:
int d = this.pressedLocation + /** @j2sNative (isHorizontal ? xyev.dx : xyev.dy) || */ 0;
int d = this.pressedLocation + /** @j2sNative (this.isHorizontal ? xyev.dx : xyev.dy) || */ 0;
int max = getMaximumDividerLocation(splitPane);
int min = getMinimumDividerLocation(splitPane);
d = Math.max(min, Math.min(max, d));
Expand All @@ -248,10 +253,18 @@ protected void fHandleDrag(Object xyev, int type) {
}
}

private Cursor getCursor() {
if (cursor == null) {
cursor = Toolkit.getDefaultToolkit().createCustomCursor(null, null, isHorizontal ? "col-resize" : "row-resize");
}
return cursor;
}

private void setupDivider() {
divider = new SplitPaneDivider(this);
JSFunction fDrag = null;
JSSplitPaneUI me = this;

/**
* @j2sNative
*
Expand Down
9 changes: 9 additions & 0 deletions sources/net.sf.j2s.java.core/src/test/Test_Applet_Split.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.beans.PropertyChangeListener;

import javax.swing.JApplet;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;

Expand Down Expand Up @@ -41,12 +43,19 @@ public void init() {
p.setSize(500, 400);
p.setDividerLocation(0.24);
p.setDividerSize(3);
JComboBox cb = new JComboBox();

cb.addItem("test1");
cb.addItem("test2");
cb.addItem("test3");
right.add(cb);
p.addPropertyChangeListener(new PropertyChangeListener() {

@Override
public void propertyChange(PropertyChangeEvent evt) {
switch (evt.getPropertyName()) {
case "dividerLocation":
cb.setEnabled(false);
if (p.getDividerLocation() > p.getWidth() * 0.75)
p.setDividerLocation(0.75);
break;
Expand Down
7 changes: 4 additions & 3 deletions sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,8 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
}, drag = function(ev) {
// we will move the frame's parent node and take the frame along
// with it
if (tag.isDragging && J2S._dmouseOwner == tag) {
var mode = (tag.isDragging ? 506 : 503);
if (!J2S._dmouseOwner || tag.isDragging && J2S._dmouseOwner == tag) {
x = pageX0 + (dx = ev.pageX - pageX);
y = pageY0 + (dy = ev.pageY - pageY);
if (fDrag) {
Expand All @@ -2779,9 +2780,9 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
dx : dx,
dy : dy,
ev : ev
}, 506);
}, mode);
} else if (target) {
var frame = target(506, x, y);
var frame = target(mode, x, y);
if (frame)
$(frame).css({ top : y + 'px', left : x + 'px'})
}
Expand Down
7 changes: 4 additions & 3 deletions sources/net.sf.j2s.java.core/srcjs/swingjs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13425,7 +13425,8 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
}, drag = function(ev) {
// we will move the frame's parent node and take the frame along
// with it
if (tag.isDragging && J2S._dmouseOwner == tag) {
var mode = (tag.isDragging ? 506 : 503);
if (!J2S._dmouseOwner || tag.isDragging && J2S._dmouseOwner == tag) {
x = pageX0 + (dx = ev.pageX - pageX);
y = pageY0 + (dy = ev.pageY - pageY);
if (fDrag) {
Expand All @@ -13435,9 +13436,9 @@ console.log("J2S._getRawDataFromServer " + J2S._serverUrl + " for " + query);
dx : dx,
dy : dy,
ev : ev
}, 506);
}, mode);
} else if (target) {
var frame = target(506, x, y);
var frame = target(mode, x, y);
if (frame)
$(frame).css({ top : y + 'px', left : x + 'px'})
}
Expand Down