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
AWT/Swing TextArea default size
  • Loading branch information
hansonr authored and hansonr committed Mar 20, 2019
commit 42a8b8155eb33574fcfeee476ce18a40ae8353b2
3 changes: 0 additions & 3 deletions sources/net.sf.j2s.java.core/src/javax/swing/JTextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import javax.swing.text.Element;
import javax.swing.text.JTextComponent;
import javax.swing.text.PlainDocument;

import swingjs.api.JSMinimalAbstractDocument;

/**
Expand Down Expand Up @@ -240,8 +239,6 @@ public String getUIClassID() {
* @return the default document model
*/
protected Document createDefaultModel() {
// SwingJS
// return JSToolkit.getPlainDocument(this);
return new PlainDocument();
}

Expand Down
38 changes: 35 additions & 3 deletions sources/net.sf.j2s.java.core/src/swingjs/plaf/JSTextAreaUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
import java.beans.PropertyChangeEvent;

import javax.swing.JTextArea;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.JTextComponent;
import javax.swing.text.PlainView;
import javax.swing.text.View;
import javax.swing.text.WrappedPlainView;

import swingjs.JSToolkit;
import swingjs.api.js.DOMNode;
Expand Down Expand Up @@ -45,12 +51,20 @@ public DOMNode updateDOMNode() {
@Override
public void propertyChange(PropertyChangeEvent e) {
String prop = e.getPropertyName();
if (prop == "ancestor") {
// Object newValue = e.getNewValue();
// Object oldValue = e.getOldValue();
switch(prop) {
case "ancestor":
setJ2sMouseHandler();
}
break;
}
super.propertyChange(e);
}


protected void updateRootView() {
useRootView = true;
rootView.setView(create(editor.getDocument().getDefaultRootElement()));// does not take into account nested documents like HTML (I guess)
}
/**
* Get the real height and width of the text in a JavaScript textarea
* Used by JSScrollPaneUI
Expand Down Expand Up @@ -109,4 +123,22 @@ protected DOMNode setHTMLElement() {
"position", "absolute");
}

/**
* Creates the view for an element. Returns a WrappedPlainView or PlainView.
*
* @param elem the element
* @return the view
*/
@Override
public View create(Element elem) {
JTextArea area = (JTextArea) c;
View v;
if (area.getLineWrap()) {
v = new WrappedPlainView(elem, area.getWrapStyleWord());
} else {
v = new PlainView(elem);
}
return v;
}

}
Loading