本文整理汇总了Java中javax.swing.text.DefaultStyledDocument.setDocumentFilter方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultStyledDocument.setDocumentFilter方法的具体用法?Java DefaultStyledDocument.setDocumentFilter怎么用?Java DefaultStyledDocument.setDocumentFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.DefaultStyledDocument
的用法示例。
在下文中一共展示了DefaultStyledDocument.setDocumentFilter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newPassword
import javax.swing.text.DefaultStyledDocument; //导入方法依赖的package包/类
/**
* @return A new "Password" text field
*/
public static JPasswordField newPassword() {
JPasswordField passwordField = new JPasswordField(BitherUI.PASSWORD_LENGTH);
// Ensure it is accessible
AccessibilityDecorator.apply(passwordField, MessageKey.ENTER_PASSWORD);
// Provide a consistent echo character across all components
passwordField.setEchoChar(getPasswordEchoChar());
// Limit the length of the underlying document
DefaultStyledDocument doc = new DefaultStyledDocument();
doc.setDocumentFilter(new DocumentMaxLengthFilter(BitherUI.PASSWORD_LENGTH));
passwordField.setDocument(doc);
// Set the theme
passwordField.setBorder(new TextBubbleBorder(Themes.currentTheme.dataEntryBorder()));
passwordField.setBackground(Themes.currentTheme.dataEntryBackground());
passwordField.setOpaque(false);
return passwordField;
}
示例2: newEnterTransactionLabel
import javax.swing.text.DefaultStyledDocument; //导入方法依赖的package包/类
/**
* @return A new "enter transaction label" text field
*/
public static JTextField newEnterTransactionLabel() {
JTextField textField = newTextField(BitherUI.RECEIVE_ADDRESS_LABEL_LENGTH);
// Ensure it is accessible
AccessibilityDecorator.apply(textField, MessageKey.TRANSACTION_LABEL, MessageKey.TRANSACTION_LABEL_TOOLTIP);
// Limit the length of the underlying document
DefaultStyledDocument doc = new DefaultStyledDocument();
doc.setDocumentFilter(new DocumentMaxLengthFilter(BitherUI.RECEIVE_ADDRESS_LABEL_LENGTH));
textField.setDocument(doc);
return textField;
}
示例3: newEnterQRCodeLabel
import javax.swing.text.DefaultStyledDocument; //导入方法依赖的package包/类
/**
* @return A new "enter QR code label" text field
*/
public static JTextField newEnterQRCodeLabel() {
JTextField textField = newTextField(BitherUI.RECEIVE_ADDRESS_LABEL_LENGTH);
// Ensure it is accessible
AccessibilityDecorator.apply(textField, MessageKey.QR_CODE_LABEL, MessageKey.QR_CODE_LABEL_TOOLTIP);
// Limit the length of the underlying document
DefaultStyledDocument doc = new DefaultStyledDocument();
doc.setDocumentFilter(new DocumentMaxLengthFilter(BitherUI.RECEIVE_ADDRESS_LABEL_LENGTH));
textField.setDocument(doc);
return textField;
}
示例4: newEnterPrivateNotes
import javax.swing.text.DefaultStyledDocument; //导入方法依赖的package包/类
/**
* @param listener The document listener for detecting changes to the content
* @return A new "Notes" text area
*/
public static JTextArea newEnterPrivateNotes(DocumentListener listener, int width) {
JTextArea textArea = new JTextArea(6, width);
// Ensure it is accessible
AccessibilityDecorator.apply(textArea, MessageKey.PRIVATE_NOTES, MessageKey.PRIVATE_NOTES_TOOLTIP);
// Limit the length of the underlying document
DefaultStyledDocument doc = new DefaultStyledDocument();
doc.setDocumentFilter(new DocumentMaxLengthFilter(BitherUI.SEED_PHRASE_LENGTH));
textArea.setDocument(doc);
// Ensure we monitor changes
doc.addDocumentListener(listener);
// Ensure line wrapping occurs correctly
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
// Ensure TAB transfers focus
AbstractAction transferFocus = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
((Component) e.getSource()).transferFocus();
}
};
textArea.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "transferFocus");
textArea.getActionMap().put("transferFocus", transferFocus);
// Set the theme
textArea.setBorder(new TextBubbleBorder(Themes.currentTheme.dataEntryBorder()));
textArea.setBackground(Themes.currentTheme.dataEntryBackground());
textArea.setOpaque(false);
return textArea;
}
示例5: newEnterSeedPhrase
import javax.swing.text.DefaultStyledDocument; //导入方法依赖的package包/类
/**
* @return A new "seed phrase" text area for entry
*/
public static JTextArea newEnterSeedPhrase() {
// Limit the length of the underlying document
DefaultStyledDocument doc = new DefaultStyledDocument();
doc.setDocumentFilter(new DocumentMaxLengthFilter(BitherUI.SEED_PHRASE_LENGTH));
// Keep this in line with the PASSWORD_AREA constant
JTextArea textArea = new JTextArea(doc, "", 6, BitherUI.PASSWORD_LENGTH);
// Ensure it is accessible
AccessibilityDecorator.apply(textArea, MessageKey.SEED_PHRASE);
// Ensure TAB transfers focus
AbstractAction transferFocus = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
((Component) e.getSource()).transferFocus();
}
};
textArea.getInputMap().put(KeyStroke.getKeyStroke("TAB"), "transferFocus");
textArea.getActionMap().put("transferFocus", transferFocus);
// Ensure line and word wrapping occur as required
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
// Set the theme
textArea.setBorder(new TextBubbleBorder(Themes.currentTheme.dataEntryBorder()));
textArea.setBackground(Themes.currentTheme.dataEntryBackground());
textArea.setFont(new Font("Courier New", Font.PLAIN, 14));
return textArea;
}
示例6: createEditor
import javax.swing.text.DefaultStyledDocument; //导入方法依赖的package包/类
private void createEditor() {
editor = new TextEditor(true);
editor.setFont(new Font(FONT_FAMILY, Font.PLAIN, FONT_SIZE));
DefaultStyledDocument doc = new DefaultStyledDocument();
doc.setDocumentFilter(new GroovyFilter(doc));
editor.setDocument(doc);
registerEditorActions();
}
示例7: newReadOnlyLengthLimitedTextArea
import javax.swing.text.DefaultStyledDocument; //导入方法依赖的package包/类
/**
* @param listener The document listener for detecting changes to the content
* @param rows The number of rows (normally 6)
* @param columns The number of columns (normally 60)
* @return A new read only length limited text field with default theme
*/
public static JTextArea newReadOnlyLengthLimitedTextArea(DocumentListener listener, int rows, int columns) {
JTextArea textArea = newReadOnlyTextArea(rows, columns);
// Limit the length of the underlying document
DefaultStyledDocument doc = new DefaultStyledDocument();
doc.setDocumentFilter(new DocumentMaxLengthFilter(rows * columns));
textArea.setDocument(doc);
// Ensure we monitor changes
doc.addDocumentListener(listener);
return textArea;
}