All Packages Class Hierarchy This Package Previous Next Index
Class jumbo.xml.gui.XText
java.lang.Object
|
+----com.sun.java.swing.text.AbstractDocument
|
+----com.sun.java.swing.text.DefaultStyledDocument
|
+----jumbo.xml.gui.XText
- public class XText
- extends DefaultStyledDocument
a simple implemntation of a Swing text document.
/** (from Swing tutorial)
Then, at the appropriate time, you can use the various methods of StyleConstants to
change the style of the selected contents within the JTextPane or use
StyledDocument methods like setCharacterAttributes,
setParagraphAttributes, or just plain setLogicalStyle, to change the
document characteristics. Just create a SimpleAttributeSet, and configure any
attribute you would like:
void setAlignment()
void setBold()
void setComponent()
void setFirstLineIndent()
void setFontFamily()
void setFontSize()
void setForeground()
void setIcon()
void setItalic()
void setLeftIndent()
void setLineSpacing()
void setRightIndent()
void setSpaceAbove()
void setSpaceBelow()
void setUnderline()
StyleConstants methods for changing
attributes of currently selected content.
You will also need to
setCharacterAttributes or
setParagraphAttributes the
JTextPane.
void replaceSelection(String c)
void insertComponent(Component c)
void insertIcon(Icon g)
JTextPane methods to replace currently
selected content with a String,
Component, or Icon
void setLogicalStyle(Style s)
Changes Style of current paragraph
- Author:
- P.Murray-Rust, 1998
-
defaultStyle
- default style
-
XText()
- default constructor
-
XText(StyleContext)
- use existing style context (required for icons?)
-
XText(URL)
- create from a URL
-
addComponent(Component)
- add a component
-
addIcon(Icon)
- add icon (only way so far I can add an image).
-
addText(String)
- add text using current style
-
addText(String, SimpleAttributeSet)
- add text using current style
-
displayInFrame()
- display the Text in a JFrame
-
getJTextPane()
- return a JTextPane containing the document.
-
getSimpleAttributeSet(Font)
- make a SimpleAttributeSet (i.e.
-
getSimpleAttributeSet(Font, Color)
- make a SimpleAttributeSet (i.e.
-
getText()
- get current text
-
highlight(int, int)
- highlight by line and column; BOTH start from 1 (ONE)
-
main(String[])
- simple test routine
-
setEditable(boolean)
- make the JTextPane (un)editable
defaultStyle
public static final SimpleAttributeSet defaultStyle
- default style
XText
public XText()
- default constructor
XText
public XText(StyleContext styleContext)
- use existing style context (required for icons?)
XText
public XText(URL url) throws IOException
- create from a URL
getSimpleAttributeSet
public static SimpleAttributeSet getSimpleAttributeSet(Font font)
- make a SimpleAttributeSet (i.e. a style) from a Font. Note that the components
of a SimpleAttributeSet can be poked in individually if required).
- Parameters:
- Font - font the font to set the style to
getSimpleAttributeSet
public static SimpleAttributeSet getSimpleAttributeSet(Font font,
Color foreground)
- make a SimpleAttributeSet (i.e. a style) from a Color. Note that the components
of a SimpleAttributeSet can be poked in individually if required).
- Parameters:
- Font - font the font to set the style to
getJTextPane
public JTextPane getJTextPane()
- return a JTextPane containing the document. At present this is the primary
way of using this class
- Returns:
- JTextPane contains the rendered document
addText
public void addText(String text,
SimpleAttributeSet style)
- add text using current style
- Parameters:
- String - text text to be added (newlines have to be explicitly included)
- SimpleAttributeSet - style the style (see Swing documentation for how to create this)
getText
public String getText()
- get current text
addText
public void addText(String text)
- add text using current style
- Parameters:
- String - text text to be added
addComponent
public void addComponent(Component component)
- add a component
- Parameters:
- Component - component to be added
addIcon
public void addIcon(Icon icon)
- add icon (only way so far I can add an image). It doesn't work yet
- Parameters:
- Icon - image to be added
displayInFrame
public void displayInFrame()
- display the Text in a JFrame
highlight
public void highlight(int line,
int column)
- highlight by line and column; BOTH start from 1 (ONE)
setEditable
public void setEditable(boolean editable)
- make the JTextPane (un)editable
- Parameters:
- boolean - editable
main
public static void main(String args[])
- simple test routine
All Packages Class Hierarchy This Package Previous Next Index