how to add a circle or rectangle in a jtextarea
hi im new here
and i have try to add by myself a circle on a jtextarea which doesnt work atm
im new to graphics2d but not to java...
the code i have atm doesnt work out when i try to add my circle into a jtextarea but its works when i add it to the jframe
what am i doing wrong ?
Here is the Main class
Code:
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class ShowCircle extends JFrame
{
private Circle circle;
private JTextArea jTA;
public ShowCircle()
{
jTA = new JTextArea(6, 20);
circle = new Circle(60,150,50,30);
jTA.add(circle);
//this.add(circle); works
getContentPane().add(jTA,BorderLayout.WEST);
this.setSize(100,100);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args)
{
ShowCircle sc = new ShowCircle();
}
}
and here is the Circle class
Code:
import java.awt.Graphics;
import java.awt.geom.Ellipse2D;
import java.awt.Graphics2D;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class Circle extends JPanel
{
int x,y,width,height;
public Circle()
{
x = 10;
y = 50;
width = 100;
height = 50;
}
public Circle(int x,int y,int width, int height)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;
g.drawOval(x,y,width,height);
}
}
help me out plz im block
ty in advance