permaculture playing cards*
The moose likes Applets and the fly likes When I reload the applet the labels with html syntax hides. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "When I reload the applet the labels with html syntax hides." Watch "When I reload the applet the labels with html syntax hides." New topic
Author

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

priyal fernando
Greenhorn

Joined: Nov 16, 2010
Posts: 1
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));
tt.setTipText("<html><i>ToolTip</i></html>");

JButton button = new JButton("<html><u>Button</u></html>");
button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
button.setBorderPainted(false);
button.setBorder(BorderFactory.createEmptyBorder());
button.setActionCommand("export");
button.setBackground(Color.white);
button.setOpaque(false);
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);
add(panel);

}
}

Please help...
Chris Zaremba
Ranch Hand

Joined: Nov 22, 2010
Posts: 54

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


SCJA, OCPJP, OCMJD
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: When I reload the applet the labels with html syntax hides.
 
Similar Threads
JButtons inside JTooltip
Customizing JToolTip
Image problem in SWING
array to graphic mapping
JTooltip with a vertical scrollbar?