Problem with HTML in a JLabel

Is it possible to use styles when using HTML in a JLabel?
Example:
<html><hr style="height: 1px; color: black;"></html>Doesn't work correctly as this should give a solid 1px high hr, but doesn't. Instead it gives a black hr with a white shade...
The JLabel it is used in is not customized in any way.

I too am interested in getting color on an HR to work. Can you summarize what you have done to date? Sample code?
Note: An easy way to correct it in a Nonframe instance of html is to subclass HTMLEditor to implement your own ViewFactory and own HRuleView which checks the attribute tag color for the color. I've got this to work, but frames don't work since you can call FrameView (not public) and thus have to use the super class - which then by-passes the ViewFactory from then on.
So a NON-FRAME Solution to give HR color is... Anybody have a better global solution?
Here is the one line fix to HRuleView .setProperties. So if you subclass HRuleView specifically to do
public class MyHTMLEditorKit extends HTMLEditorKit { // StyledEditorKit
    private static final ViewFactory defaultFactory = new MyHTMLFactory();
    public static class MyHTMLFactory extends HTMLFactory {//implements ViewFactory {
         public View create(Element elem) {
         Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
         if (o instanceof HTML.Tag) {
          HTML.Tag kind = (HTML.Tag) o;
          if (kind == HTML.Tag.HR) {
              return new MyHRuleView(elem);
       return super.create(elem);
class MyHRuleView extends View  {
     private Color color = null;
     public void setPropertiesFromAttributes() {
          super.setPropertiesFromAttributes();
          try {color = new Color(Integer.decode((String)attr.getAttribute("color")).intValue());} catch (Exception e) {}
     public void paint(Graphics g, Shape a) {
          if (color != null) g.setColor(color);
          super.paint(g, a);
}

Similar Messages

  • Problem with HTML viewer

    Dear All ,
    I am facing a problem with HTML Viewer . My senario is as follows :
    1. I have created one HTML page . On that page there are 4 Images
    2. I imported that HTML page in SAP with the help of transaction SMW0
    3. I Called that HTML page in my ABAP program using the method "load_html_document" of class cl_gui_html_viewer
    4. This is happening perfectly ok on the machine on which all this developement was done.
    But the issue is when I execute my ABAP program on a different machine , those Images on that HTML page are not displaying.
    Can you please guide me how to remove that machine dependancy?
    Regards,
    Nikhil

    Hi Nikhil,
    Please check if the image is properly imported properly. Also check if there is any option which you might have forgotten while imported like dependeency.
    Regards
    Abhii...

  • Problems with html content in box

    Hi! I have a problem with html content. For example photoswipe. If I import the folder with the index.html of photoswipe as an article all works fine. If I link it trough the folio overlay creator/webcontent) into a box in indesign dps, it stays empty. Seems like it doesnt find the images/paths??
    Klaus

    This sounds familiar. PhotoSwipe doesn't seem to like working in a web content overlay unless the JavaScript and other source files are uploaded within HTMLResources. This means editing your local HTML file so that paths to the JavaScript, images and CSS files begin by pointing to HTMLResources virtual folder (../../../HTMLResources/) before their subfolder and filenames. It's worth a try.

  • Problem with HTML in a read only textarea item

    I'm working on a messaging system for our site. For the body of the message, we use a standard textarea item. However, if we come to the messaging page from a certain page in our system, then we pre-load the textarea item, and make it read only. The only problem with this is that there are HTML tags in the body that we try to pre-load. This is causing problems because they aren't being interpreted as tags, but are being displayed as text. If I make the textarea editable, then everything looks fine, it's just when I set the area to be read only that it doesn't work. Any thoughts on how to fix this? Thanks!

    Not always. A user is allowed to edit that area in most circumstances except for when the user arrives at the page coming from 1 page in particular. In this case, then the field is read-only. At all other times though, it is editable.
    As a workaround, whenever I know I'm coming from this page, I set a variable, and if the variable is set, then I use a Display Only item and then hide the Textarea. If the variable is not set, then I hide my Display Only item and show the Textarea. Not very elegant, but it works.

  • Problem with HTML email formatting

    I'm using Firefox 4.0.1. I have a job function that requires me to use web page based email. When responding to emails, Firefox automatically places the cursor at the bottom of the chain as opposed to the top of the chain as in previous versions. I need for the response to start at the top of the page. This is the way it worked in my previous version of Firefox and no settings in the email program have been changed. In fact there is no setting in that program to specify where the response will go. I'm assuming the cursor placement is being determined by Firefox. Please help me change it.

    Oooops forgot the link
    http://www.adlerhealth.com/ad122607/ad122607.htm
    "Ken Binney" <[email protected]> wrote
    in message
    news:fljkp6$9kc$[email protected]..
    > Look at this HTML email.
    > The email message is only about 7.5kb because all it's
    images are on a
    > webserver.
    >
    >
    >
    >
    > "[email protected]" <[email protected]>
    wrote in message
    > news:flj9fg$qrg$[email protected]..
    >> I've made a few email newsletters, but the problem
    that I have is that I
    >> can't
    >> use a lot of images because when the email is sent
    it has a large file
    >> size.
    >> The images themselves are very big files, like under
    10 kb, is there
    >> anyway to
    >> add multiple images to an email while still keeping
    the file size down.
    >> Also I
    >> have a problem with the formatting of the email.
    When the html is placed
    >> into
    >> an email the spacing isn't right, it usually is the
    images that I have
    >> problems
    >> with. If this is any help I make the newsletters out
    of tables. I'd
    >> appreciate any tips you can think of.
    >>
    >
    >

  • Problems with HTML in 11g

    Got 11g up and running without too much difficulty (Win2003) but I'm having trouble getting HTML content to render. For example, create a simple analysis, add a narrative view, check the "Contains HTML Markup" button, and put HTML in there, but it comes out escaped anyway?
    I couldn't find much mention of this in the docs, other than the usual about XSS hardening. I verified that I have the "Save Actions containing embedded HTML" and "Save Content with HTML Markup" privileges - just to make sure, I even granted them to AuthenticatedUsers.
    Any ideas?

    Hi All,
    It seems like this problem is specific to the "Narrative View". If I try the following in the "Static View" it works like expected;
    <hr size="15" width="100%" shade align="right">
    In the "Narrative View" I did not get it to work yet.
    Cheers,
    Daan Bakboord
    http://obibb.wordpress.com

  • JavaHelp: problem with HTML size

    Hi guys,
    I converted a MS Word document to HTML and I'd like to display it using JavaHelp. The HTML file size is about 800k. It does work, but it takes a few minutes to be displayed!!!
    I tried with HTML files with size of about 100k and it works better (it takes a few seconds).
    Where is the problem? Is the HTML size? Or is MS Word that doesn't work so well?
    Thanks a lot for your answers!
    Paul.

    MS Word produces fat ugly HTML.

  • Are ther any Problems with HTML in iOS 6?

    We are having a problem with animated HTML-Objects in Adobe DPS. It's seems to be related with the iOS 6 update. We have two iPads, one with the updated software (iOS 6) and the other without it (iOS 5). Both of these have been updated with the new Adobe Content Viewer. The one with the old iOS works perfectly (HTML, Edge Animation, Videos) but the other with the most-up-to-date software does not. The HTML doesn't play and some times plays it once. We even tried by adding it to the HTMLResource folder to be trigger by a button to open a new window by itself, but no joy. Again we don’t have any of these problems on the iPad without the current software update. They all work perfectly

    All the HTML content on my iOS 6 devices renders fine.
    What does a web page from a non-Adobe DPS site look like?
    From your description, it's a problem with the Adobe software.
    Contact them.

  • Problem with HTML form on Android

    Hello,
    we are experiencing problems with quite simple HTML/Javascript form included in Adobe DPS publication on Android. It's working on iPad without problem, it's working on standard Android Chrome viewer, but when included in DPS publication, we can't write anything in the form.
    Does somebody encountered same problem and found solution? seems that this problem appeared on some newer version of Android, circa 4.3.
    Thanks
    Martin

    Hi, there, a couple of things to double check on your emulator settings:
    When configuring the Android emulator, please make sure the emulator emulates ARM Processor (armeabi - v7).  ADF Mobile only works with ARM processors - both device and emulator.
    Under Memory Options, please ensure RAM is at least 768 or greater.  This of course is also constraint by the amount of memory your development machine has, but generally you should have at least 768 MB allocated.  ADF Mobile app itself won't take up nearly that much RAM of course, but there are a lot of Android apps that are started in the background when Android emulator starts.
    Also, make sure there is 500 MB of internal storage configured - you can go as low as 200 MB but the space will quickly.
    Lastly, before you compile/deploy again, please go to JDeveloper menu item Build - Clean All to clean up any left over deployment artifacts.
    Thanks,
    Joe Huang

  • Problem with html:select or html:options tags using struts,jsp and tomcat

    Hi
    I'm updating a Struts-Project to a new layout and therefore rework all jsp Sites.
    I'm also using a new Folder-Structure and update therefore my struts-config file.
    My Problem now is:
    Till now, we had a select-field with a code like this:
    < html:form action="/timetableAction" method="POST">
    < table width="53%" border="0">
    < tr>
    < td>< html:radio property="dauer" value="semester"
    /></ td>
    < html:select property="semester" size="1">
    < htmlptions name="semesterList" />
    </ html:select>
    </ html:form>
    The problem now is, that whenever I use any <html:xy> tag, the tomcat server I use can not show the page, he shows just the headers of the template, but not the
    content.-jsp-File where the form would be in. He stops right in the middle of the html page, when he notices the <html:xy> tags.
    And the funny thing is, that he has no problem to show a page when there is a <html:errors> within it? Why could this be? the struts-html.tld File is well included and teh Tomcat Server shows no exceptions.
    Waiting for you answers and thanks

    Thank you, I already got the answer in another forum

  • Problems with Html in Report in different browsers

    Hi all!
    I4m doin4a Sql query Report with it will be used as a menu with linked option with htp.anchor and in the display html options I use html to create an style that shows the lines in white and not underlined, it works ok, but only in Iexplorer, in Netscape is shows me not underlined, but colored blue
    I4m going insane
    Any help will be appreciated, (better as faster as possible ;P )
    Thks all
    Chema

    Hi All,
    It seems like this problem is specific to the "Narrative View". If I try the following in the "Static View" it works like expected;
    <hr size="15" width="100%" shade align="right">
    In the "Narrative View" I did not get it to work yet.
    Cheers,
    Daan Bakboord
    http://obibb.wordpress.com

  • Problems with html code for video

    Hello
    I followed this instructions to add my video:
    - Upload the files in Muse < Add Files for upload ( These would add the files to your assets )
    - Object > Insert HTML :
    <video width="320" height="240" controls>
    <source src="assets/video.mp4"/>
    </video>"
    My actual code is:
    <video width="720" height="576" controls>
    <source src="assets/Gelo.mp4"/>
    </video>
    And here's the problem when I preview:
    Can someone help? What's wrong?
    Thank you

    Hi
    Please check if the files are correctly added to your site, also the format should be supported by browser so you can check with different video formats.
    Thanks,
    Sanjit

  • Problem with findComponentAt highlighting wrong JLabel

    I've got a small 6 by 7 grid of jlabels that I would like to turn red if clicked on. In the japplet shown below, this works, sort of: it turns the label to its left red but not the label under the mouse. Any ideas on what I'm doing wrong? Thanks!
    MyApplet.java
    import javax.swing.JApplet;
    public class MyApplet extends JApplet
        MyPane2 pane = new MyPane2();
        public void init()
            getContentPane().add(pane);
    }MyPane2.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class MyPane2 extends JPanel implements MouseListener
        private static final int MAX_ROW = 6;
        private static final int MAX_COL = 7;
        private String whiteDot = ".\\petes\\brief3\\whiteDot.jpg";
        private String redDot = ".\\petes\\brief3\\redDot.jpg";
        private JLabel[][] myLabelGrid;
        private JPanel gridPane = new JPanel();
        public MyPane2()
            super();
            add(createLabelGridPane());
        private JPanel createLabelGridPane()
            gridPane = new JPanel();
            GridLayout myGridLO = new GridLayout(MAX_ROW, MAX_COL);
            myGridLO.setHgap(5);
            myGridLO.setVgap(5);
            gridPane.setLayout(myGridLO);
            gridPane.addMouseListener(this);
            myLabelGrid = new JLabel[MAX_COL][MAX_ROW];
            for (int row = 0; row < MAX_ROW; row++)
                for (int col = 0; col < MAX_COL; col++)
                    //myLabelGrid[col][row] = new JLabel(new ImageIcon(whiteDot));
                    myLabelGrid[col][row] = new JLabel("W");
                    gridPane.add(myLabelGrid[col][row]);
            return gridPane;
        public void mouseClicked(MouseEvent me)
            JPanel myPanel = (JPanel)me.getSource();
            System.out.println(findComponentAt(me.getX(), me.getY()));
            Component myComponent = findComponentAt(me.getX(), me.getY());
            if (myComponent instanceof JLabel)
                //((JLabel)myComponent).setIcon(new ImageIcon(redDot));
                ((JLabel)myComponent).setText("R");
            repaint();
        public void mouseEntered(MouseEvent arg0){}
        public void mouseExited(MouseEvent arg0){}
        public void mousePressed(MouseEvent arg0){}
        public void mouseReleased(MouseEvent arg0){}
    }[edited to use a label with "W" or "R" rather than images]
    Message was edited by:
    petes1234

    //  <applet code="FindComponentApplet" width="400" height="400"></applet>
    //      No html file necessary, just type
    //  appletviewer FindComponentApplet.java
    //      at the prompt and press enter.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class FindComponentApplet extends JApplet
        public void init()
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(new FindComponentPane());
    class FindComponentPane extends JPanel implements MouseListener
        private static final int MAX_ROW = 6;
        private static final int MAX_COL = 7;
        Component lastSelected;
        public FindComponentPane()
            super(new BorderLayout());
            add(createLabelGridPane());
        private JPanel createLabelGridPane()
            JPanel gridPane = new JPanel(new GridLayout(MAX_ROW, MAX_COL, 5, 5));
            gridPane.addMouseListener(this);
            JLabel[][] myLabelGrid = new JLabel[MAX_COL][MAX_ROW];
            for (int row = 0; row < MAX_ROW; row++)
                for (int col = 0; col < MAX_COL; col++)
                    JLabel label = new JLabel("W", JLabel.CENTER);
                    label.setBorder(BorderFactory.createEtchedBorder());
                    myLabelGrid[col][row] = label;
                    gridPane.add(myLabelGrid[col][row]);
            return gridPane;
        public void mouseClicked(MouseEvent me)
            JPanel panel = (JPanel)me.getSource();
            Component component = panel.findComponentAt(me.getX(), me.getY());
            System.out.println(component.getClass().getName());
            if (component instanceof JLabel)
                if(lastSelected != null)
                    ((JLabel)lastSelected).setForeground(Color.black);
                ((JLabel)component).setForeground(Color.red);
                // Since there are gaps among the labels we need this in here.
                lastSelected = component;
            repaint();
        public void mouseEntered(MouseEvent arg0){}
        public void mouseExited(MouseEvent arg0){}
        public void mousePressed(MouseEvent arg0){}
        public void mouseReleased(MouseEvent arg0){}
    }

  • Javascript problem with HTML embed

    I'm migrating a large existing site from Sitegrinder to Muse after converting several smaller sites without problem. Unfortunately this site has a javascript button that doesn't work at all. The button was created with the Object/Embed HTML feature, just as coding for several ads was placed in the same way. All the elements displayed properly in the Muse layout and in the browser preview, so I assumed that the code was being read correctly.
    Unfortunately when I click the button on the deployed site, the message "Run script "getPianoDeals()" appears at the bottom of the browser window but nothing else happens. A pop-up window with localized info is supposed to show up. This button appears at the top of every page on a website of hundreds of pages.
    I don't know Javascript, simply place the line of code provided to me. The button has always worked in the past. There's a lot going on in the pages so I don't know if there's a conflict or what to do about it. The site is at www.pianobuyer.com; the white button labeled "view local offers" in the top right corner is the problem. For reference I've reloaded the main pages of the old site at www.pianobuyer.com/Julie/ where the button functions correctly.
    Any suggestions are greatly appreciated.
    Thanks.

    I've tried several things to sort out the problem.
    I isolated the button on a separate layer (helpful with problems between drop-down menu bar and other HTML objects on a page) but it made no difference.
    I then edited the HTML file, moving the relative position of the Muse javascript entries and the problem button script. No matter where the lines were placed, when the button script follows the Muse scripts it works fine; when the button script precedes the Muse scripts it does nothing. Also when the Muse scripts follows the button script the normal actions on the site works fine (drop-down menu bar, slide show); when the Muse scripts precedes the button script none of them work. So the conflict definitely occurs between the scripts.
    I found two discussions on the forum about similar problems. Both refer to a "require.js" file being added to the page. Unfortunately I don't understand what's being discussed.

  • Problem with HTML Help import lib

    I am doing a project and using HTML help as the help system. I have done
    this with other projects on the same PC (in a different directory) just
    fine. When I try build my specific new project I get
    3 link errors
    undefined symbol __imp__RegCloseKey@4 referenced in c:\supervisor
    console\htmlhelp.lib
    undefined symbol __imp__RegQueryValueExA@4 referenced in c:\supervisor
    console\htmlhelp.lib
    plus one more
    Could the problem be the space in the directory name "\supervisor console"?
    I am at a loss to what is missing from this new project. I am including the
    same htmlhelp.lib as in the other project.

    We are using designer/headstart 6i.
    Within Designer we have build a Module component with
    several Sub components.
    The Headstart HTML Help Generator doesn't seem to
    allocate a context help ID prefix/suffix, for
    (unbound-) items that are placed on the
    sub-component.
    Hello Mark,
    I modified the generator so that it also generates help for items on subcomponents. Send me an email and I will send you the modified sources.
    Regards, Rob

Maybe you are looking for