Take the 2-minute tour ×

how to make the rectangle which can have a editable text as microsoft visio or gliffy. i have implemented the rectangle draggable but i am not able to put the text inside it which can edit at runtime as microsoft visio or gliffy.so please give me some idea to implement this.

code :- public class ColoredRect extends JPanel{

  private double x, y, width, height;  
  private Rectangle2D.Double rect;

  public ColoredRect(double x,double y)
      this.x = x;
      this.y = y;
      width = 100;
      height =40;
      rect = new Rectangle2D.Double(this.x , this.y,width,height);
  public void paintComponent(Graphics g) 
    Graphics2D g2 = (Graphics2D) g;
  public void setRectangle(double x, double y)
      this.x =x;
      this.y =y;


thanks in advance.

share|improve this question
Graphics2D.drawString(...) and KeyListener –  iccthedral Jun 28 '12 at 7:49
add comment


Your Answer



Browse other questions tagged or ask your own question.