Help with code to print HTML in Java 5

Hi,
The following code works and runs successfully..
However, the printing in Java 1.4.2_03 is better than Java 5 (latest version).
i.e in particular the characters are not monospaced compared with compiling with Java 1.4.2_03. e.g si so ss squashed together.
This issue does not seem to occur when running the same code in Java 1.4.2_03. (I haven't tried other 1.4.2 java versions).
Any help would be appreciated. We really need this working under Java 5 or bust.
Here is the complete listing ... PrintHtml.java (it uses the DocumentRenderer)
and following this is the input file.
import javax.swing.text.html.HTMLDocument;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
import java.io.DataInputStream;
import java.io.InputStream;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import java.lang.reflect.*;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import javax.swing.JEditorPane;
import javax.swing.text.Document;
import javax.swing.text.PlainDocument;
import javax.swing.text.View;
import javax.swing.text.html.HTMLDocument;
import java.awt.*;
import javax.swing.*;
import java.awt.print.*;
import java.text.ParseException;
public class PrintHtml {
     * Utility helper to convert HTML Text to HTML Document.
     * @param baseUrl URL to be used in order
     * to resolve relative HTML references, in lieu of an
     * HTML BASE tag. May be null, if not required or HTML
     * BASE tag is to be used.
     * @see jbox.view.jfx.JboxHtmlEditor
     * @see jbox.utility.JboxPrint
     * @see jbox.utility.JboxPrintUtil
  public static HTMLDocument htmlTextToHtmlDoc(String htmlText, URL baseUrl)
          try
          //  JboxHtmlEditorKit editorKit = new JboxHtmlEditorKit();
            HTMLEditorKit editorKit = new HTMLEditorKit();
            HTMLDocument doc = (HTMLDocument)editorKit.createDefaultDocument();
               if (baseUrl != null)
                    try
                         doc.setBase(baseUrl);
                    catch(Exception e)
                         //JboxTraceManager.trace(e);
               StringReader reader = new StringReader(htmlText);
               editorKit.read(reader, doc, 0);
         return doc;
          catch(Exception e)
               //JboxTraceManager.trace(e);
               return null;
   public static void main(String[] args) {
      System.out.println("printing...");
      HTMLDocument x = new HTMLDocument();
      DocumentRenderer invoice = new DocumentRenderer();
      //invoice.setScaleWidthToFit(false);
      String s = "";
      try {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("mark.html"));
        InputStreamReader in = new InputStreamReader(bis , "ASCII");
        StringWriter sw = new StringWriter();
        while (true) {
           int datum = in.read();
           if (datum == -1) break;
           sw.write(datum);
        in.close();
        s = sw.toString();
        System.out.println("s="+s);
      catch (IOException e) {
         System.err.println(e);
      HTMLDocument htmldoc = htmlTextToHtmlDoc(s, null);
      invoice.print(htmldoc);
// the good old infamous DocumentRenderer.
/*  Copyright 2002
    Kei G. Gauthier
    Suite 301
    77 Winsor Street
    Ludlow, MA  01056
class DocumentRenderer implements Printable {
/*  DocumentRenderer prints objects of type Document. Text attributes, including
    fonts, color, and small icons, will be rendered to a printed page.
    DocumentRenderer computes line breaks, paginates, and performs other
    formatting.
    An HTMLDocument is printed by sending it as an argument to the
    print(HTMLDocument) method. A PlainDocument is printed the same way. Other
    types of documents must be sent in a JEditorPane as an argument to the
    print(JEditorPane) method. Printing Documents in this way will automatically
    display a print dialog.
    As objects which implement the Printable Interface, instances of the
    DocumentRenderer class can also be used as the argument in the setPrintable
    method of the PrinterJob class. Instead of using the print() methods
    detailed above, a programmer may gain access to the formatting capabilities
    of this class without using its print dialog by creating an instance of
    DocumentRenderer and setting the document to be printed with the
    setDocument() or setJEditorPane(). The Document may then be printed by
    setting the instance of DocumentRenderer in any PrinterJob.
  protected int currentPage = -1;               //Used to keep track of when
                                                //the page to print changes.
  protected JEditorPane jeditorPane;            //Container to hold the
                                                //Document. This object will
                                                //be used to lay out the
                                                //Document for printing.
  protected double pageEndY = 0;                //Location of the current page
                                                //end.
  protected double pageStartY = 0;              //Location of the current page
                                                //start.
  protected boolean scaleWidthToFit = true;     //boolean to allow control over
                                                //whether pages too wide to fit
                                                //on a page will be scaled.
/*    The DocumentRenderer class uses pFormat and pJob in its methods. Note
      that pFormat is not the variable name used by the print method of the
      DocumentRenderer. Although it would always be expected to reference the
      pFormat object, the print method gets its PageFormat as an argument.
  protected PageFormat pFormat;
  protected PrinterJob pJob;
/*  The constructor initializes the pFormat and PJob variables.
  public DocumentRenderer() {
    pFormat = new PageFormat();
    pJob = PrinterJob.getPrinterJob();
/*  Method to get the current Document
  public Document getDocument() {
    if (jeditorPane != null) return jeditorPane.getDocument();
    else return null;
/*  Method to get the current choice the width scaling option.
  public boolean getScaleWidthToFit() {
    return scaleWidthToFit;
/*  pageDialog() displays a page setup dialog.
  public void pageDialog() {
    pFormat = pJob.pageDialog(pFormat);
/*  The print method implements the Printable interface. Although Printables
    may be called to render a page more than once, each page is painted in
    order. We may, therefore, keep track of changes in the page being rendered
    by setting the currentPage variable to equal the pageIndex, and then
    comparing these variables on subsequent calls to this method. When the two
    variables match, it means that the page is being rendered for the second or
    third time. When the currentPage differs from the pageIndex, a new page is
    being requested.
    The highlights of the process used print a page are as follows:
    I.    The Graphics object is cast to a Graphics2D object to allow for
          scaling.
    II.   The JEditorPane is laid out using the width of a printable page.
          This will handle line breaks. If the JEditorPane cannot be sized at
          the width of the graphics clip, scaling will be allowed.
    III.  The root view of the JEditorPane is obtained. By examining this root
          view and all of its children, printView will be able to determine
          the location of each printable element of the document.
    IV.   If the scaleWidthToFit option is chosen, a scaling ratio is
          determined, and the graphics2D object is scaled.
    V.    The Graphics2D object is clipped to the size of the printable page.
    VI.   currentPage is checked to see if this is a new page to render. If so,
          pageStartY and pageEndY are reset.
    VII.  To match the coordinates of the printable clip of graphics2D and the
          allocation rectangle which will be used to lay out the views,
          graphics2D is translated to begin at the printable X and Y
          coordinates of the graphics clip.
    VIII. An allocation Rectangle is created to represent the layout of the
          Views.
          The Printable Interface always prints the area indexed by reference
          to the Graphics object. For instance, with a standard 8.5 x 11 inch
          page with 1 inch margins the rectangle X = 72, Y = 72, Width = 468,
          and Height = 648, the area 72, 72, 468, 648 will be painted regardless
          of which page is actually being printed.
          To align the allocation Rectangle with the graphics2D object two
          things are done. The first step is to translate the X and Y
          coordinates of the graphics2D object to begin at the X and Y
          coordinates of the printable clip, see step VII. Next, when printing
          other than the first page, the allocation rectangle must start laying
          out in coordinates represented by negative numbers. After page one,
          the beginning of the allocation is started at minus the page end of
          the prior page. This moves the part which has already been rendered to
          before the printable clip of the graphics2D object.
    X.    The printView method is called to paint the page. Its return value
          will indicate if a page has been rendered.
    Although public, print should not ordinarily be called by programs other
    than PrinterJob.
  public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
    double scale = 1.0;
    Graphics2D graphics2D;
    View rootView;
//  I
    graphics2D = (Graphics2D) graphics;
    disableDoubleBuffering(jeditorPane);
//  II
    jeditorPane.setSize((int) pageFormat.getImageableWidth(),Integer.MAX_VALUE);
    jeditorPane.validate();
//  III
    rootView = jeditorPane.getUI().getRootView(jeditorPane);
//  IV
    if ((scaleWidthToFit) && (jeditorPane.getMinimumSize().getWidth() >
    pageFormat.getImageableWidth())) {
      scale = pageFormat.getImageableWidth()/
      jeditorPane.getMinimumSize().getWidth();
      graphics2D.scale(scale,scale);
//  V
    graphics2D.setClip((int) (pageFormat.getImageableX()/scale),
    (int) (pageFormat.getImageableY()/scale),
    (int) (pageFormat.getImageableWidth()/scale),
    (int) (pageFormat.getImageableHeight()/scale));
//  VI
    if (pageIndex > currentPage) {
      currentPage = pageIndex;
      pageStartY += pageEndY;
      pageEndY = graphics2D.getClipBounds().getHeight();
//  VII
    graphics2D.translate(graphics2D.getClipBounds().getX(),
    graphics2D.getClipBounds().getY());
//  VIII
    Rectangle allocation = new Rectangle(0,
    (int) -pageStartY,
    (int) (jeditorPane.getMinimumSize().getWidth()),
    (int) (jeditorPane.getPreferredSize().getHeight()));
//  X
    if (printView(graphics2D,allocation,rootView)) {
      return Printable.PAGE_EXISTS;
    else {
      pageStartY = 0;
      pageEndY = 0;
      currentPage = -1;
      return Printable.NO_SUCH_PAGE;
  /** The speed and quality of printing suffers dramatically if
   *  any of the containers have double buffering turned on.
   *  So this turns if off globally.
   *  @see enableDoubleBuffering
  public static void disableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(false);
  /** Re-enables double buffering globally. */
  public static void enableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(true);
/*  print(HTMLDocument) is called to set an HTMLDocument for printing.
  public void print(HTMLDocument htmlDocument) {
    setDocument(htmlDocument);
    printDialog();
/*  print(JEditorPane) prints a Document contained within a JEDitorPane.
  public void print(JEditorPane jedPane) {
    setDocument(jedPane);
    printDialog();
/*  print(PlainDocument) is called to set a PlainDocument for printing.
  public void print(PlainDocument plainDocument) {
    setDocument(plainDocument);
    printDialog();
/*  A protected method, printDialog(), displays the print dialog and initiates
    printing in response to user input.
  protected void printDialog() {
    if (pJob.printDialog()) {
      pJob.setPrintable(this,pFormat);
      try {
        pJob.print();
      catch (PrinterException printerException) {
        pageStartY = 0;
        pageEndY = 0;
        currentPage = -1;
        System.out.println("Error Printing Document");
/*  printView is a recursive method which iterates through the tree structure
    of the view sent to it. If the view sent to printView is a branch view,
    that is one with children, the method calls itself on each of these
    children. If the view is a leaf view, that is a view without children which
    represents an actual piece of text to be painted, printView attempts to
    render the view to the Graphics2D object.
    I.    When any view starts after the beginning of the current printable
          page, this means that there are pages to print and the method sets
          pageExists to true.
    II.   When a leaf view is taller than the printable area of a page, it
          cannot, of course, be broken down to fit a single page. Such a View
          will be printed whenever it intersects with the Graphics2D clip.
    III.  If a leaf view intersects the printable area of the graphics clip and
          fits vertically within the printable area, it will be rendered.
    IV.   If a leaf view does not exceed the printable area of a page but does
          not fit vertically within the Graphics2D clip of the current page, the
          method records that this page should end at the start of the view.
          This information is stored in pageEndY.
  protected boolean printView(Graphics2D graphics2D, Shape allocation,
  View view) {
    boolean pageExists = false;
    Rectangle clipRectangle = graphics2D.getClipBounds();
    Shape childAllocation;
    View childView;
    if (view.getViewCount() > 0 &&
          !view.getElement().getName().equalsIgnoreCase("td")) {
      for (int i = 0; i < view.getViewCount(); i++) {
        childAllocation = view.getChildAllocation(i,allocation);
        if (childAllocation != null) {
          childView = view.getView(i);
          if (printView(graphics2D,childAllocation,childView)) {
            pageExists = true;
    } else {
//  I
      if (allocation.getBounds().getMaxY() >= clipRectangle.getY()) {
        pageExists = true;
//  II
        if ((allocation.getBounds().getHeight() > clipRectangle.getHeight()) &&
        (allocation.intersects(clipRectangle))) {
          view.paint(graphics2D,allocation);
        } else {
//  III
          if (allocation.getBounds().getY() >= clipRectangle.getY()) {
            if (allocation.getBounds().getMaxY() <= clipRectangle.getMaxY()) {
              view.paint(graphics2D,allocation);
            } else {
//  IV
              if (allocation.getBounds().getY() < pageEndY) {
                pageEndY = allocation.getBounds().getY();
    return pageExists;
/*  Method to set the content type the JEditorPane.
  protected void setContentType(String type) {
    jeditorPane.setContentType(type);
/*  Method to set an HTMLDocument as the Document to print.
  public void setDocument(HTMLDocument htmlDocument) {
    jeditorPane = new JEditorPane();
    setDocument("text/html",htmlDocument);
/*  Method to set the Document to print as the one contained in a JEditorPane.
    This method is useful when Java does not provide direct access to a
    particular Document type, such as a Rich Text Format document. With this
    method such a document can be sent to the DocumentRenderer class enclosed
    in a JEditorPane.
  public void setDocument(JEditorPane jedPane) {
    jeditorPane = new JEditorPane();
    setDocument(jedPane.getContentType(),jedPane.getDocument());
/*  Method to set a PlainDocument as the Document to print.
  public void setDocument(PlainDocument plainDocument) {
    jeditorPane = new JEditorPane();
    setDocument("text/plain",plainDocument);
/*  Method to set the content type and document of the JEditorPane.
  protected void setDocument(String type, Document document) {
    setContentType(type);
    jeditorPane.setDocument(document);
/*  Method to set the current choice of the width scaling option.
  public void setScaleWidthToFit(boolean scaleWidth) {
    scaleWidthToFit = scaleWidth;
}The sample input file is "mark.html":::
<html>
<head>
<style type="text/css">
<!--
ol { list-style-type: decimal; margin-top: 10; margin-left: 50; margin-bottom: 10 }
u { text-decoration: underline }
s { text-decoration: line-through }
p { font-weight: normal; font-size: medium; margin-top: 15 }
dd p { margin-top: 0; margin-left: 40; margin-bottom: 0 }
ol li p { margin-top: 0; margin-bottom: 0 }
address { color: blue; font-style: italic }
i { font-style: italic }
h6 { font-weight: bold; font-size: xx-small; margin-top: 10; margin-bottom: 10 }
h5 { font-weight: bold; font-size: x-small; margin-top: 10; margin-bottom: 10 }
h4 { font-weight: bold; font-size: small; margin-top: 10; margin-bottom: 10 }
h3 { font-weight: bold; font-size: medium; margin-top: 10; margin-bottom: 10 }
dir li p { margin-top: 0; margin-bottom: 0 }
h2 { font-weight: bold; font-size: large; margin-top: 10; margin-bottom: 10 }
b { font-weight: bold }
h1 { font-weight: bold; font-size: x-large; margin-top: 10; margin-bottom: 10 }
a { color: blue; text-decoration: underline }
ul li ul li ul li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
menu { margin-top: 10; margin-left: 40; margin-bottom: 10 }
menu li p { margin-top: 0; margin-bottom: 0 }
table table { border-color: Gray; margin-right: 0; border-style: outset; margin-top: 0; margin-left: 0; margin-bottom: 0 }
sup { vertical-align: sup }
body { margin-right: 0; font-size: 14pt; font-family: SansSerif; color: black; margin-left: 0 }
ul li ul li ul { list-style-type: square; margin-left: 25 }
blockquote { margin-right: 35; margin-top: 5; margin-left: 35; margin-bottom: 5 }
samp { font-size: small; font-family: Monospaced }
cite { font-style: italic }
sub { vertical-align: sub }
em { font-style: italic }
table table table { border-color: Gray; margin-right: 0; border-style: outset; margin-top: 0; margin-left: 0; margin-bottom: 0 }
ul li p { margin-top: 0; margin-bottom: 0 }
ul li ul li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
var { font-weight: bold; font-style: italic }
table { border-color: Gray; margin-right: 7; border-style: outset; margin-top: 7; margin-left: 7; margin-bottom: 17 }
dfn { font-style: italic }
menu li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
strong { font-weight: bold }
ul { list-style-type: disc; margin-top: 10; margin-left: 50; margin-bottom: 10 }
center { text-align: center }
ul li ul { list-style-type: circle; margin-left: 25 }
kbd { font-size: small; font-family: Monospaced }
dir li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
th p { font-weight: bold; padding-left: 2; padding-bottom: 3; padding-right: 2; margin-top: 0; padding-top: 3 }
ul li menu { list-style-type: circle; margin-left: 25 }
dt { margin-top: 0; margin-bottom: 0 }
ol li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
li p { margin-top: 0; margin-bottom: 0 }
strike { text-decoration: line-through }
dl { margin-top: 10; margin-left: 10; margin-bottom: 10 }
tt { font-family: Monospaced }
ul li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
dir { margin-top: 10; margin-left: 40; margin-bottom: 10 }
pre p { margin-top: 0 }
th { border-color: Gray; border-style: solid; padding-left: 3; padding-bottom: 3; padding-right: 1; padding-top: 1 }
pre { font-family: Monospaced; margin-top: 5; margin-bottom: 5 }
td { border-color: Gray; border-style: inset; padding-left: 3; padding-bottom: 3; padding-right: 1; padding-top: 1 }
td p { padding-left: 2; padding-bottom: 3; padding-right: 2; margin-top: 0; padding-top: 3 }
code { font-size: small; font-family: Monospaced }
small { font-size: x-small }
big { font-size: x-large }
-->
</style>
</head>
<body>
<p style="margin-top: 0">
</p>
<table width="500" cellspacing="20" border="1">
<tr>
<td height="330" valign="top">
<table border="0">
<tr>
<td>
<font size="2">This is to certify that [[Client Name]], born
on [[Client Date of Birth]], of [[Client Residential
                Address]], was the holder of motor vehicle driver
licence number [[Client Licence Number]], first issued on
[[First Issue Date of Holding]] and expired on [[Holding
                Expiry Date]].<br></font>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="500" border="2">
<tr>
<td>
<table width="480" border="0">
<tr>
<td align="right">
<font size="2"><br>
<b>Fred Flintstone<br>Manager</b><br>Records Services Division<br>State
Police<br>An authorised person for the purposes of the
Road Act 1986</font>
</td>
</tr>
<tr>
<td align="left">
<font size="2"><b>User ID: wzvqv7<br>Dated: 29 November 2006</b>
</font>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

I have finally cracked it!!!!!!!!!!!!!!!!
The issue is definitely with Java Sun. "Uneven character spacing when printing JTextComponent"
It is raised on the http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6488219
And currently in OPEN state, and raised on 31 Oct 2006 and mentions it was caused by fix 4352983.
So where do we go from here. It's not good because I have tried all later version of the JVM and the issue is still there.
Why? Because it hasn't been fixed yet. Read the bug report above, as it gives more insight -- and mentions the workaround is NOT good for existing code.
So the way forward is to use an earlier version of the JVM 5.
I download the JVM version 1.5.0 (starting version) and works Ok... I would probably think version prior to 4352983 would be Ok too.
Please vote for this.... We have a workaround (use older version of the JVM).
So I am very happy.

Similar Messages

  • Combo box and Check box..help with code please?

    Here is my problem...i have a list of check boxes and according to which one is checked, i need combo boxes to populate different choices.
    as an easy example im only using 2 check boxes and two combo boxes.
    the check boxes are named Choice 1or2 with export values of 1 and 2
    the Combo Boxes are named List A and List B..
    both containing options that say you checked box 1 and you checked box 2
    any help would be greatly appreciated

    Implode wrote:
    "Help with code please."
    In the future, please use a meaningful subject. Given that you're posting here, it's kind of a given that you're looking for help with the code. The whole point of the subject is to give people a high level idea of what KIND of help with what KIND of code you need, so they can decide if they're interested and qualified to help.
    Exception in thread "main" java.lang.NumberFormatException: For input string: "fgg"
         at java.lang.NumberFormatException.forInputString(Unknown Source)
         at java.lang.Integer.parseInt(Unknown Source)
         at java.lang.Integer.parseInt(Unknown Source)
         at assignment1.Game.Start(Game.java:120)
         at assignment1.RunGame.main(RunGame.java:18)This error message is telling you exactly what's wrong. At line 120 of Game.java, in the Start method (which should start with lowercase "s" to follow conventions, by the way), you're calling Integer.parseInt, but "fgg" is not a valid int.

  • HT4199 I need help with getting my printer to print, PLEASE.

    I need help with getting my printer to print, Please.

    What have you done so far?
    I suggest you connect it via a usb  cable first.  Once you get the printer working, move to wifi.  You will have to use an existing printer usb cable or purchase a cable.  Be sure to get the correct cable.  Ask for help.
    The warrenty indicates there is phone support.  Give HP a call.
    Warranty
    One-year limited hardware warranty; 24-hour, 7 days a week phone support
    Robert

  • Help with code errors

    Can somebody help me get rid of the following compile errors:
    coreservlets/OrderPage.java:61: setNumOrdereed(int, int) in coreservlets.ShoppingCart
    cannont be applied to (java.lang.String,int)
    cart.setNumOrdered(recordingid, numItems);
    .\coreservlets\shoppingCart.java:44 cannot resolve symbol
    symbol : variable recordingid
    location: class coreservlets.ShoppingCart
    if (order.getrecordingid() == (recordingid)) {
    .\coreservlets\ShoppingCart.java:49: cannot resolve symbol
    symbol : variable recordingid
    location: class coreservlets.ShoppingCart
    itemOrder new order = new ItemOrder(Catalog.getItem(recordingid));I know that not very helpful with out the code but the code is very big so if anyone wants me to post extracts from the code please tell me.

    Thank you i put that code in but now get the following:
    coreservlets/OrderPage.java:40:  incompatible types
    found : java.lang.strgin
    required: int int recordingid = request.getParameter("recordingid")!=null?request.getParameter("recordingid"):1;
    ^/code]
    coreservlets/OrderPage.java:48: addItem(java.lang.String) in coreservlets.ShoppingCart cannot be applied to (int)
    cart.additem(recordingid);
    .\coreservlets\AhoppingCart.java:44: cannot resolve symbol
    symbol: variable recordingid
    location: class coreservlets.ShoppingCart
    if (order.getrecordingid() == (recordingid)) {
    .\coreservlets\AhoppingCart.java:49: cannot resolve symbol
    symbol: variable recordingid
    location: class coreservlets.ShoppingCart
    ItemOrder newOrder = new ItemOrder(Catalog.getItem(recordingid));
    4 errors.
    Also could you explain what the line you added to the code means:
    !=null?request.getParameter("recordingid"):1;
    !=null?request.getParameter("numItems"):"1";and how come you got rid of if (recordingid != null) {Thanks for any help with these errors
    OK I HAVE GOT RID OF ALL THE ERRORS APART FROM THE TOP ONE:
    code]coreservlets/OrderPage.java:40: incompatible types
    found : java.lang.strgin
    required: int
    int recordingid = request.getParameter("recordingid")!=null?request.getParameter("recordingid"):1;
                                            /code]
    Message was edited by:
            ajrobson                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Help with HP Laser Printer 1200se

    HP Support Line,
    Really need your assistance.  I have tried both contacting HP by phone (told they no longer support our printer via phone help), the tech told me that I needed to contact HP by e-mail for assistance.   I then sent an e-mail for assistance and got that reply today, the reply is as follows  "Randall, unfortunately, HP does not offer support via e-mail for your product.  However many resources are available on the HP web site that may provide the answer to your inquiry.  Support is also available via telephone.  A list of technical support numbers can be round at the following URL........."  The phone numbers listed are the ones I called and the ones that told me I needed to contact the e-mail support for help.
    So here I am looking for your help with my issue.
    We just bought a new HP Pavillion Slimline Desk Top PC (as our 6 year old HP Pavillion PC died on us).  We have 2 HP printers, one (an all-in-one type printer, used maily for copying and printing color, when needed) is connected and it is working fine with the exception of the scanning option (not supported by Windows 7).  However we use our Laser Printer for all of our regular prining needs.  This is the HP LaserPrinter 1200se, which is about 6 years old but works really well.  For this printer we currently only have a parallel connection type cord and there is not a parallel port on the Slimline HP PC.  The printer also has the option to connedt a USB cable (we do not currently have this type of cable).
    We posed the following two questions:
    1.  Is the Laser Jet 1200se compatible with Windows 7?
    and if this is the case
    2.  Can we purchase either a) a USC connection cord (generic or do we need a printer specific cord)? or b) is there there a printer cable converter adapater to attach to our parallel cable to convert to a USB connection?
    We do not want to purchase the USB cable if Windows 7 will not accept the connection, or if doing this will harm the PC.
    We really would appreciate any assitance that you might give us.
    Thank you,
    Randy and Leslie Gibson

    Sorry, both cannot be enabled by design.  That said, devices on a network do not care how others are connected.  You can print from a wireless connection to a wired (Ethernet) printer and v/v.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • Problem with NIReport.llb\Print HTML Report using IE.vi on different machines

    We have 5 machines here in our workgroup which have the same state regarding security patches and other system updates. We recently found out that there is a problem with the NIReport.llb\Print HTML Report using IE.vi on the different machines.
    If I would open the VI on MachineA the control could be loaded. If I would open the VI on MachineB the control could be loaded. If I would copy the VI from MachineB to MachineA and open the VI the control could not be loaded. If I would copy the VI from MachineA to MachineB and open the VI on MachineB the control could be loaded. MachineB could load the version from MachineA and MachineB but on MachineA only the own version will load. I have seen that both versions have the same GUID for the Microsoft Webbrowser but are different in some other aereas.
    Since printing HTML Reports is part of the application which will be distributed as application I want to know if someone else have seen such a behaviour or has got problems distributing an application.
    Also I want to know which additional information is stored in an Active-X container about the control beside the GUID.
    We have Win XP Prof SP2 with MS IE 6.0.2900.2180 on all machines in the workgroup.
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

    Hi Tom,
    this is the VI <vi.lib>\Utillitiy\NIReport.llb\Print HTML Report using IE.vi copied from a machine that can load and run the VI and it will print. On this machine the control in the VI is white.
    This VI will give the "Control could not be loaded" message on my machine.
    The file shdocvw.dll is 2006-10-23 16:18 size 1.460 KB and I verifyed that both machines have the same version of this file.
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions
    Attachments:
    Print HTML Report using IE.png ‏11 KB

  • Can you help with wireless usb printing?

    I have a D-Link router ([DI-824VUP) that works fine as far as geting online and printing to an ethernet printer,(HP1300n) wirelessly. I recently bought this router because it has a usb printer port, yet I can not get it to see the usb printer (Canon S830D). D-Link was no help, as they don't support Apple wireless printing, even though they do support wired printing via their router. QUESTION-any idea how to get powerbook to see the printer when connected to the router? Printer setup utility does not see it, only the HP. Thanks-bobbabe
    OS 10.3.9.
    Titanium Powerbook 667.   Mac OS X (10.3.9)   D-Link router(DI-824VUP)

    Because this forum software is so absolutely USELESS now, you don't get to see the whole of the question in this view. In the other (non-list) view it says:
    "can you help with a technical problem with the stereo imagery option ? it won't take out lead vocal in a stereo mp3"
    And the answer is that if you can't isolate the vocal in the stereo field, or it is one of these odd ones where it's used inverted polarity in different parts of the stereo signal for the same vocal, then you won't be able to. But without a sample, it's impossible to tell. If you can post a link to one, that might help. It has to be external to this site though - Adobe in their infinite wisdom don't allow the posting of audio files on their audio U2U forum. Helpful, that, isn't it?

  • Urgent-Need help with code for Master data enhancement

    hi Experts,
    I have appended YMFRGR field(Table MARC) to 0MAT_PLANT_ATTR datasource.
    The key fields in the MARC table are MATNR and WERKS.Can anybody help with the user exit to populate this field,as am pretty new to ABAP.
    Thanks in advance

    Hi,
    go through this link which has the similar problem:
    https://forums.sdn.sap.com/click.jspa?searchID=1331543&messageID=2794783
    hope it helps.
    Thanks,
    Amith

  • Help with new site index.html

    I'm new to website design/hosting/etc so I apologize for the newbie questions.  I'm using DW8
    I have a hobby site on a free host and have been using it for 2+ years without problems.  Recently I decided to re-design the website.  When I uploaded the new website in place of the old one the host kept saying that the file was not found.  So I re-loaded the old site and everything worked fine.  So just for kicks I uploaded the NEW index.html file in place of the old one, and again the website could not be found.
    So is there something actually wrong with my NEW index.html root file, or do I need to do something else in DW to upload a new site in place of an old one?  I have no idea what could be wrong with the new index file; I created it just like I did the old one.
    Thanks in advance, joel

    Before you upload next time click on Site->Advanced->FTP log.  See if you get any errors with that.
    If you are not and the files are uploading ok, you may need to get in touch with your host.  If something is not working on the account it could be something on their end, whether it be configuration errors or some other random occurrence. 

  • Checking Account and help with code ?

    Hi all..my computer hung up on me, so I'm not sure if my last post went through. First of all thank you all for helping me out the other day with my question on the Bank Account. It continues :)
    I'm trying to work on each class one by one..when I test my Checking Account, it isn't printing out the correct balance. The string method to print this is coming from the Withdrawal class...so I know it has to be somewhere in there but I can't seem to figure out why it isn't totalling the balance...or how to get it too.
    Then when I test my MyBank class, it hangs up on line 63..which I could swear I have written correctly. Again I am getting a NullPointerException and I honestly think I have the line of code written right, but I'm guessing I dont.
    Any help would be appreciated.
    public abstract class BankAccount {
        public static final String bankName = "BrianBank";
        protected String custName;
        protected String pin;
        protected Transaction[] history;
        private double balance;
        private double amt, amount;
        private double bal, initBal;
        private int transactions;
        private final int MAX_HISTORY = 100;
        private int acct;
        protected BankAccount(String cname, String cpin, double initBal) {
         custName = cname;
         pin = cpin;
         balance = initBal;
         history = new Transaction[MAX_HISTORY];
         transactions =0;
        public double getBalance() {
         return balance;
        public void withdraw(double amt) {
         history [transactions] = new Withdrawal (bal, amt);
       balance = bal;
         amount = amt;
         balance -= amt;
       transactions = transactions + 1;     
        public void deposit(double amt) {     
         history [transactions] = new Deposit (bal, amt);
         balance = bal;
         amount = amt;
         balance += amt;
         transactions = transactions +1;
        // abstract method to return account number
        public abstract int getAcctNum();
        // abstract method to return a summary of transactions as a string
        public abstract String getStatement();
    public class CheckingAccount extends BankAccount implements IncursFee
          private int transactions;
          private double balance, initBal, amt;
          private static final int NOFEE_WITHDRAWALS = 10;
          private static final double TRANSACTION_FEE = 5.00;
          public static final String bankName = "iBank";
          public static final int STARTING_ACCOUNT_NUMBER = 10000;
          private int checkingAccountNumber = STARTING_ACCOUNT_NUMBER;
          private static int accountNumberCounter = STARTING_ACCOUNT_NUMBER;
          private String custName;
          private String pin;
          public CheckingAccount (String cname, String cpin, double initBal)
             super (cname, cpin, initBal);
              custName = cname;
              pin = cpin;
             balance = initBal;
             accountNumberCounter++; 
             checkingAccountNumber = accountNumberCounter;
          //initialize a count of transactions
             transactions = 0;          
           public double getBalance()
             return balance;
           public void withdraw(double amt)
            super.withdraw (amt);
             transactions ++;
           public void deposit(double amt)
           super.deposit (amt);
             transactions ++;
           public int getAcctNum ()
             return checkingAccountNumber;     
           public String getStatement ()
             int i = 0;
             String output = "";
             while ( i < history.length && history[i] != null )
                output += history.toString () + "\n";
    i++;
    return output;     
    public void deductFee(double fee)
    if (transactions > NOFEE_WITHDRAWALS)
    {  fee = TRANSACTION_FEE *(transactions - NOFEE_WITHDRAWALS);
    super.withdraw(fee);
    balance -=fee;
    transactions = 0;
    public interface IncursFee {
    public abstract void deductFee(double fee);
    public abstract class Transaction {
    protected double initBal;
    protected double tranAmt;
    // constructor
    protected Transaction(double bal, double amt) {
         initBal = bal;
         tranAmt = amt;
    abstract public String toString();
    public class Withdrawal extends Transaction
         private double initBal;
         private double amount;
         private static NumberFormat fmt = NumberFormat.getCurrencyInstance();
         public Withdrawal (double bal, double amt)
              super (bal, amt);
              initBal = bal;
              amount = amt;
         public String toString ()
         return "Balance : " + fmt.format(initBal) + "\n" + "Withdrawal : " + fmt.format(amount);
    import java.text.NumberFormat;
    public class Deposit extends Transaction
         private double initbal, balance;
         private double amount;
         private static NumberFormat fmt = NumberFormat.getCurrencyInstance();
         public Deposit (double bal, double amt)
         super (bal, amt);
         initbal = bal;
         amount = amt;
         public String toString ()
         return "Balance : " + fmt.format(initbal) + "\n" + "Deposit : " + fmt.format(amount);
    public class TestCheckingAcct {
    public static void main(String[] args) {
         BankAccount b1 = new CheckingAccount("Harry", "1234", 500.0);
         System.out.println (b1.getBalance ());
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(50);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(10);
         b1.withdraw(1);
         System.out.println(b1.getStatement());
    // This interface specifies the functionality requirements of a bank
    public interface Bank {
    public abstract int openNewAccount(String customerName, String customerPIN, String accType, double initDepAmount);
    public abstract void processWithdrawal(int accNum, String pin, double amount);
    // executes a deposit on the specified acct by the amount
    public abstract void processDeposit(int accNum, String pin, double amount);
    // returns the balance of acct
    public abstract double processBalanceInquiry(int accNum, String pin);
    // returns summary of transactions
    public abstract String processStatementInquiry(int accNum, String pin);
    import java.util.ArrayList;
    public class MyBank implements Bank
    private ArrayList<BankAccount> savAccounts = new ArrayList<BankAccount>(); //dynamically grows
    private ArrayList<BankAccount> chkAccounts = new ArrayList<BankAccount>(); //dynamically grows
    private SavingsAccount sav;
    private CheckingAccount chk;
    private int accNum;
    private String customerName, customerPIN, accType, pin;
    private double initDepAmount, amount, balance;
    public int openNewAccount(String customerName, String customerPIN, String accType, double initDepAmount)
    this.customerName = customerName;
    this.customerPIN = customerPIN;
    this.accType = accType;
    this.initDepAmount = initDepAmount;
    if ( accType.equals("Savings"))
    BankAccount savAcct = new SavingsAccount(customerName, customerPIN, initDepAmount);
    try
    savAccounts.add(savAcct);
    catch (ArrayIndexOutOfBoundsException savAccounts)
    return savAcct.getAcctNum();
    else
    CheckingAccount chkAcct = new CheckingAccount(customerName, customerPIN, initDepAmount);
         try
    chkAccounts.add(chkAcct);
    catch (ArrayIndexOutOfBoundsException chkAccounts)
    return chkAcct.getAcctNum();
    public void processWithdrawal (int accNum, String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.withdraw (amount);
    if (accNum >50000 && accNum <60000)
         sav.withdraw (amount);
    public void processDeposit (int accNum, String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.deposit (amount);
    if (accNum >50000 && accNum <60000)
         sav.deposit (amount);
    public double processBalanceInquiry (int accNum, String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.balance = 0;
    if (accNum >10000 && accNum <20000)
         balance = chk.getBalance ();
    if (accNum >50000 && accNum <60000)
         balance = sav.getBalance ();
    return balance;
    public String processStatementInquiry(int accNum, String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.statement = "";
    if (accNum >10000 && accNum <20000)
    statement = chk.getStatement ();
    if (accNum >50000 && accNum <60000)
    statement= sav.getStatement ();
         return statement;

    Here's some quick code review:
    public abstract class BankAccount {
    public static final String bankName =
    me = "BrianBank";
    protected String custName;
    protected String pin;
    protected Transaction[] history;
    private double balance;
    private double amt, amount;
    private double bal, initBal;
    private int transactions;// make MAX_HISTORY private static final, too.
    private final int MAX_HISTORY = 100;
    private int acct;
    protected BankAccount(String cname, String cpin,
    pin, double initBal) {
         custName = cname;
         pin = cpin;
         balance = initBal;
         history = new Transaction[MAX_HISTORY];
         transactions =0;
    public double getBalance() {
         return balance;
    public void withdraw(double amt) {
         history [transactions] = new Withdrawal (bal, amt);
    balance = bal;
         amount = amt;
         balance -= amt;// ++transactions above would be elegant.
    transactions = transactions + 1;     
    public void deposit(double amt) {     
         history [transactions] = new Deposit (bal, amt);
         balance = bal;
         amount = amt;
         balance += amt;
         transactions = transactions +1;
    // abstract method to return account number// why abstract?
    public abstract int getAcctNum();
    // abstract method to return a summary of
    y of transactions as a string// why abstract?
    public abstract String getStatement();
    public class CheckingAccount extends BankAccount
    implements IncursFee
    private int transactions;
    private double balance, initBal, amt;
    private static final int NOFEE_WITHDRAWALS =
    WALS = 10;
    private static final double TRANSACTION_FEE =
    _FEE = 5.00;
    public static final String bankName = "iBank";
    public static final int STARTING_ACCOUNT_NUMBER
    NUMBER = 10000;
    private int checkingAccountNumber =
    mber = STARTING_ACCOUNT_NUMBER;
    private static int accountNumberCounter =
    nter = STARTING_ACCOUNT_NUMBER;// BankAccount has a custName attribute; why does CheckingAccount need
    // one if it extends BankAccount?
    private String custName;
    private String pin;
    public CheckingAccount (String cname, String
    String cpin, double initBal)
    super (cname, cpin, initBal);
    custName = cname;
    pin = cpin;
    balance = initBal;
    accountNumberCounter++;
    checkingAccountNumber =
    tNumber = accountNumberCounter;
    //initialize a count of transactions
    transactions = 0;          
    // same as BankAccount - why rewrite it?
    public double getBalance()
    return balance;
    // same as BankAccount - why rewrite it?
    public void withdraw(double amt)
    super.withdraw (amt);
    transactions ++;
    // same as BankAccount - why rewrite it?
    public void deposit(double amt)
    super.deposit (amt);
    transactions ++;
              // same as BankAccount - why rewrite it?
    public int getAcctNum ()
    return checkingAccountNumber;     
    public String getStatement ()
    int i = 0;
    String output = "";
    while ( i < history.length && history[i] !=
    ory[i] != null )
    output += history.toString () + "\n";
    i++;
    return output;     
    public void deductFee(double fee)
    if (transactions > NOFEE_WITHDRAWALS)
    {  fee = TRANSACTION_FEE *(transactions -
    ansactions - NOFEE_WITHDRAWALS);
    super.withdraw(fee);
    balance -=fee;
    transactions = 0;
    public interface IncursFee {
    public abstract void deductFee(double fee);
    public abstract class Transaction {
    protected double initBal;
    protected double tranAmt;
    // constructor
    // why protected? make it public.
    protected Transaction(double bal, double amt) {
         initBal = bal;
         tranAmt = amt;
    abstract public String toString();
    public class Withdrawal extends Transaction
         private double initBal;
         private double amount;
    private static NumberFormat fmt =
    = NumberFormat.getCurrencyInstance();
         public Withdrawal (double bal, double amt)
              super (bal, amt);
              initBal = bal;
              amount = amt;
         public String toString ()
    return "Balance : " + fmt.format(initBal) + "\n" +
    + "Withdrawal : " + fmt.format(amount);
    import java.text.NumberFormat;
    public class Deposit extends Transaction
         private double initbal, balance;
         private double amount;
    private static NumberFormat fmt =
    = NumberFormat.getCurrencyInstance();
         public Deposit (double bal, double amt)
         super (bal, amt);
         initbal = bal;
         amount = amt;
         public String toString ()
    return "Balance : " + fmt.format(initbal) + "\n" +
    + "Deposit : " + fmt.format(amount);
    public class TestCheckingAcct {
    public static void main(String[] args) {
    BankAccount b1 = new CheckingAccount("Harry",
    , "1234", 500.0);
         System.out.println (b1.getBalance ());
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(50);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(10);
         b1.withdraw(1);
         System.out.println(b1.getStatement());
    // This interface specifies the functionality
    requirements of a bank
    public interface Bank {
    public abstract int openNewAccount(String
    String customerName, String customerPIN, String
    accType, double initDepAmount);
    public abstract void processWithdrawal(int
    (int accNum, String pin, double amount);
    // executes a deposit on the specified acct by
    t by the amount
    public abstract void processDeposit(int accNum,
    Num, String pin, double amount);
    // returns the balance of acct
    public abstract double processBalanceInquiry(int
    (int accNum, String pin);
    // returns summary of transactions
    public abstract String
    ring processStatementInquiry(int accNum, String
    pin);
    import java.util.ArrayList;
    public class MyBank implements Bank
    private ArrayList<BankAccount> savAccounts =
    unts = new ArrayList<BankAccount>(); //dynamically
    grows
    private ArrayList<BankAccount> chkAccounts =
    unts = new ArrayList<BankAccount>(); //dynamically
    grows
    private SavingsAccount sav;
    private CheckingAccount chk;
    private int accNum;
    private String customerName, customerPIN,
    erPIN, accType, pin;
    private double initDepAmount, amount, balance;
    public int openNewAccount(String customerName,
    erName, String customerPIN, String accType, double
    initDepAmount)
    this.customerName = customerName;
    this.customerPIN = customerPIN;
    this.accType = accType;
    this.initDepAmount = initDepAmount;
    if ( accType.equals("Savings"))
    BankAccount savAcct = new
    vAcct = new SavingsAccount(customerName, customerPIN,
    initDepAmount);
    try
    savAccounts.add(savAcct);
    catch (ArrayIndexOutOfBoundsException
    Exception savAccounts)
    return savAcct.getAcctNum();
    else
    CheckingAccount chkAcct = new
    hkAcct = new CheckingAccount(customerName,
    customerPIN, initDepAmount);
         try
    chkAccounts.add(chkAcct);
    catch (ArrayIndexOutOfBoundsException
    Exception chkAccounts)
    return chkAcct.getAcctNum();
    public void processWithdrawal (int accNum,
    accNum, String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.withdraw (amount);
    if (accNum >50000 && accNum <60000)
         sav.withdraw (amount);
    public void processDeposit (int accNum, String
    String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.deposit (amount);
    if (accNum >50000 && accNum <60000)
         sav.deposit (amount);
    public double processBalanceInquiry (int accNum,
    String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.balance = 0;
    if (accNum >10000 && accNum <20000)
         balance = chk.getBalance ();
    if (accNum >50000 && accNum <60000)
         balance = sav.getBalance ();
    return balance;
    public String processStatementInquiry(int accNum,
    m, String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.statement = "";
    if (accNum >10000 && accNum <20000)
    statement = chk.getStatement ();
    if (accNum >50000 && accNum <60000)
    statement= sav.getStatement ();
         return statement;
    Very bad style with those brace placements. Pick a style and stick with it. Consistency is the key.
    Your code isn't very readable.
    You don't have a SavingsAccount here anywhere, even though your MyBank uses one.
    You use JDK 1.5 generics yet you've got ArrayList as the static type on those declarations. Better to use the interface type List as the compile time type on the LHS.
    You have a lot of compile time problems, and some incomprehensible stuff, but I was able to change it enough to my TestCheckingAcct run to completion. No NPE exceptions.
    I'm not sure I agree with your design.
    No SavingsAccount. The accounts I have ALL incur fees - no need for a special interface there. Savings accounts are usually interest bearing. That's the way they behave differently from checking accounts. Where do you have that?
    You rewrite too much code. If you put behavior in the abstract BankingAccount class (a good idea), the whole idea is that concrete classes that extend BankingAccount don't need to overload any methods whose default behavior is correct for them.
    I don't know that I'd have separate Deposit and Withdrawal to implement Transaction. I'd make Transaction concrete and have starting balance, ending balance, and a transaction type String (e.g., "DEPOSIT", "WITHDRAWAL")
    It'd be good to see some thought put into exception handling. I don't see an OverdrawnException anywhere. Seems appropriate.
    No transfer methods from one account to another. I often do that with my bank.
    That's enough to get started.

  • Please help with newline non-printing character in JTextPane.

    Hi.
    I need to implement "View non-printing characters" feature in my JTextPane.
    So when this feature is toggled, the newline character is displayed at the end of every line like in Microsot Word editor.
    I been digging around for few hours now and I cant find a solution for this.
    Please help me with any tips guys.

    StanislavL:
    ok i digged around and i found code example... i got my code to show "X" at the end of every line as a newline character. here is code I used:
    import javax.swing.text.StyledEditorKit;
    import javax.swing.text.ViewFactory;
    import javax.swing.text.Element;
    import javax.swing.text.View;
    import javax.swing.text.AbstractDocument;
    import javax.swing.text.LabelView;
    import javax.swing.text.IconView;
    import javax.swing.text.StyleConstants;
    import javax.swing.text.ComponentView;
    import javax.swing.text.BoxView;
    import java.awt.Graphics;
    import java.awt.Shape;
    import java.awt.Rectangle;
    class MyEditorKit extends StyledEditorKit
         public ViewFactory getViewFactory()
              return new MyRTFViewFactory();
    class MyRTFViewFactory implements ViewFactory
         public View create(Element elem)
              String kind = elem.getName();
              if (kind != null)
                   if (kind.equals(AbstractDocument.ContentElementName)) {
              return new LabelView(elem);
                   } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
    //              return new ParagraphView(elem);
                        return new MyParagraphView(elem);
                   } else if (kind.equals(AbstractDocument.SectionElementName)) {
    //              return new BoxView(elem, View.Y_AXIS);
                        return new MySectionView(elem, View.Y_AXIS);
                   } else if (kind.equals(StyleConstants.ComponentElementName)) {
                        return new ComponentView(elem);
                   } else if (kind.equals(StyleConstants.IconElementName)) {
                        return new IconView(elem);
                   // default to text display
                   return new LabelView(elem);
    class MySectionView extends BoxView {
         public MySectionView(Element e, int axis)
              super(e,axis);
         public void paintChild(Graphics g,Rectangle r,int n) {
              if (n>0) {
                   MyParagraphView child=(MyParagraphView)this.getView(n-1);
                   int shift=child.shift+child.childCount;
                   MyParagraphView current=(MyParagraphView)this.getView(n);
                   current.shift=shift;
              super.paintChild(g,r,n);
    class MyParagraphView extends javax.swing.text.ParagraphView
         public int childCount;
         public int shift=0;
         public MyParagraphView(Element e)
              super(e);
              short top=0;
              short left=20;
              short bottom=0;
              short right=0;
              this.setInsets(top,left,bottom,right);
         public void paint(Graphics g, Shape a)
              childCount=this.getViewCount();
              super.paint (g,a);
              int rowCountInThisParagraph=this.getViewCount(); //<----- YOU HAVE REAL ROW COUNT FOR ONE PARAGRAPH}
              System.err.println(rowCountInThisParagraph);
         public void paintChild(Graphics g,Rectangle r,int n) {
              super.paintChild(g,r,n);
              //g.drawString(Integer.toString(shift+n+1),r.x-20,r.y+r.height-3); // line number
              g.drawString("X",r.x+r.width,r.y+r.height-3);
    }this line here draws "X":
    g.drawString("X",r.x+r.width,r.y+r.height-3);How would I modify this to draw a small picture there?
    Thanx a lot.

  • SSL - Default SSL context init failed: null - need help with code

    Hi!
    Once Again I have problems with SSL.
    I read something about SSL here:
    http://www.javaalmanac.com/egs/javax.net.ssl/Server.html
    Now I tried to test this stuff, that resulted in this program (I simply tried to put the SSL stuff from the above code in a small skeleton):
    import java.io.*;
    import java.net.*;
    import java.security.*;
    import javax.net.ssl.*;
    import javax.net.*;
    public class MyServer
         public static void main(String arguments[])
         try
              int port = 443;
              ServerSocketFactory ssocketFactory = SSLServerSocketFactory.getDefault();
              ServerSocket ssocket = ssocketFactory.createServerSocket(port);
              // Listen for connections
              Socket socket = ssocket.accept();
              System.out.println("Connected successfully");
              // Create streams to securely send and receive data to the client
              InputStream in = socket.getInputStream();
              OutputStream out = socket.getOutputStream();
              // Read from in and write to out...
              // Close the socket
              in.close();
              out.close();
         catch(IOException e)
              System.out.println("GetMessage() = "+e.getMessage());
              e.printStackTrace();
    }     Now I compiled this stuff with : 'javac MyServer.java' - there were no errors. After this I run the program
    with the following command (also taken from java almanac):
    'java -Djavax.net.ssl.keyStore=mySrvKeystore -Djavax.net.ssl.keyStorePassword=123456 MyServer'
    But if I run it, it reports:
    "GetMessage() = Default SSL context init failed: null
    java.net.SocketException: Default SSL context init failed: null
    at javax.net.ssl.DefaultSSLServerSocketFactory.createServerSocket(Dasho
    6275)
    at MyServer.main(MyServer.java:15)"
    createServerSocket() seems to be the wrong line, but what is wrong with it.
    Is there any mistake in my code ?
    Btw. I created my keystore etc. according to the instructions at
    http://forum.java.sun.com/thread.jsp?forum=2&thread=528092&tstart=0&trange=15
    Any help appreciated
    Greets
    dancing_coder

    I got this error last week.
    The problem was that the keystore I was pointing to, was in other location, so it could not initialize the default context.
    I had defined ...
    String CLIENT_CERTIFPATH = getParam("client.certificate.path", "/users/pridas/myKeystoreFile");
    // getParam extracts the location of the keystore from a text file which contains some configuration parameters. The default value will be /users/pridas/myKeystoreFile
    In my case, I will try to develop a secure SOAP conexion using certificates.
    Before to try the conexion, I defined ...
    System.setProperty("javax.net.ssl.trustStore", CLIENT_CERTIFPATH);
    System.setProperty("javax.net.ssl.keyStore", CLIENT_CERTIFPATH);
    ... and the problem when I got this error ... the keystore file was not in the correct location.
    That was how I resolved this error.
    I hope everybody will be oriented about this kind of errors.
    Salu2.

  • Borderless Window help with code please!

    I am using Dreamweaver MX 2004.
    I just cannot get my head round this Java code and would really appreciate some help or direction!
    I want to make a nice little window to show a few lines of text, with a close button or X in the corner (not fussed). I have looked at lots of tutorials and produced numerous codes to use.
    OK, fine I get that bit. My problem comes with placing the codes in the right places. I paste the HEAD portion in the head of the doc. The BODY in the body. BUT is this the doc I am going to call up with my few lines of text in, or the doc I am going to call from? Get what I mean? Also I want to call from a link and haven't had much luck with the line of code I put in the link box. I have tried lots ways and have just managed to confuse myself.
    I am not asking for someone to do it for me and believe me I have tried to work this out for myself but it's not happening for me. Please can someone explain this to me in very plain English as I am obviously some sort of delinquent!
    Thank you

    Yes I am using HTML and Javascript. So Java and Javascript are not the same thing? Right ,OK ,well that has taught me something. Don't suppose you can help me with script on this forum then. Sorry!

  • Help with email content type HTML

    Hi,
    Following is my control file code for sending the email message (just putting the delivery part, and not the while content from control file):
    <xapi:delivery>
    <xapi:email server="${DCRD_SMTP_HOST}" port="${DCRD_SMTP_PORT}"
    from="${CP_DCRD_ADMIN_EMAIL}"
         reply-to="${CP_DCRD_ADMIN_EMAIL}">
    <!-- Set the id for the delivery method -->
    <xapi:message id="123" to="${CF_DCRD_CONTACT_EMAIL}" cc="${CP_DCRD_ADMIN_EMAIL}" bcc="[email protected], [email protected]" attachment="true" content-type="html"
    subject="Datacard Maintenance Agreement Number ${CONTRACT_NUMBER} ">${CF_FINAL_EMAIL_CONTENT}
    </xapi:message>
    </xapi:email>
    </xapi:delivery>
    The formula column CF_FINAL_EMAIL_CONTENT get populated with some html content based on condition. Now, when I get the email, the text from the formula column get printed as is.......with tags and all. It's like I had unformatted plain text email. I need the content to be formatted and I need different content based on a condition. Has anyone done this before?
    Appreciate any help on this.
    Thanks,
    Alka

    I finally could fix the issue by still using a formula column to store the html text and using the following in my control file (in bold):
    <xapi:message id="123" to="${CF_DCRD_CONTACT_EMAIL}" cc="${CP_DCRD_ADMIN_EMAIL}" bcc="[email protected], [email protected]" attachment="true" content-type="text/html"
    subject="Datacard Maintenance Agreement Number ${CONTRACT_NUMBER} "> *<content><![CDATA[${CF_FINAL_EMAIL_CONTENT}]]></content>*
    </xapi:message>
    Hope this would help someone clueless like me :-)
    Alka

  • Print HTML from Java

    Hello All,
    can anyone please provide example code of how to print an html-file from localhost by Java-code ?
    Thanx a lot !!

    Not sure what you are asking. You've mentioned several different things.
    One is printing - do you mean to put something on paper? There should be examples on how to print a file if you do a search.
    The other is 'from localhost' - this implies a socket to connect to 127.0.0.1 - Does your code connect to an HTTP server, issue a HTTP GET for an HTML page?
    Again there should be sample code for connecting to a server and reading the response if you do a search.

Maybe you are looking for