com.saic.isd.printscreen
Class Util

java.lang.Object
  extended bycom.saic.isd.printscreen.Util

public class Util
extends java.lang.Object

Provides a variety of static functions to support the print screen package.


Constructor Summary
Util()
           
 
Method Summary
static void copyToClipboard(java.lang.String contents)
          Copies a string to the clipbaord.
static javax.swing.text.html.HTMLDocument getHTMLDocument(java.lang.String convertMe)
          Converts String to HTMLDocument.
static java.lang.String getTextFromFile(java.io.File file)
          Gets a string from a file.
static java.io.File getUserHomeDirectory()
          Returns a data directory for this user for saving stuff into.
static void main(java.lang.String[] args)
           
static void preview(javax.swing.JDialog dialog, java.lang.String printMe, javax.swing.text.EditorKit kit)
           
static void previewHTML(java.awt.Component owner, java.lang.String title, java.lang.String printMe)
           
static void previewText(java.awt.Component owner, java.lang.String title, java.lang.String printMe)
           
static void print(java.lang.String printMe, javax.swing.text.EditorKit kit)
          Sends a string to the printer using the editor kit provided.
static void printHtml(java.lang.String printMe)
          Sends an HTML string to the printer.
static void printText(java.lang.String printMe)
          Sends a plain text string to the printer.
static void saveToFile(java.lang.String contents, SimpleFileFilter filter, java.awt.Component component)
          Asks the user a file name and saves a string to a file.
static java.io.InputStream stringToInputStream(java.lang.String convertMe)
          Converts String to InputStream.
static void writeTextToFile(java.io.File file, java.lang.String write)
          Writes a String to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

printHtml

public static void printHtml(java.lang.String printMe)
Sends an HTML string to the printer. Dialog boxes will come up to get appropriate printer information.

Parameters:
printMe - String containing a complete HTML 3.2 document.

previewHTML

public static void previewHTML(java.awt.Component owner,
                               java.lang.String title,
                               java.lang.String printMe)

printText

public static void printText(java.lang.String printMe)
Sends a plain text string to the printer. Dialog boxes will come up to get appropriate printer information.

Parameters:
printMe - Unformatted text string.

previewText

public static void previewText(java.awt.Component owner,
                               java.lang.String title,
                               java.lang.String printMe)

preview

public static void preview(javax.swing.JDialog dialog,
                           java.lang.String printMe,
                           javax.swing.text.EditorKit kit)

print

public static void print(java.lang.String printMe,
                         javax.swing.text.EditorKit kit)
Sends a string to the printer using the editor kit provided. Dialog boxes will come up to get appropriate printer information.

Note that if you pass in a DefaultEditorKit, it likely that nothing will print. Instead, use a StyledEditorKit or HTMLEditorKit.

Parameters:
printMe - text to print
kit - how to print

getHTMLDocument

public static javax.swing.text.html.HTMLDocument getHTMLDocument(java.lang.String convertMe)
                                                          throws java.io.IOException,
                                                                 javax.swing.text.BadLocationException
Converts String to HTMLDocument.

Parameters:
convertMe - text to convert
Returns:
the document
Throws:
java.io.IOException
javax.swing.text.BadLocationException

stringToInputStream

public static java.io.InputStream stringToInputStream(java.lang.String convertMe)
Converts String to InputStream.

Parameters:
convertMe - String to convert
Returns:
input stream

getTextFromFile

public static java.lang.String getTextFromFile(java.io.File file)
                                        throws java.io.FileNotFoundException,
                                               java.io.IOException
Gets a string from a file.

Parameters:
file - File to get text from.
Returns:
text from the file.
Throws:
java.io.FileNotFoundException
java.io.IOException

writeTextToFile

public static void writeTextToFile(java.io.File file,
                                   java.lang.String write)
                            throws java.io.IOException
Writes a String to a file.

Parameters:
file - file to write to.
write - text to write.
Throws:
java.io.IOException

getUserHomeDirectory

public static java.io.File getUserHomeDirectory()
Returns a data directory for this user for saving stuff into.

Returns:
Users home directory.

copyToClipboard

public static void copyToClipboard(java.lang.String contents)
Copies a string to the clipbaord.

Parameters:
contents -

saveToFile

public static void saveToFile(java.lang.String contents,
                              SimpleFileFilter filter,
                              java.awt.Component component)
Asks the user a file name and saves a string to a file.

Parameters:
contents - What to save into the file.
filter - Files to show; file type to be saved.

main

public static void main(java.lang.String[] args)


Copyright © 2002 Gerhard Beck. All rights reserved. Subject to GPL.