jtable question
hey all
i have a jtable that have more than one column....
i have a component called JHyperLinkedLabel...
my question is how can i make every column on each row have this custom component
below is the custom component that i need to add to every row on each first column...
please help
tahnks in advance
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
/**
* @author tim yates
*/
publicclass JHyperlinklabelextends JLabelimplements MouseMotionListener{
/**
* Creates a new instance of JHyperlinklabel
*
* @param text
*/
public JHyperlinklabel(String text){
super("<html><b><u>" + text +"</u></b></html>");
this.setForeground(Color.blue);
this.addMouseMotionListener(this);
}
publicvoid mouseDragged(MouseEvent e){
}
/**
* This method is taken from inside the source of JLabel (in the inner AccessibleJLabel class)
*
* @return
*/
private Rectangle getTextRectangle(){
String text = getText();
Icon icon = (isEnabled()) ? getIcon() : getDisabledIcon();
if ((icon ==null) && (text ==null)){
returnnull;
}
Rectangle paintIconR =new Rectangle();
Rectangle paintTextR =new Rectangle();
Rectangle paintViewR =new Rectangle();
Insets paintViewInsets =new Insets(0, 0, 0, 0);
paintViewInsets = getInsets(paintViewInsets);
paintViewR.x = paintViewInsets.left;
paintViewR.y = paintViewInsets.top;
paintViewR.width = getWidth() - (paintViewInsets.left + paintViewInsets.right);
paintViewR.height = getHeight() - (paintViewInsets.top + paintViewInsets.bottom);
Graphics g = getGraphics();
if (g ==null){
returnnull;
}
String clippedText = SwingUtilities.layoutCompoundLabel(
(JComponent) this,
g.getFontMetrics(),
text,
icon,
getVerticalAlignment(),
getHorizontalAlignment(),
getVerticalTextPosition(),
getHorizontalTextPosition(),
paintViewR,
paintIconR,
paintTextR,
getIconTextGap());
return paintTextR;
}
publicvoid mouseMoved(MouseEvent e){
if (getTextRectangle().contains(e.getPoint())){
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}else{
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
}

