/[classpath]/classpath/javax/swing/text/JTextComponent.java
ViewVC logotype

Diff of /classpath/javax/swing/text/JTextComponent.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by mark, Sat Sep 4 17:14:01 2004 UTC revision 1.15 by mkoch, Sun Sep 26 18:30:11 2004 UTC
# Line 800  public abstract class JTextComponent ext Line 800  public abstract class JTextComponent ext
800    private Color selectionColor;    private Color selectionColor;
801    private boolean editable;    private boolean editable;
802    private Insets margin;    private Insets margin;
803      private boolean dragEnabled;
804    
805    /**    /**
806     * Creates a new <code>JTextComponent</code> instance.     * Creates a new <code>JTextComponent</code> instance.
# Line 921  public abstract class JTextComponent ext Line 922  public abstract class JTextComponent ext
922    }    }
923    
924    /**    /**
925       * Retrieves the currently selected text in this text document.
926       *
927       * @return the selected text
928       *
929       * @exception NullPointerException if the underlaying document is null
930       */
931      public String getSelectedText()
932      {
933        try
934          {
935           return doc.getText(getSelectionStart(), getSelectionEnd());
936          }
937        catch (BadLocationException e)
938          {
939           // This should never happen.
940           return null;
941          }
942      }
943    
944      /**
945     * Returns a string that specifies the name of the Look and Feel class     * Returns a string that specifies the name of the Look and Feel class
946     * that renders this component.     * that renders this component.
947     *     *
# Line 1225  public abstract class JTextComponent ext Line 1246  public abstract class JTextComponent ext
1246    
1247      try      try
1248        {        {
1249           int start = getSelectionStart();
1250           int end = getSelectionEnd();
1251          
1252          // Remove selected text.          // Remove selected text.
1253          if (dot != mark)          if (dot != mark)
1254            doc.remove(Math.min(dot, mark), Math.max(dot, mark));           doc.remove(start, end - start);
1255    
1256          // Insert new text.          // Insert new text.
1257          doc.insertString(Math.min(dot, mark), content, null);         doc.insertString(start, content, null);
1258    
1259           // Set dot to new position.
1260           setCaretPosition(start + content.length());
1261        }        }
1262      catch (BadLocationException e)      catch (BadLocationException e)
1263        {        {
# Line 1333  public abstract class JTextComponent ext Line 1360  public abstract class JTextComponent ext
1360    {    {
1361      return getUI().modelToView(this, position);      return getUI().modelToView(this, position);
1362    }    }
1363    
1364      public boolean getDragEnabled()
1365      {
1366        return dragEnabled;
1367      }
1368    
1369      public void setDragEnabled(boolean enabled)
1370      {
1371        dragEnabled = enabled;
1372      }
1373  }  }

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26