|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent com.wildcrest.j2printerworks.J2Pageable com.wildcrest.j2printerworks.J2TextPrinter
A Java 2 component for multi-page printing of the contents of any multi-line JTextComponent (JTextPane,
JEditorPane, JTextArea) or subclass thereof, as either a Pageable or a Flowable, breaking pages on text
line boundaries.
Prints the contents of any multi-line JTextComponent such as a JTextPane, JEditorPane, JTextArea, or
any subclass thereof. The contents of the JTextComponent will either be reflowed (rewrapped) to fit
the available page or can be printed in "WYSIWYG" mode to maintain the layout of the specified
JTextComponent. In addition, if the JTextComponent is a JTextPane, it can have embedded graphics or
embedded components (provided they are <1 page in size). You can specify page breaks directly in the
JTextComponent. The JTextComponent can be left, right, or center justified horizontally,
or top, bottom, or center justified vertically on the page.
The JTextComponent model (Document or StyledDocument for a JTextPane) can be generated programmatically
or, in the case of JTextPane and JEditorPane, specified
using HTML or RTF (subject to the limitations of Java's support for these formats).
In addition, all the standard J2Pageable features are also available when printing
J2TextPrinter as a Pageable, including control of
headers, footers, margins, orientation, and scale.
(C) Copyright 2009, Wildcrest Associates (http://www.wildcrest.com). All rights reserved.
Nested Class Summary |
Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
Fields inherited from class com.wildcrest.j2printerworks.J2Pageable |
BOTTOM, BOX, CENTER, FIRST, GLOBAL, LANDSCAPE, LEFT, LINE, NONE, PORTRAIT, PPI72, REST, REVERSE_LANDSCAPE, RIGHT, TOP |
Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.print.Pageable |
UNKNOWN_NUMBER_OF_PAGES |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
J2TextPrinter()
Construct a J2TextPrinter object (no JTextComponent specified) |
|
J2TextPrinter(javax.swing.JEditorPane pane)
Construct a J2TextPrinter object for a given JEditorPane |
|
J2TextPrinter(javax.swing.JTextArea pane)
Construct a J2TextPrinter object for a given JTextArea |
|
J2TextPrinter(javax.swing.JTextPane pane)
Construct a J2TextPrinter object for a given JTextPane |
|
J2TextPrinter(java.lang.String string)
Construct a J2TextPrinter object for a given String (uses default font: SansSerif, PLAIN, 12 with color: black and alignment: left) |
|
J2TextPrinter(java.lang.String string,
java.awt.Font font)
Construct a J2TextPrinter object for a given String and given Font (with color: black and alignment: left). |
|
J2TextPrinter(java.lang.String string,
java.awt.Font font,
java.awt.Color color,
int alignment)
Construct a J2TextPrinter object for a given String, Font, Color, and alignment. |
Method Summary | |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a PropertyChangeListener for this component |
static void |
appendStyledText(javax.swing.JTextPane pane,
java.lang.String string,
javax.swing.text.SimpleAttributeSet attribute)
Convenience method for appending text with the specified rich text attributes to the end of the StyledDocument that represents the current contents of the JTextPane. |
static void |
clearPane(javax.swing.JTextPane pane)
Convenience method to clear all text and attributes in the specified JTextPane |
javax.swing.JEditorPane |
clone(javax.swing.JEditorPane oldPane)
Convenience factory method for making a new JEditorPane whose Document is a serialized copy (deep clone) of the specified JEditorPane's Document. |
javax.swing.JTextArea |
clone(javax.swing.JTextArea oldArea)
Convenience factory method for making a new JTextArea whose Document is a serialized copy (deep clone) of the specified JTextArea's Document. |
javax.swing.JTextPane |
clone(javax.swing.JTextPane oldPane)
Convenience factory method for making a new JTextPane whose StyledDocument is a serialized copy (deep clone) of the specified JTextPane's StyledDocument. |
void |
dispose()
Release all heap objects created by this J2TextPrinter object, must not call until printing completes. |
boolean |
doneX()
Returns whether there is no more of this Flowable object to print horizontally. |
boolean |
doneY()
Returns whether there is no more of this Flowable object to print vertically. |
int |
getHorizontalAlignment()
Returns horizontal alignment (LEFT, CENTER, RIGHT) of this JTextComponent on page. |
double |
getMaximumPaginationGap()
Returns largest acceptable pagination gap as a percentage of the full body height. |
java.awt.Color |
getOutsideLineColor()
Returns outside line Color. |
javax.swing.JTextPane |
getPane()
Returns the JTextPane containing the StyledDocument that will be printed. |
javax.swing.text.JTextComponent |
getTextComponent()
Returns the JTextComponent whose contents (Document) will be printed. |
int |
getVerticalAlignment()
Returns vertical alignment (TOP, CENTER, BOTTOM) of this JTextComponent on page. |
void |
hideImagingFrame()
Hide internal imaging JFrame (left behind if have embedded components), must only be called after printing completes. |
boolean |
isCloningUsed()
Returns whether cloning is used for J2TextPrinter printing (see explanation under setCloningUsed ). |
boolean |
isDirectPrint()
Returns current value of Direct Print mode. |
boolean |
isOutsideLines()
Returns whether to print outside border lines around this JTextComponent. |
boolean |
isPrintHTMLComments()
Returns current value of printHTMLComments mode. |
boolean |
isWYSIWYG()
Returns current value of wysiwyg mode. |
static javax.swing.JTextPane |
makeHTMLPane(java.lang.String html)
Convenience factory method for creating a JTextPane using an HTML String. |
static javax.swing.text.SimpleAttributeSet |
makeSimpleAttributeSet(java.lang.String fontName,
java.lang.String style,
int size,
int align,
java.awt.Color color)
Convenience factory method for making a SimpleAttributeSet for a desired Font, specified using font name, style, size, alignment, and color. |
void |
printFlowable(java.awt.Graphics g,
int availableWidth,
int availableHeight,
int nextFullPageWidth,
int nextFullPageHeight)
Print the next sequential section of this Flowable object that fits into the next incremental area. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a PropertyChangeListener for this component |
void |
resetFlowable()
Reset the Flowable object so that it starts printing from the beginning. |
void |
setCloningUsed(boolean cloningUsed)
Specify whether cloning (copying by Java serialization) is to be used when printing with J2TextPrinter. |
void |
setDirectPrint(boolean directPrint)
Sets whether "direct print" mode is enabled (see documentation). |
void |
setHorizontalAlignment(int horizontalAlignment)
Sets the horizontal alignment (LEFT, CENTER, RIGHT) for printing the JTextComponent on the page, typically used with setWYSIWYG(true). |
void |
setHTMLEditorKit(javax.swing.text.html.HTMLEditorKit kit)
Notify J2TextPrinter of your use of a custom HTMLEditorKit for this JTextPane or JEditorPane. |
void |
setMaximumPages(int pagesHigh)
Rescale this J2TextPrinter to print within a maximum number of vertical pages (will minify to fit). |
void |
setMaximumPaginationGap(double maximumPaginationGap)
Sets the largest acceptable pagination gap as a percentage of the full body height. |
void |
setOutsideLineColor(java.awt.Color outsideLineColor)
Sets Color of outside border lines. |
void |
setOutsideLines(boolean showOutsideLines)
Sets whether to print outside border lines around this JTextComponent. |
void |
setPane(javax.swing.JTextPane pane)
Convenience method for specifying the JTextPane containing a StyledDocument that will be printed. |
void |
setPrintHTMLComments(boolean printHTMLComments)
Sets whether HTML comments (delimited by <!-- and -->) are printed when printing HTML documents. |
void |
setTextComponent(javax.swing.text.JTextComponent component)
Specifies the JTextComponent (JTextPane, JEditorPane, or JTextArea whose contents (Document) will be printed. |
void |
setVerticalAlignment(int verticalAlignment)
Sets the vertical alignment (TOP, CENTER, BOTTOM) for printing the JTextComponent on the page. |
void |
setWYSIWYG(boolean wysiwyg)
Sets whether WYSIWYG (What-You-See-Is-What-You-Get) mode is enabled (and thereby prevent relayout of text). |
int |
usedX()
Returns the amount this Flowable object was able to advance horizontally in the last printFlowable call. |
int |
usedY()
Returns the amount this Flowable object was able to advance vertically in the last printFlowable call. |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public J2TextPrinter()
public J2TextPrinter(javax.swing.JTextPane pane)
public J2TextPrinter(javax.swing.JEditorPane pane)
public J2TextPrinter(javax.swing.JTextArea pane)
public J2TextPrinter(java.lang.String string)
public J2TextPrinter(java.lang.String string, java.awt.Font font, java.awt.Color color, int alignment)
string
- String specifying desired text string to be printedfont
- Font specifying desired Font to be used for printingecolor
- Color specifying the desired Color of the text to be printedalignment
- int specifying desired left, center, right alignment, e.g., StyleConstants.ALIGN_LEFT, etc.public J2TextPrinter(java.lang.String string, java.awt.Font font)
string
- String specifying desired text string to be printedfont
- Font specifying desired Font to be used for printingeMethod Detail |
public void dispose()
dispose
in class J2Pageable
public void hideImagingFrame()
public void printFlowable(java.awt.Graphics g, int availableWidth, int availableHeight, int nextFullPageWidth, int nextFullPageHeight)
Flowable
g
- context into which the page is to be drawn (null means advance but don't actually print)availableWidth
- horizontal amount into which the next sequential amount of this Flowable is to be printed.availableHeight
- vertical amount into which the next sequential amount of this Flowable is to be printed.nextFullPageWidth
- horizontal size of next full page (lets Flowables decide whether to opt for next page).nextFullPageHeight
- vertical size of next full page (lets Flowables decide whether to opt for next page).
The above parameters specify a rectangular area of size width by height (height = down the page) in pixels (72 dpi printing "points"). A Flowable object is assumed to print in "raster" order (over then down). Assumes upon entry that translation and scale are already set up so that 0,0 is the upper left corner to print and width and height are already increased by the overall printer scale. Flowable object must return Graphics context translation and scale to values at entry if changed during printing. Upon return from printFlowable, the doneX, doneY, usedX, and usedY methods describe the resulting state of the Flowable, based on its ability to make progress. Return values of usedX and usedY are to be specified in same scale as availableWidth and availableHeight were given.
public int usedX()
Flowable
public int usedY()
Flowable
public boolean doneX()
Flowable
public boolean doneY()
Flowable
public void resetFlowable()
Flowable
public void setMaximumPages(int pagesHigh)
pagesHigh
- specifies maximum vertical number of pages for printing this J2TextPrinter
(< or = 0 if unconstrained).public javax.swing.JTextPane clone(javax.swing.JTextPane oldPane)
oldPane
- JTextPane whose contents is to be cloned
CloneException
- if unable to serialize JTextPane's StyledDocumentpublic javax.swing.JEditorPane clone(javax.swing.JEditorPane oldPane)
oldPane
- JEditorPane whose contents is to be cloned
CloneException
- if unable to serialize JEditorPane's Documentpublic void setHTMLEditorKit(javax.swing.text.html.HTMLEditorKit kit)
kit
- HTMLEditorKit to use when printing this JTextPane or JEditorPanepublic javax.swing.JTextArea clone(javax.swing.JTextArea oldArea)
oldArea
- JTextArea whose contents is to be cloned
CloneException
- if unable to serialize JTextArea's Documentpublic static javax.swing.JTextPane makeHTMLPane(java.lang.String html)
html
- String specifying desired HTML contents for JTextPanepublic static void appendStyledText(javax.swing.JTextPane pane, java.lang.String string, javax.swing.text.SimpleAttributeSet attribute)
pane
- JTextPane for appending styled text with the specified attributesstring
- String of characters to be appended to the specified JTextPaneattribute
- SimpleAttributeSet specifying desired text style (use makeSimpleAttributeSet)public static void clearPane(javax.swing.JTextPane pane)
pane
- JTextPane for which all text and attributes will be clearedpublic static javax.swing.text.SimpleAttributeSet makeSimpleAttributeSet(java.lang.String fontName, java.lang.String style, int size, int align, java.awt.Color color)
SimpleAttributeSet aset = makeSimpleAttributeSet("Serif",
"BoldItalic",
12,
StyleConstants.ALIGN_LEFT,
Color.black);
StyleConstants.setLineSpacing(aset,.25);
StyleConstants.setBackground(aset,Color.yellow);
and similarly using StyleConstants for other attributes such as TabSet, FirstLineIndent, etc.
fontName
- String name of desired Font, e.g., "Serif", "SansSerif"style
- String specifying the desired style using any combination of the words "Bold",
"Italic", and/or "Underline"size
- the desired point size of Fontalign
- int = StyleConstants.ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, or ALIGN_JUSTIFIEDcolor
- desired Color of Fontpublic void setTextComponent(javax.swing.text.JTextComponent component)
component
- the JTextComponent (JTextPane, JEditorPane, or JTexArea) whose contents (Document)
will be printedpublic javax.swing.text.JTextComponent getTextComponent()
public void setPane(javax.swing.JTextPane pane)
pane
- the JTextPane whose contents (StyledDocument) will be printedpublic javax.swing.JTextPane getPane()
public void setHorizontalAlignment(int horizontalAlignment)
horizontalAlignment
- J2TextPrinter.LEFT, .CENTER, or .RIGHT (default: CENTER)public int getHorizontalAlignment()
public void setVerticalAlignment(int verticalAlignment)
verticalAlignment
- J2TextPrinter.TOP, .CENTER, or .BOTTOM (default: TOP)public int getVerticalAlignment()
public void setOutsideLines(boolean showOutsideLines)
showOutsideLines
- true means print outside border lines, false if not (default: true)public boolean isOutsideLines()
public void setOutsideLineColor(java.awt.Color outsideLineColor)
outsideLineColor
- color with which to draw outside lines (default: Color.black)public java.awt.Color getOutsideLineColor()
public void setMaximumPaginationGap(double maximumPaginationGap)
maximumPaginationGap
- The largest acceptable pagination gap as percentage of full body height.
Must be less than 1.0 (will be set to 0.99 if a value 1.0 or greater is requested).
A value of 0.0 means always split, never waste a pixel, close to 1.0 means
OK to skip most of a page to keep content intact (default: 0.2).public double getMaximumPaginationGap()
public void setWYSIWYG(boolean wysiwyg)
True means JTextComponent width will be preserved when printing so that the JTextComponent will not undergo relayout. If the JTextComponent is wider than the printable page area between margins, the JTextComponent will be scaled (minified) to fit. False means the JTextComponent contents will be reflowed to fit the printable page area between margins.
wysiwyg
- boolean representing whether to preserve the JTextComponent width when printing.
Default: falsepublic boolean isWYSIWYG()
public void setPrintHTMLComments(boolean printHTMLComments)
printHTMLComments
- boolean representing whether to enable printing of HTML comments.
Default: falsepublic boolean isPrintHTMLComments()
public void setDirectPrint(boolean directPrint)
A value of "true" means that the JTextComponent will be printed directly from the original user JTextComponent. Cloning will not be used, regardless of the value set by the setCloningUsed method. WYSIWYG will be assumed, regardless of the value set by the setWYSIWYG method, and the JTextComponent will not be reflowed. JTextComponent must already be "realized", e.g., added to a frame followed by a call to either frame.setVisible(true) or frame.pack(). The JTextComponent will only be paginated, with the current layout and line breaks unchanged. Printing will be scaled down as necessary to fit the available page width (this requires JDK 1.4.2_02 or later). Direct print is not thread safe so JTextComponent must be left untouched until printing completes!
The main benefit of using direct print is that text entries in the fields of an HTML form will be printed, as well as any embedded components (even if they are not cloneable) without the need to remove them from the current display.
The direct print technique only works under JDK 1.3.1, 1.4.1, and 1.4.2 or later. It does not work at all prior to JDK 1.3.1. There is also a Java bug (Bug Parade 4708924) that causes this technique to throw an "IllegalStateException: constrain(xywh) is not supported for complex transform" under JDK 1.4. Due to the same bug, prior to JDK 1.4.2_02 you can only perform a print preview with 100% scale and cannot have a JTextComponent wider than getBodyWidth() which would cause the JTextComponent to be scaled down.
directPrint
- boolean representing whether to print the JTextComponent directly from the original.
Default: falsepublic boolean isDirectPrint()
public void setCloningUsed(boolean cloningUsed)
J2TextPrinter needs to be able to reflow the contents of your JTextComponent without affecting its appearance on the screen. To accomplish this, J2TextPrinter prints your JTextComponent's contents from its own internal JTextComponent rather than from your JTextComponent (unless you use setDirectPrint(true), see documentation).
If cloningUsed
is true, the internal JTextComponent Document (or StyledDocument in
the case of a JTextPane) is set to a clone (serialized copy) of the Document of your JTextComponent.
This allows printing to proceed without ever accessing your JTextComponent again. Cloning is the
safest approach, particular if printing from a separate thread, since it assures thread-safety.
The maindrawback is that it is possible to create JTextComponent instances that can't be copied
using Java serialization, particularly when using earlier JDK releases which still had some number
of serialization bugs. But in such cases, you often can still print if you set setCloningUsed(false).
If cloningUsed
is false, the internal JTextComponent Document is set to point directly
to your JTextComponent's Document. This results in a "shared model" approach, i.e., one copy of the
model (Document) is used by both views (the internal imaging JTextComponent and your JTextComponent).
For this reason, since there is no thread-safety, you need to leave your JTextComponent alone until
printing completes when using setCloningUsed(false).
It has been determined that cloning is generally necessary if you are printing a JTextPane for which you have inserted a Component using insertComponent(). This is particularly true if it appears on the screen or if you are printing from a separate thread (setSeparatePrintThread(true), which is the default). This is because Java doesn't support having the same Component in multiple simultaneous views (Containers).
Cloning should be safe in all other cases as well, so the default for cloningUsed
is
true. This method allows cloning to be disabled if it causes any problems for a particular
JTextCompoent and since it is slower.
In particular, serialization is broken in the JDK 1.4 beta2
release (see Bug Parade #4492468), so the cloningUsed
default is set to false for
that release. It has also been determined that certain HTML tags such as the border subtag of
table are lost during serialization, so cloningUsed
needs to be set to false for HTML
documents that contain tables with borders, otherwise the borders will be missing. Also, prior
to JDK 1.4.2, Java serialization failed for JTextComponents that contained non-ASCII (e.g. Unicode)
characters.
cloningUsed
- specifies whether cloning is used for J2TextPrinter printing.
(Default: true except under JDK 1.4 beta2)public boolean isCloningUsed()
setCloningUsed
).
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
addPropertyChangeListener
in class J2Pageable
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
removePropertyChangeListener
in class J2Pageable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |