Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20190319211418
20190323074004
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20190319211418
20190323074004
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
1 change: 1 addition & 0 deletions sources/net.sf.j2s.java.core/src/java/awt/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,7 @@ protected void addImplCont(Component comp, Object constraints, int index) {

if (/** @j2sNative comp.getWrap$ && !this.isWrapper$ || */ false) {
comp = ((A2SWrappedComponent) comp).getWrap$();
comp.background = comp.foreground = null; // this parent should not set the background color
}
// SwingJS used for all add methods

Expand Down
9 changes: 9 additions & 0 deletions sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ public String getUIClassID() {
return (uiClassID == null ? uiClassID = "ComponentUI" : uiClassID);
}

/**
* for JSToolkit use only
* @param id
*/
public void setUIClassID(String id) {
uiClassID = id;
}


/**
* required by Container, but not actually ever called,
* because all Containers are JComponents in SwingJS
Expand Down
6 changes: 6 additions & 0 deletions sources/net.sf.j2s.java.core/src/java/awt/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,12 @@ final void toFront_NoClientCode() {
if (isModalBlocked()) {
modalBlocker.toFront_NoClientCode();
}

for (int i = 0; i < ownedWindowList.size(); i++) {
if (ownedWindowList.get(i).isVisible())
ownedWindowList.get(i).toFront();
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
public class DefaultComboBoxModel<E> extends AbstractListModel<E> implements MutableComboBoxModel<E> {
Vector<E> objects;
Object selectedObject;
private boolean _isQuiet;

/**
* Constructs an empty DefaultComboBoxModel object.
Expand Down Expand Up @@ -92,7 +93,8 @@ public void setSelectedItem(Object anObject) {
if ((selectedObject != null && !selectedObject.equals( anObject )) ||
selectedObject == null && anObject != null) {
selectedObject = anObject;
fireContentsChanged(this, -1, -1);
if (!_isQuiet)
fireContentsChanged(this, -1, -1);
}
}

Expand Down Expand Up @@ -134,10 +136,11 @@ public void addElement(E anObject) {
objects.addElement(anObject);
fireIntervalAdded(this,objects.size()-1, objects.size()-1);
if ( objects.size() == 1 && selectedObject == null && anObject != null ) {
setSelectedItem( anObject );
_setSelectedItemQuiet(anObject);
}
}


// implements javax.swing.MutableComboBoxModel
@Override
public void insertElementAt(E anObject,int index) {
Expand All @@ -148,14 +151,9 @@ public void insertElementAt(E anObject,int index) {
// implements javax.swing.MutableComboBoxModel
@Override
public void removeElementAt(int index) {
if ( getElementAt( index ) == selectedObject ) {
if ( index == 0 ) {
setSelectedItem( getSize() == 1 ? null : getElementAt( index + 1 ) );
}
else {
setSelectedItem( getElementAt( index - 1 ) );
}
}
if ( getElementAt( index ) == selectedObject )
_setSelectedItemQuiet(index > 0 ? getElementAt( index - 1 )
: getSize() == 1 ? null : getElementAt( index + 1 ) );

objects.removeElementAt(index);

Expand Down Expand Up @@ -185,4 +183,10 @@ public void removeAllElements() {
selectedObject = null;
}
}

void _setSelectedItemQuiet(Object o) {
_isQuiet = (/**@j2sNative !!this.isAWT$ || */false);
setSelectedItem( o );
_isQuiet = false;
}
}
19 changes: 16 additions & 3 deletions sources/net.sf.j2s.java.core/src/javax/swing/JComboBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ public void setModel(ComboBoxModel aModel) {
}
dataModel = aModel;
dataModel.addListDataListener(this);
/** @j2sNative
* aModel.isAWT$ = this.isAWT$
*/

// set the current selected item.
selectedItemReminder = dataModel.getSelectedItem();
Expand Down Expand Up @@ -544,7 +547,8 @@ public ComboBoxEditor getEditor() {
* preferred: true
* description: Sets the selected item in the JComboBox.
*/
public void setSelectedItem(Object anObject) {
@SuppressWarnings("unused")
public void setSelectedItem(Object anObject) {
Object oldSelection = selectedItemReminder;
Object objectToSelect = anObject;
if (oldSelection == null || !oldSelection.equals(anObject)) {
Expand All @@ -569,7 +573,11 @@ public void setSelectedItem(Object anObject) {
// Must toggle the state of this flag since this method
// call may result in ListDataEvents being fired.
selectingItem = true;
dataModel.setSelectedItem(objectToSelect);
if (_trigger || /** @j2sNative !this.isAWT$ &&*/true) {
dataModel.setSelectedItem(objectToSelect);
} else {
((DefaultComboBoxModel)dataModel)._setSelectedItemQuiet(objectToSelect);
}
selectingItem = false;

if (selectedItemReminder != dataModel.getSelectedItem()) {
Expand Down Expand Up @@ -1025,6 +1033,7 @@ public String getActionCommand() {

private Action action;
private PropertyChangeListener actionPropertyChangeListener;
protected boolean _trigger;

/**
* Sets the <code>Action</code> for the <code>ActionEvent</code> source.
Expand Down Expand Up @@ -1268,7 +1277,7 @@ protected void fireActionEvent() {
* or override.
*/
protected void selectedItemChanged() {
if (selectedItemReminder != null ) {
if (selectedItemReminder != null && /** @j2sNative !this.isAWT$ && */true) {
fireItemStateChanged(new ItemEvent(this,ItemEvent.ITEM_STATE_CHANGED,
selectedItemReminder,
ItemEvent.DESELECTED));
Expand Down Expand Up @@ -1587,6 +1596,10 @@ protected String paramString() {
",selectedItemReminder=" + selectedItemReminderString;
}

public void _setTrigger(boolean b) {
_trigger = b;
}


///////////////////
// Accessibility support
Expand Down
3 changes: 0 additions & 3 deletions sources/net.sf.j2s.java.core/src/javax/swing/JComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import static javax.swing.ClientPropertyKey.JComponent_ANCESTOR_NOTIFIER;
import static javax.swing.ClientPropertyKey.JComponent_INPUT_VERIFIER;

import java.applet.JSApplet;
import java.awt.AWTEvent;
import java.awt.AWTKeyStroke;
import java.awt.Color;
Expand Down Expand Up @@ -70,9 +69,7 @@

import javajs.util.Lst;
import sun.font.FontDesignMetrics;
import swingjs.JSFocusPeer;
import swingjs.JSGraphics2D;
import swingjs.JSToolkit;
import swingjs.JSUtil;
import swingjs.plaf.JSComponentUI;

Expand Down
7 changes: 2 additions & 5 deletions sources/net.sf.j2s.java.core/src/javax/swing/JDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,18 @@
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.JSDialog;
import java.awt.JSFrame;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;
import java.awt.JSDialog;
import java.awt.JSFrame;
import java.awt.LayoutManager;
import java.awt.Window;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.plaf.UIResource;

import swingjs.JSUtil;
import swingjs.plaf.JSComponentUI;

// BH: Added rootPane.addNotify(); // builds a peer for the root pane

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
}
setUIProperty("opaque",true);
updateUI();
System.out.println("jscrollpanecolor " + getBackground());
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions sources/net.sf.j2s.java.core/src/javax/swing/JTextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public void setRows(int rows) {
protected int getRowHeight() {
if (rowHeight == 0) {
FontMetrics metrics = getFontMetrics(getFont());
rowHeight = metrics.getHeight() + 2; // SwingJS adds +2 here
rowHeight = metrics.getHeight();// + 2; // SwingJS adds +2 here
}
return rowHeight;
}
Expand Down Expand Up @@ -640,7 +640,7 @@ public Dimension getSizeJS(Dimension d, int n, int rows, int columns) {
}
if (rows != 0) {
Insets insets = getInsets();
d.height = Math.max(h, (rows + 1) * getRowHeight() + insets.top + insets.bottom);
d.height = Math.max(h, rows * getRowHeight() + insets.top + insets.bottom);
}
return d;
}
Expand Down
5 changes: 4 additions & 1 deletion sources/net.sf.j2s.java.core/src/javax/swing/JTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,10 @@ protected Dimension getPrefSizeJTF() {
}

protected Dimension getPrefSizeJTF(int columns) {
Dimension size = getPrefSizeJComp();
Dimension size = (!isPreferredSizeSet() && ui != null ? ui
.getPreferredSize(this) : null);
if (size == null)
size = super.preferredSize();
if (columns != 0) {
size.width = getJ2SWidth(columns);
}
Expand Down
7 changes: 4 additions & 3 deletions sources/net.sf.j2s.java.core/src/javax/swing/JViewport.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

package javax.swing;

import java.applet.JSApplet;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
Expand All @@ -39,14 +38,15 @@
import java.awt.LayoutManager;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;

import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;

import swingjs.JSGraphics2D;


Expand Down Expand Up @@ -118,6 +118,7 @@ public class JViewport extends JComponent implements JSComponent.A2SComponentWra
{

// BH for SwingJS
@Override
public void isWrapper$() {};


Expand Down Expand Up @@ -574,7 +575,7 @@ public final void setBorder(Border border) {
*/
@Override
public final Insets getInsets() {
return Container.NULL_INSETS;
return new Insets(1, 1, 1, 1);//Container.NULL_INSETS;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public static void exit() {
// ////// java.awt.Toolkit /////////

public static void getScreenSize(Dimension d) {
@SuppressWarnings("unused")
JQuery jq = JSUtil.jQuery;
d.width = /** @j2sNative jq.$(window).width() || */0;
d.height = /** @j2sNative jq.$(window).height() || */0;
Expand Down Expand Up @@ -285,8 +286,9 @@ public static UIDefaults getLookAndFeelDefaults() {
}

public static JSComponentUI getComponentUI(JComponent target) {
String id = ((JSComponent) target).getUIClassID();
JSComponentUI ui = (JSComponentUI) Interface.getInstance("swingjs.plaf.JS"
+ ((JSComponent) target).getUIClassID(), true);
+ id, true);
if (ui != null)
ui.set(target);
return ui;
Expand Down Expand Up @@ -536,7 +538,7 @@ public WindowPeer createWindow(Window target) {

public static JSComponentUI getUI(Component c, boolean isQuiet) {
JSComponentUI ui = /** @2sNative !!c.getUI$ &&*/(JSComponentUI)((JComponent) c).getUI();
if (ui == null && ((JComponent) c).getUIClassID() != "ComponentUI") {
if (ui == null) {
((JComponent) c).updateUI();
ui = (JSComponentUI) ((JComponent) c).getUI();
}
Expand Down
3 changes: 3 additions & 0 deletions sources/net.sf.j2s.java.core/src/swingjs/a2s/Choice.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.awt.Color;
import java.awt.event.ItemEvent;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;

public class Choice extends JComboBox {
Expand Down Expand Up @@ -69,6 +70,8 @@ protected void fireActionEvent() {

@Override
protected void fireItemStateChanged(ItemEvent event) {
if (!_trigger)
return;
A2SEvent.addListener(this);
super.fireItemStateChanged(event);
}
Expand Down
Loading