当前位置: 首页>>代码示例>>Java>>正文


Java JTextComponent.selectAll方法代码示例

本文整理汇总了Java中javax.swing.text.JTextComponent.selectAll方法的典型用法代码示例。如果您正苦于以下问题:Java JTextComponent.selectAll方法的具体用法?Java JTextComponent.selectAll怎么用?Java JTextComponent.selectAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.JTextComponent的用法示例。


在下文中一共展示了JTextComponent.selectAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: focusGained

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
@Override
public void focusGained(FocusEvent e) {
    if (!e.isTemporary()) {
        JTextComponent textComp = (JTextComponent) e.getSource();
        if (textComp.getText().length() != 0) {
            textComp.selectAll();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:TextFieldFocusListener.java

示例2: actionPerformed

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
	JTextComponent tc = (JTextComponent) getInvoker();

	String sel = tc.getSelectedText();

	if (e.getSource() == cutItem) {
		tc.cut();
	} else if (e.getSource() == copyItem) {
		tc.copy();
	} else if (e.getSource() == pasteItem) {
		tc.paste();
	} else if (e.getSource() == selectAllItem) {
		tc.selectAll();
	} else if (e.getSource() == deleteItem) {
		Document doc = tc.getDocument();
		int start = tc.getSelectionStart();
		int end = tc.getSelectionEnd();

		try {
			Position p0 = doc.createPosition(start);
			Position p1 = doc.createPosition(end);

			if ((p0 != null) && (p1 != null)
					&& (p0.getOffset() != p1.getOffset())) {
				doc.remove(p0.getOffset(), p1.getOffset() - p0.getOffset());
			}
		} catch (BadLocationException be) {
		}
	}
}
 
开发者ID:breakEval13,项目名称:NSS,代码行数:31,代码来源:TextComponentPopupMenu.java

示例3: selectAll

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/**
 * Selects all contents of a text component.
 *
 * @param textComponent
 */
public static void selectAll(JTextComponent textComponent) {
    if (!textComponent.hasFocus()) {
        textComponent.requestFocus();
    }
    textComponent.selectAll();
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:12,代码来源:TextComponentUtil.java

示例4: valueChanged

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public void valueChanged(ListSelectionEvent e) {
    table.editCellAt(table.getSelectedRow(), table.getSelectedColumn());
    Component editor = table.getEditorComponent();
    if (editor != null) {
        editor.requestFocus();
    }
    if (editor instanceof JTextComponent) {
        JTextComponent textComp = (JTextComponent) editor;
        textComp.selectAll();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ExceptionsPanel.java

示例5: valueChanged

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public void valueChanged(ListSelectionEvent e) {
    table.editCellAt(table.getSelectedRow(), table.getSelectedColumn());
    Component editor = table.getEditorComponent();
    if (editor instanceof JComboBox) {
        editor = ((JComboBox) editor).getEditor().getEditorComponent();
    }
    if (editor != null) {
        editor.requestFocus();
    }
    if (editor instanceof JTextComponent) {
        JTextComponent textComp = (JTextComponent) editor;
        textComp.selectAll();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ParametersPanel.java

示例6: startEditing

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public void startEditing(Object cell, EventObject evt)
{
	if (editingCell != null)
	{
		stopEditing(true);
	}

	mxCellState state = graphComponent.getGraph().getView().getState(cell);

	if (state != null)
	{
		editingCell = cell;
		trigger = evt;

		double scale = Math.max(minimumEditorScale, graphComponent
				.getGraph().getView().getScale());
		scrollPane.setBounds(getEditorBounds(state, scale));
		scrollPane.setVisible(true);

		String value = getInitialValue(state, evt);
		JTextComponent currentEditor = null;

		// Configures the style of the in-place editor
		if (graphComponent.getGraph().isHtmlLabel(cell))
		{
			if (isExtractHtmlBody())
			{
				value = mxUtils.getBodyMarkup(value,
						isReplaceHtmlLinefeeds());
			}

			editorPane.setDocument(mxUtils.createHtmlDocumentObject(
					state.getStyle(), scale));
			editorPane.setText(value);

			// Workaround for wordwrapping in editor pane
			// FIXME: Cursor not visible at end of line
			JPanel wrapper = new JPanel(new BorderLayout());
			wrapper.setOpaque(false);
			wrapper.add(editorPane, BorderLayout.CENTER);
			scrollPane.setViewportView(wrapper);

			currentEditor = editorPane;
		}
		else
		{
			textArea.setFont(mxUtils.getFont(state.getStyle(), scale));
			Color fontColor = mxUtils.getColor(state.getStyle(),
					mxConstants.STYLE_FONTCOLOR, Color.black);
			textArea.setForeground(fontColor);
			textArea.setText(value);

			scrollPane.setViewportView(textArea);
			currentEditor = textArea;
		}

		graphComponent.getGraphControl().add(scrollPane, 0);

		if (isHideLabel(state))
		{
			graphComponent.redraw(state);
		}

		currentEditor.revalidate();
		currentEditor.requestFocusInWindow();
		currentEditor.selectAll();

		configureActionMaps();
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:71,代码来源:mxCellEditor.java

示例7: startEditing

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
public void startEditing(Object cell, EventObject evt) {
  if (editingCell != null) {
    stopEditing(true);
  }

  mxCellState state = graphComponent.getGraph().getView().getState(cell);

  if (state != null) {
    editingCell = cell;
    trigger = evt;

    double scale = Math.max(minimumEditorScale, graphComponent.getGraph().getView().getScale());
    scrollPane.setBounds(getEditorBounds(state, scale));
    scrollPane.setVisible(true);

    String value = getInitialValue(state, evt);
    JTextComponent currentEditor = null;

    // Configures the style of the in-place editor
    if (graphComponent.getGraph().isHtmlLabel(cell)) {
      if (isExtractHtmlBody()) {
        value = mxUtils.getBodyMarkup(value, isReplaceHtmlLinefeeds());
      }

      editorPane.setDocument(mxUtils.createHtmlDocumentObject(state.getStyle(), scale));
      editorPane.setText(value);

      // Workaround for wordwrapping in editor pane
      // FIXME: Cursor not visible at end of line
      JPanel wrapper = new JPanel(new BorderLayout());
      wrapper.setOpaque(false);
      wrapper.add(editorPane, BorderLayout.CENTER);
      scrollPane.setViewportView(wrapper);

      currentEditor = editorPane;
    } else {
      textArea.setFont(mxUtils.getFont(state.getStyle(), scale));
      Color fontColor =
          mxUtils.getColor(state.getStyle(), mxConstants.STYLE_FONTCOLOR, Color.black);
      textArea.setForeground(fontColor);
      textArea.setText(value);

      scrollPane.setViewportView(textArea);
      currentEditor = textArea;
    }

    graphComponent.getGraphControl().add(scrollPane, 0);

    if (isHideLabel(state)) {
      graphComponent.redraw(state);
    }

    currentEditor.revalidate();
    currentEditor.requestFocusInWindow();
    currentEditor.selectAll();

    configureActionMaps();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:60,代码来源:mxCellEditor.java


注:本文中的javax.swing.text.JTextComponent.selectAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。