Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37372

Re: how to convert html?

From Knute Johnson <nospam@rabbitbrush.frazmtn.com>
Newsgroups comp.lang.java.programmer
Subject Re: how to convert html?
Date 2017-08-31 14:52 -0500
Organization A noiseless patient Spider
Message-ID <oo9p5k$4c5$1@dont-email.me> (permalink)
References (5 earlier) <0df9b410-65f7-4064-8748-f35691ef7355@googlegroups.com> <804837be-8404-48df-8f3c-b6a1672e3a3a@googlegroups.com> <8a035a47-e940-4153-b595-c3a65da887ec@googlegroups.com> <oo9job$hnv$1@dont-email.me> <c20a9a60-2ac5-4332-bd53-d578957d7d00@googlegroups.com>

Show all headers | View raw


On 8/31/2017 13:49, Eric Douglas wrote:
> On Thursday, August 31, 2017 at 2:20:20 PM UTC-4, Knute Johnson wrote:
>> It is really unclear what you are trying to do.  You don't want to print
>> the text from a JToolTip or you do?  You want to use css styles with a
>> JToolTip, that works just fine.  What is it that you are really trying
>> to do?  A JLabel will display HTML text too.
>>
>> -- 
>>
>> Knute Johnson
> 
> Yes, I have a custom JTree with a custom print class which dynamically creates reports.  I set up a tree report class to turn any custom tree into a report.  This prints the icon and text of every node with indents.  Now I'm printing the node tooltips.
> 
> So I discovered they're using BasicHTML.createHTMLView to paint a JToolTip if it has <html> in it. (I don't know if they're specifically looking for that tag or how they know it's html) If there's no html it does a straight up drawString.
> 
> So I have a JToolTip called jt and I want to set the font I call jt.setFont() updates how it draws that plain string.  Then to update the html font I call BasicHTML.updateRenderer(jt,jt.getTipText()), and to get the html to properly use the font I had to put a static initializer on my class to call new HTMLEditorKit().setStyleSheet(new StyleSheet());.  To update the plain text background I can call jt.setBackground(Color.blue), but to update the html background I call new HTMLEditorKit().getStyleSheet().addRule("body {background:blue}").
> 
> The dynamic report object does everything.  It uses standard fixed width font embedded in the jar so I can dynamically specify how many character to print across the page and specify where to print text anywhere on the page by column/row.  It puts that information in a serializable object I can use repeatedly, to draw on a printer's graphics, draw a PDF using iText graphics, or draw on the screen using a JPanel in a JScrollPane in a JFrame.
> 
> Anyway the consistent display was tricky because JToolTip renders plain string different than html string, some tooltips have html some don't, and the html/css doesn't seem clearly documented.
> 

In that case I think I would be tempted to only use HTML in the 
JToolTips and then they will all render the same.  You can put the CSS 
styles in the HTML if you want and skip all the HTMLEditorKit and 
StyleSheet stuff.

The CSS version is quite old and limited in Swing and I don't know that 
it will ever be updated.  I love Swing but it is showing its age.

I'm curious though have you figured out a way to get at the actual 
JToolTip from a JComponent?

-- 

Knute Johnson

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

how to convert html? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-30 07:03 -0700
  Re: how to convert html? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-08-30 10:59 -0500
    Re: how to convert html? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-30 11:41 -0700
      Re: how to convert html? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-08-30 14:52 -0500
        Re: how to convert html? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-30 14:00 -0700
          Re: how to convert html? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-31 05:47 -0700
            Re: how to convert html? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-31 05:56 -0700
              Re: how to convert html? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-31 07:12 -0700
                Re: how to convert html? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-08-31 13:20 -0500
                Re: how to convert html? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-31 11:49 -0700
                Re: how to convert html? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-08-31 14:52 -0500
                Re: how to convert html? Eric Douglas <e.d.programmer@gmail.com> - 2017-08-31 13:37 -0700

csiph-web