jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); fnt = ge.getAvailableFontFamilyNames(); mas = jta.getInputAttributes(); new Thread(this).start();
public static void increaseJTextPaneFont(JTextPane jtp) { MutableAttributeSet attrs = jtp.getInputAttributes(); //first get the current size of the font int size = StyleConstants.getFontSize(attrs); //now increase by 2 (or whatever factor you like) StyleConstants.setFontSize(attrs, size * 2); StyledDocument doc = jtp.getStyledDocument(); doc.setCharacterAttributes(0, doc.getLength() + 1, attrs, false); }
/** * Method for inserting Unicode characters via the UnicodeDialog class */ public void insertUnicodeChar(String sChar) throws IOException, BadLocationException, RuntimeException { int caretPos = jtpMain.getCaretPosition(); if (sChar != null) { htmlDoc.insertString(caretPos, sChar, jtpMain.getInputAttributes()); jtpMain.setCaretPosition(caretPos + 1); } }
/** * Method for inserting a non-breaking space ( ) */ private void insertNonbreakingSpace() throws IOException, BadLocationException, RuntimeException { int caretPos = jtpMain.getCaretPosition(); htmlDoc.insertString(caretPos, "\240", jtpMain.getInputAttributes()); jtpMain.setCaretPosition(caretPos + 1); }
pane.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent event) { final JTextPane textPane = (JTextPane) event.getSource(); EventQueue.invokeLater(new Runnable() { public void run() { MutableAttributeSet inputAttr = textPane.getInputAttributes(); inputAttr.removeAttribute(StyleConstants.Foreground); } }); } });
private void maintainForegroundColor() { // Ensure text typed into the console uses the foreground color. If we don't set it here, the // editor sometimes reuses a color from wherever the user may have moved the cursor in the console // and pressed Enter. _outputPanel.getInputAttributes(); SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setForeground( sas, _outputPanel.getForeground() ); _outputPanel.setCharacterAttributes( sas, false ); } }
public void appendToInput(String message, boolean preserveCaretPosition) { try { document.insertString(document.getLength(), message, textPane.getInputAttributes().copyAttributes()); } catch (BadLocationException e) { e.printStackTrace(); } catch (Exception e) { logger.error("Cannot insert input text", e); } if(!preserveCaretPosition) { textPane.setCaretPosition(document.getLength()); } }
MutableAttributeSet attrs = jtp.getInputAttributes();
attribIns = new SimpleAttributeSet (textArea.getInputAttributes());
public void run() { textPane2.getCaret().setDot(textPane2.getText().length()); MutableAttributeSet inputAttributes = textPane2.getInputAttributes(); inputAttributes.addAttributes(set);
private OffsetAttrs fixCaretPosition(int offset, AttributeSet attrs) { if (!isEditAllowedAt(offset) && (readMode || fakeReadMode)) { textPane.setCaretPosition(document.getLength()); return new OffsetAttrs(document.getLength(), textPane.getInputAttributes().copyAttributes()); } return new OffsetAttrs(offset, attrs); }
public void replaceInput(String message, boolean preserveCaretPosition) { int oldCaretPosition = textPane.getCaretPosition(); try { document.remove(startReadLen, document.getLength() - startReadLen); document.insertString(document.getLength(), message, textPane.getInputAttributes().copyAttributes()); } catch (BadLocationException e) { e.printStackTrace(); } catch (Exception e) { logger.error("Cannot insert input text", e); } int newCaretPosition = (preserveCaretPosition && oldCaretPosition <= document.getLength()) ? oldCaretPosition : document.getLength(); textPane.setCaretPosition(newCaretPosition); }
jsp.setPreferredSize(new Dimension(height, width)); fnt = ge.getAvailableFontFamilyNames(); mas = jta.getInputAttributes(); for (int i = 0; i < fnt.length; i++) { StyleConstants.setBold(mas, false);
jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); fnt = ge.getAvailableFontFamilyNames(); mas = jta.getInputAttributes(); new Thread(this).start();
jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); fnt = ge.getAvailableFontFamilyNames(); mas = jta.getInputAttributes(); new Thread(this).start();
jta.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); fnt = ge.getAvailableFontFamilyNames(); mas = jta.getInputAttributes(); new Thread(this).start();