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

Variable Index

 o defaultStyle
default style

Constructor Index

 o XText()
default constructor
 o XText(StyleContext)
use existing style context (required for icons?)
 o XText(URL)
create from a URL

Method Index

 o addComponent(Component)
add a component
 o addIcon(Icon)
add icon (only way so far I can add an image).
 o addText(String)
add text using current style
 o addText(String, SimpleAttributeSet)
add text using current style
 o displayInFrame()
display the Text in a JFrame
 o getJTextPane()
return a JTextPane containing the document.
 o getSimpleAttributeSet(Font)
make a SimpleAttributeSet (i.e.
 o getSimpleAttributeSet(Font, Color)
make a SimpleAttributeSet (i.e.
 o getText()
get current text
 o highlight(int, int)
highlight by line and column; BOTH start from 1 (ONE)
 o main(String[])
simple test routine
 o setEditable(boolean)
make the JTextPane (un)editable

Variables

 o defaultStyle
 public static final SimpleAttributeSet defaultStyle
default style

Constructors

 o XText
 public XText()
default constructor

 o XText
 public XText(StyleContext styleContext)
use existing style context (required for icons?)

 o XText
 public XText(URL url) throws IOException
create from a URL

Methods

 o 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
 o 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
 o 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
 o 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)
 o getText
 public String getText()
get current text

 o addText
 public void addText(String text)
add text using current style

Parameters:
String - text text to be added
 o addComponent
 public void addComponent(Component component)
add a component

Parameters:
Component - component to be added
 o 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
 o displayInFrame
 public void displayInFrame()
display the Text in a JFrame

 o highlight
 public void highlight(int line,
                       int column)
highlight by line and column; BOTH start from 1 (ONE)

 o setEditable
 public void setEditable(boolean editable)
make the JTextPane (un)editable

Parameters:
boolean - editable
 o main
 public static void main(String args[])
simple test routine


All Packages  Class Hierarchy  This Package  Previous  Next  Index