sandip chitale's blog    Sandip Chitale's blog (scblog)
NOTE: I have moved many of my modules to NetBeans Plugin Portal . Please check there for latest versions of modules described on this blog.
20060521 Sunday May 21, 2006

TIP: Images in Tooltips

Here is a simple tip:

The Swing tooltips support html syntax via use of the <html> tag. This can be exploited to show images in tooltips.

For example, with the following layout:

src
   org
      mypackage
         ImageInTooltip.java
         tooltip.gif
and source code:
package org.mypackage;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ImageInTooltip {
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		JLabel label = new JLabel("Label with image in Tooltip!");
		label.setToolTipText(
			"<html><img src=\"" +
			ImageInTooltip.class.getResource("tooltip.gif") +
			"\"> Tooltip "
			);
		label.setHorizontalAlignment(JLabel.CENTER);
		frame.setContentPane(label);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setBounds(100, 100, 200, 100);
		frame.setVisible(true);
	}
}
give you this:


Posted by sandipchitale ( May 21 2006, 04:59:23 PM PDT ) Permalink Comments [0]


UPDATED: Code Template Tools Module

I have updated the Code Template Tools Module on my NetBeans 5.0 update center described (here).

What is new?

A new generalized code template parameter ${input-parameter name ...} :
  • ${input-parameter name prompt="prompt string" defaultValue="value1" valuesSeparator="," enumeratedValues="value1,value2,value3" suggestedValues="value1,value2,value3"} - The user will be be prompted to enter the value of the parameter. The parameter name part (excluding the input- prefix is used as the default prompt and default value. The values of input-... parameters can be strictly constrained using the enumeratedValues hint. The values of input-... parameters can be loosely constrained using the suggestedValues hint. The values separator can be specified using valuesSeparator regexp hint.

DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.


Posted by sandipchitale ( May 21 2006, 08:51:56 AM PDT ) Permalink Comments [1]










« May 2006 »
SunMonTueWedThuFriSat
 
3
4
5
7
9
10
11
12
13
14
15
16
19
22
23
24
25
26
27
28
29
30
31
   
       
Today

Get NetBeans 5.5

Locations of visitors to this page

Today's Page Hits: 9


XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

scblog
scblog