本文整理汇总了Java中javax.swing.event.CaretListener类的典型用法代码示例。如果您正苦于以下问题:Java CaretListener类的具体用法?Java CaretListener怎么用?Java CaretListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CaretListener类属于javax.swing.event包,在下文中一共展示了CaretListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WikiEditPanel
import javax.swing.event.CaretListener; //导入依赖的package包/类
/**
* Creates new form WikiEditPanel
*/
public WikiEditPanel(String wikiLanguage, boolean editing, boolean switchable) {
this.wikiLanguage = wikiLanguage;
this.switchable = switchable;
this.wikiFormatText = "";
this.htmlFormatText = "";
initComponents();
pnlButtons.setVisible(switchable);
textCode.getDocument().addDocumentListener(new RevalidatingListener());
textPreview.getDocument().addDocumentListener(new RevalidatingListener());
textCode.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent e) {
makeCaretVisible(textCode);
}
});
textCode.getDocument().addDocumentListener(new EnablingListener());
// A11Y - Issues 163597 and 163598
UIUtils.fixFocusTraversalKeys(textCode);
UIUtils.issue163946Hack(scrollCode);
Spellchecker.register(textCode);
textPreview.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
setEditing(editing);
}
示例2: updateActiveEditor
import javax.swing.event.CaretListener; //导入依赖的package包/类
private void updateActiveEditor() {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(this);
return;
}
JTextComponent c = findActivePane();
if (c == null) {
editorReleased();
return;
}
if (activeEditor != null && activeEditor.get() == c) {
return;
}
editorReleased();
activeEditor = new WeakReference<>(c);
wCaretL = WeakListeners.create(CaretListener.class, this, c);
c.addCaretListener(this);
selectCurrentNode();
}
示例3: TableViewLayoutTest
import javax.swing.event.CaretListener; //导入依赖的package包/类
public TableViewLayoutTest() {
super("Code example for a TableView bug");
setUndecorated(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
edit.setEditorKit(new CodeBugEditorKit());
initCodeBug();
this.getContentPane().add(new JScrollPane(edit));
this.pack();
this.setLocationRelativeTo(null);
edit.addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent e) {
JTextComponent textComp = (JTextComponent) e.getSource();
try {
Rectangle rect = textComp.getUI().modelToView(textComp, e.getDot());
yCaret = rect.getY();
xCaret = rect.getX();
} catch (BadLocationException ex) {
throw new RuntimeException("Failed to get pixel position of caret", ex);
}
}
});
}
示例4: RowColumnLabel
import javax.swing.event.CaretListener; //导入依赖的package包/类
RowColumnLabel(ISQLEntryPanel sqlEntryPanel)
{
super(" ", JLabel.CENTER);
_sqlEntryPanel = sqlEntryPanel;
sqlEntryPanel.addCaretListener(new CaretListener()
{
public void caretUpdate(CaretEvent e)
{
onCaretUpdate(e);
}
});
writePosition(0,0, 0);
setToolTipText(s_stringMgr.getString("RowColumnLabel.tooltip"));
}
示例5: setVFormat
import javax.swing.event.CaretListener; //导入依赖的package包/类
/**
* Feature Request [1707462]
* Set VFormat
* @param strMask mask
* @author fer_luck
*/
public void setVFormat (String strMask)
{
m_VFormat = strMask;
//Get the actual caret from the field, if there's no
//caret then just catch the exception and continue
//creating the new caret.
try{
CaretListener [] cl = this.getCaretListeners();
this.removeCaretListener(cl[0]);
} catch(ClassCastException ex ){
log.debug("VString.setVFormat - No caret Listeners");
}
//hengsin: [ adempiere-Bugs-1891037 ], preserve current data before change of format
String s = getText();
setDocument(new MDocString(m_VFormat, m_fieldLength, this));
setText(s);
}
示例6: SlotConstTraitDetailPanel
import javax.swing.event.CaretListener; //导入依赖的package包/类
public SlotConstTraitDetailPanel(final DecompiledEditorPane editor) {
slotConstEditor = new LineMarkedEditorPane();
setLayout(new BorderLayout());
add(new JScrollPane(slotConstEditor), BorderLayout.CENTER);
slotConstEditor.setFont(Configuration.getSourceFont());
slotConstEditor.changeContentType("text/flasm3");
slotConstEditor.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent e) {
if (ignoreCaret) {
return;
}
Highlighting spec = Highlighting.searchPos(specialHilights, slotConstEditor.getCaretPosition());
if (spec != null) {
editor.hilightSpecial(spec.getProperties().subtype, (int) spec.getProperties().index);
slotConstEditor.getCaret().setVisible(true);
}
}
});
}
示例7: addTextOption
import javax.swing.event.CaretListener; //导入依赖的package包/类
protected void addTextOption(TextPropertyConfigurationOption option, Component control) {
String defaultValue = this.model.getProperty(option.getName());
if (defaultValue == null) {
defaultValue = option.getDefaultValue();
}
final String requiredField = option.getName();
final JTextField valueField = new JTextField(defaultValue);
if (option.isRequired()) {
boolean isSet = defaultValue != null && defaultValue.trim().length() > 0;
this.requiredFields.put(option.getName(), isSet);
valueField.addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent evt) {
if (PropertyConfigurationStep.this.requiredFields.containsKey(requiredField)) {
boolean selected = valueField.getText() != null && valueField.getText().trim().length() > 0;
PropertyConfigurationStep.this.requiredFields.put(requiredField, selected);
PropertyConfigurationStep.this.checkComplete();
}
}
});
}
addOption(option.getName(), option.getDescription(), valueField, control);
}
示例8: addPasswordOption
import javax.swing.event.CaretListener; //导入依赖的package包/类
protected void addPasswordOption(PasswordPropertyConfigurationOption option) {
String defaultValue = this.model.getProperty(option.getName());
if (defaultValue == null) {
defaultValue = option.getDefaultValue();
}
final String requiredField = option.getName();
final JPasswordField valueField = new JPasswordField(defaultValue);
if (option.isRequired()) {
boolean isSet = defaultValue != null && defaultValue.trim().length() > 0;
this.requiredFields.put(option.getName(), isSet);
valueField.addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent evt) {
if (PropertyConfigurationStep.this.requiredFields.containsKey(requiredField)) {
boolean selected = valueField.getPassword() != null
&& String.valueOf(valueField.getPassword()).trim().length() > 0;
PropertyConfigurationStep.this.requiredFields.put(requiredField, selected);
PropertyConfigurationStep.this.checkComplete();
}
}
});
}
addOption(option.getName(), option.getDescription(), valueField);
}
示例9: SourceMenuPanel
import javax.swing.event.CaretListener; //导入依赖的package包/类
/**
* constructor
*
* @param textArea the textArea-instance
*/
public SourceMenuPanel(JTextArea textArea) {
super(new FlowLayout(FlowLayout.LEFT,5,2));
_textArea = textArea;
Document doc = _textArea.getDocument();
doc.addUndoableEditListener(new MyUndoableEditListener());
createActionTable();
_textArea.addCaretListener(new CaretListener() {
public void caretUpdate(CaretEvent e) {
boolean select = e.getDot() != e.getMark();
_btnCut.setEnabled(select);
_btnCopy.setEnabled(select);
}
});
initLayout();
}
示例10: setInput
import javax.swing.event.CaretListener; //导入依赖的package包/类
/**
* updates the inputPane-area, if references were imported from a file
*
* @param bibTexStrng
* a string containing the raw bibtext references
*/
public static void setInput(String bibTexString) {
if (clearInput) {
final CaretListener[] clis = inputPane.getCaretListeners();
final CaretListener cli = clis[0];
inputPane = new JTextArea();
inputPane.setText(bibTexString);
inputPane.addCaretListener(cli);
} else
{
inputPane.setText(bibTexString);
}
inputPane.validate();
}
示例11: createCaretListenerForComponent
import javax.swing.event.CaretListener; //导入依赖的package包/类
private CaretListener createCaretListenerForComponent() {
return new CaretListener() {
@Override
public void caretUpdate(CaretEvent e) {
if (SearchBar.getInstance().isVisible()) {
int num = SearchBar.getInstance().getNumOfMatches();
SearchBar.getInstance().showNumberOfMatches(null, num);
}
}
};
}
示例12: TaskPanel
import javax.swing.event.CaretListener; //导入依赖的package包/类
/**
* Creates new form TaskPanel
*/
public TaskPanel (LocalTask task) {
this.task = task;
initComponents();
updateReadOnlyField(headerField);
Font font = new JLabel().getFont();
headerField.setFont(font.deriveFont((float) (font.getSize() * 1.7)));
mainScrollPane.getVerticalScrollBar().setUnitIncrement(10);
privateNotesField.addCaretListener(new CaretListener() {
@Override
public void caretUpdate (CaretEvent e) {
makeCaretVisible(privateNotesField);
}
});
// A11Y - Issues 163597 and 163598
UIUtils.fixFocusTraversalKeys(privateNotesField);
initSpellChecker();
attachmentsPanel = new AttachmentsPanel(this);
attachmentsSection.setContent(attachmentsPanel);
GroupLayout layout = (GroupLayout) attributesPanel.getLayout();
dueDatePicker = UIUtils.createDatePickerComponent();
scheduleDatePicker = new SchedulePicker();
layout.replace(dummyDueDateField, dueDatePicker.getComponent());
dueDateLabel.setLabelFor(dueDatePicker.getComponent());
layout.replace(dummyScheduleDateField, scheduleDatePicker.getComponent());
scheduleDateLabel.setLabelFor(scheduleDatePicker.getComponent());
attachListeners();
}
示例13: fireCaretEvent
import javax.swing.event.CaretListener; //导入依赖的package包/类
protected void fireCaretEvent() {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i--) {
if (listeners[i] == CaretListener.class) {
((CaretListener) listeners[i + 1]).caretUpdate(caretEvent);
}
}
}
示例14: CodeReader
import javax.swing.event.CaretListener; //导入依赖的package包/类
public CodeReader() {
setEditable(false);
setContentType("text/java");
// turn off token highlighting (it's wrong most of the time anyway...)
DefaultSyntaxKit kit = (DefaultSyntaxKit)getEditorKit();
kit.toggleComponent(this, "de.sciss.syntaxpane.components.TokenMarker");
// hook events
addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent event) {
if (m_selectionListener != null && m_sourceIndex != null) {
Token token = m_sourceIndex.getReferenceToken(event.getDot());
if (token != null) {
m_selectionListener.onSelect(m_sourceIndex.getDeobfReference(token));
} else {
m_selectionListener.onSelect(null);
}
}
}
});
m_selectionHighlightPainter = new SelectionHighlightPainter();
m_sourceIndex = null;
m_selectionListener = null;
}
示例15: addCaretListener
import javax.swing.event.CaretListener; //导入依赖的package包/类
/**
* Maps {@code JTextComponent.addCaretListener(CaretListener)} through queue
*/
public void addCaretListener(final CaretListener caretListener) {
runMapping(new MapVoidAction("addCaretListener") {
@Override
public void map() {
((JTextComponent) getSource()).addCaretListener(caretListener);
}
});
}