04. april 2002 - 15:02Der er
1 kommentar og 1 løsning
Set new tab size in a JTextPane
Hello!
I have a class that extends from JTextPane. Now I would like to have an other tab size in this pane, an other then the deafult. JTextArea support this but how do a make it in a JTextPane?
Best regards
Fredrik
Ps I have ide about a Keylistener theat listens for keyEvent-tab and moves everything to a given point but it seems so complicated??
private TabSet tabSet = new TabSet(new TabStop[] { new TabStop(100), new TabStop(100), new TabStop(100)} ); //set up the styles you want to use in you JTextPane Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setFontFamily(def, regularFont.getFamily()); StyleConstants.setTabSet(def,tabSet); textPane.setParagraphAttributes(def,true); Style regular = textPane.addStyle("regular", def);
//Now put tabbed text in the pane: Document doc = textPane.getDocument(); doc.insertString(doc.getLength(), "\t" + "some text" + NL, textPane.getStyle("regular"));
But do you know how to set tabstop dynamic in case you do not know the width?
Best regards
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.