Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

When I reload the applet the labels with html syntax hides.

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I coded this applet to try out the html syntax for swing object labels.
I'm using jdk 1.6 update 22 and firefox

This applet works fine when I am viewing the applet for the first time. but if I reload the applet the labels with html syntax in them hides.

This is the code

package test;

import java.awt.*;
import javax.swing.*;

* @author priyal
public class NewJApplet extends JApplet {

public void init() {

JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(200, 200));
panel.setLayout(new GridBagLayout());

GridBagConstraints panelConstraints = new GridBagConstraints();
panelConstraints.anchor = GridBagConstraints.CENTER;
panelConstraints.weightx = 1.0;
panelConstraints.ipadx = 5;
panelConstraints.gridx = 0;
panelConstraints.gridy = 0;

JToolTip tt = new JToolTip();
tt.setPreferredSize(new Dimension(50, 20));

JButton button = new JButton("<html><u>Button</u></html>");
button.setPreferredSize(new Dimension(50, 50));

panel.add(button, panelConstraints);
panelConstraints.gridx = 1;
panelConstraints.gridy = 1;
panel.add(tt, panelConstraints);

JLabel label = new JLabel("<html><i>Label</i></html>");
panelConstraints.gridx = 0;
panelConstraints.gridy = 1;
panel.add(label, panelConstraints);


Please help...
Ranch Hand
Posts: 54
Eclipse IDE Spring Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Priyal,

Did you ever find a solution to this? I have exactly the same problem. It is ok in older JVMs.

EDIT: This appears to be caused by or related to this bug in the JLabel.

Oracle Bug
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic