本文整理匯總了Java中javax.swing.event.DocumentEvent.getDocument方法的典型用法代碼示例。如果您正苦於以下問題:Java DocumentEvent.getDocument方法的具體用法?Java DocumentEvent.getDocument怎麽用?Java DocumentEvent.getDocument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.event.DocumentEvent
的用法示例。
在下文中一共展示了DocumentEvent.getDocument方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateTexts
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
/** Handles changes in the Project name and project directory
*/
private void updateTexts(DocumentEvent e) {
Document doc = e.getDocument();
if (doc.equals(projectNameTextField.getDocument()) || doc.equals(projectLocationTextField.getDocument())) {
// Change in the project name
String projectName = projectNameTextField.getText();
String projectFolder = projectLocationTextField.getText();
String projFolderPath = FileUtil.normalizeFile(new File(projectFolder)).getAbsolutePath();
if (projFolderPath.endsWith(File.separator)) {
createdFolderTextField.setText(projFolderPath + projectName);
} else {
createdFolderTextField.setText(projFolderPath + File.separator + projectName);
}
}
panel.fireChangeEvent(); // Notify that the panel changed
if (this.projectNameTextField.getDocument().equals(e.getDocument())) {
firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
}
if (this.projectLocationTextField.getDocument().equals(e.getDocument())) {
firePropertyChange(PROP_PROJECT_LOCATION, null, this.projectLocationTextField.getText());
}
}
示例2: updateTexts
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
/** Handles changes in the Project name and project directory
*/
private void updateTexts( DocumentEvent e ) {
Document doc = e.getDocument();
if ( doc == projectNameTextField.getDocument() || doc == projectLocationTextField.getDocument() ) {
// Change in the project name
String projectName = projectNameTextField.getText();
String projectFolder = projectLocationTextField.getText();
String projFolderPath = FileUtil.normalizeFile(new File(projectFolder)).getAbsolutePath();
if (projFolderPath.endsWith(File.separator)) {
createdFolderTextField.setText(projFolderPath + projectName);
} else {
createdFolderTextField.setText(projFolderPath + File.separator + projectName);
}
}
panel.fireChangeEvent(); // Notify that the panel changed
}
示例3: editAttribute
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
private void editAttribute(DocumentEvent documentEvent) {
Document source = documentEvent.getDocument();
int length = source.getLength();
try {
String value = source.getText(0, length);
if (value == null) {
value = "";
}
String selectedRmlAttributeKey = editor.getSelectedRmlAttributeKey();
RmlTag selectedRmlTag = editor.getSelectedRmlTag();
value = editor.formatValue(selectedRmlTag, selectedRmlAttributeKey, value);
onEditorAttribute(selectedRmlTag, selectedRmlAttributeKey, value);
} catch (BadLocationException e1) {
e1.printStackTrace();
}
}
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:17,代碼來源:TextAreaCellEditorComponentInstantEditDocumentAdapter.java
示例4: updateDefaultDirectory
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
private void updateDefaultDirectory(DocumentEvent e) {
Document doc = e.getDocument();
if (doc.equals(username.getDocument())) {
String usernameText = username.getText();
if (!usernameText.isEmpty()) {
String workdirText = workingDir.getText();
if (workdirText.isEmpty() || (currentDefaultWorkDir != null && workdirText.equals(currentDefaultWorkDir))) {
String updatedDefaultworkDir = "/home/" + usernameText + "/NetBeansProjects/"; //NOI18N
workingDir.setText(updatedDefaultworkDir);
currentDefaultWorkDir = updatedDefaultworkDir;
}
} else {
if (currentDefaultWorkDir != null && workingDir.getText().equals(currentDefaultWorkDir)) {
workingDir.setText(""); //NOI18N
currentDefaultWorkDir = null;
}
}
}
}
示例5: contentChange
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
private void contentChange(DocumentEvent e) {
changed = true;
Document doc = e.getDocument();
CodeCategory category = getCategoryForDocument(doc);
int eBlockIndex = getEditBlockIndex(category, e.getOffset());
if (eBlockIndex < 0) {
return;
}
List<EditableLine> lines = getEditInfos(category)[eBlockIndex].lines;
int[] blockBounds = getEditBlockBounds(category, eBlockIndex);
boolean repaint = false;
Integer lastLineCount = lastDocLineCounts.get(doc);
int lineCount = getLineCount(doc);
if (lastLineCount == null || lastLineCount.intValue() != lineCount) {
lastDocLineCounts.put(doc, Integer.valueOf(lineCount));
updateLines(doc, blockBounds[0], blockBounds[1], lines,
codeData.getEditableBlock(category, eBlockIndex));
repaint = true;
// make sure our listener is invoked after position listeners update
doc.removeDocumentListener(this);
doc.addDocumentListener(this);
}
repaint |= updateGutterComponents(lines, doc, blockBounds[0], blockBounds[1]);
if (repaint) {
JPanel gutter = getGutter(doc);
gutter.revalidate();
gutter.repaint();
}
// ((BaseDocument)doc).resetUndoMerge();
}
示例6: processInsert
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
private void processInsert(DocumentEvent e) throws BadLocationException {
final Document document = e.getDocument();
Element root = document.getDefaultRootElement();
int start = root.getElementIndex(e.getOffset());
int end = root.getElementIndex(e.getOffset() + e.getLength() - 1);
Element startElement = root.getElement(start);
Element endElement = root.getElement(end);
if (start == end) {
String newValue = getText(document, startElement);
replaceLine(document, start, newValue);
if (e.getOffset() + e.getLength() == startElement.getEndOffset()) {
Element startNext = root.getElement(start + 1);
insertLines(document, start + 1, Collections.singletonList(
getText(document, startNext)
));
}
} else {
removeLines(document, start, start);
List<String> lines = new ArrayList<>();
for (int line = start; line <= end; ++line) {
lines.add(getText(document, root.getElement(line)));
}
if (e.getOffset() + e.getLength() == endElement.getEndOffset() && end + 1 < root.getElementCount()) {
Element endNext = root.getElement(end + 1);
lines.add(getText(document, endNext));
}
insertLines(document, start, lines);
}
}
示例7: removeLines
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
private void removeLines(DocumentEvent e) {
// The root Element of the Document will tell us the total number
// of line in the Document.
Document document = e.getDocument();
Element root = document.getDefaultRootElement();
while (root.getElementCount() > maximumLines) {
if (isRemoveFromStart) {
removeFromStart(document, root);
} else {
removeFromEnd(document, root);
}
}
}
示例8: insertUpdate
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
@Override
public void insertUpdate (DocumentEvent e) {
if (e.getDocument() == panel.tagMessageField.getDocument()) {
validate();
} else {
validateName();
}
}
示例9: removeUpdate
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
@Override
public void removeUpdate (DocumentEvent e) {
if (e.getDocument() == panel.tagMessageField.getDocument()) {
validate();
} else {
validateName();
}
}
示例10: handleTextFieldUpdate
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
private void handleTextFieldUpdate(DocumentEvent de) {
if (de.getDocument()==getTfChartTitle().getDocument()) {
setChartTitle(getTfChartTitle().getText());
}else if(de.getDocument() == getTfXAxisLabel().getDocument()){
setXAxisLabel(getTfXAxisLabel().getText());
}else if(de.getDocument() == getTfYAxisLabel().getDocument()){
setYAxisLabel(getTfYAxisLabel().getText());
}
}
示例11: changeTab
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
/**
* ȭ���� ������ �ٲ� Ouput�� ���̰� ��ȯ�Ѵ�.
*/
private void changeTab( DocumentEvent e ) {
if ( e.getDocument() == outputStd.getOutput().getDocument() ) {
if ( tabPane.getSelectedComponent() != outputStd )
tabPane.setSelectedComponent(outputStd);
} else if ( e.getDocument() == outputErr.getOutput().getDocument() ) {
if ( tabPane.getSelectedComponent() != outputErr )
tabPane.setSelectedComponent(outputErr);
}
}
示例12: update
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
void update(DocumentEvent e) {
try {
Document doc = e.getDocument();
int len = doc.getLength();
String text = doc.getText(0, len);
update(text);
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例13: changedUpdate
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
public final void changedUpdate(DocumentEvent e) {
//Ensure it is consumed
e.getLength();
documentChanged();
if (e.getOffset() + e.getLength() >= getCaretPos() && (locked || !(e instanceof OutputDocument.DO))) {
//#119985 only move caret when not in editable section
OutputDocument doc = (OutputDocument)e.getDocument();
if (! (e instanceof OutputDocument.DO) && getCaretPos() >= doc.getOutputLength()) {
return ;
}
getCaret().setDot(e.getOffset() + e.getLength());
}
}
示例14: documentChanged
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
private void documentChanged (DocumentEvent e) {
if (e.getDocument() == txtFilter.getDocument()) {
filterTimer.restart();
} else {
validateUserInput();
}
}
示例15: markChanged
import javax.swing.event.DocumentEvent; //導入方法依賴的package包/類
private void markChanged( DocumentEvent evt ) {
Document doc = evt.getDocument();
doc.putProperty( MODIFIED, Boolean.TRUE );
File file = (File)doc.getProperty( FILE );
int index = tabPane.indexOfComponent( comp );
tabPane.setTitleAt( index, file.getName() + '*' );
doc.removeDocumentListener( this );
}