894 |
private Insets margin; |
private Insets margin; |
895 |
private boolean dragEnabled; |
private boolean dragEnabled; |
896 |
|
|
897 |
|
/** Issues repaint request on document changes. */ |
898 |
|
private DocumentListener repaintListener; |
899 |
|
|
900 |
/** |
/** |
901 |
* Creates a new <code>JTextComponent</code> instance. |
* Creates a new <code>JTextComponent</code> instance. |
902 |
*/ |
*/ |
903 |
public JTextComponent() |
public JTextComponent() |
904 |
{ |
{ |
905 |
|
repaintListener = new DocumentListener() |
906 |
|
{ |
907 |
|
public void changedUpdate(DocumentEvent ev) |
908 |
|
{ |
909 |
|
repaint(); |
910 |
|
} |
911 |
|
public void insertUpdate(DocumentEvent ev) |
912 |
|
{ |
913 |
|
repaint(); |
914 |
|
} |
915 |
|
public void removeUpdate(DocumentEvent ev) |
916 |
|
{ |
917 |
|
repaint(); |
918 |
|
} |
919 |
|
}; |
920 |
|
|
921 |
Keymap defkeymap = getKeymap(DEFAULT_KEYMAP); |
Keymap defkeymap = getKeymap(DEFAULT_KEYMAP); |
922 |
boolean creatingKeymap = false; |
boolean creatingKeymap = false; |
923 |
if (defkeymap == null) |
if (defkeymap == null) |
951 |
{ |
{ |
952 |
Document oldDoc = doc; |
Document oldDoc = doc; |
953 |
doc = newDoc; |
doc = newDoc; |
954 |
|
|
955 |
|
// setup document listener |
956 |
|
if (oldDoc != null) |
957 |
|
oldDoc.removeDocumentListener(repaintListener); |
958 |
|
if (newDoc != null) |
959 |
|
newDoc.addDocumentListener(repaintListener); |
960 |
|
|
961 |
firePropertyChange("document", oldDoc, newDoc); |
firePropertyChange("document", oldDoc, newDoc); |
962 |
revalidate(); |
revalidate(); |
963 |
repaint(); |
repaint(); |