Hi! I'm trying to draw some filled rectangles in a JPanel, should I define a paintComponent like this?
public void paintComponent( Graphics g) {
super.paintComp onent(g);
g.setColor(Colo r.blue);
g.drawRect(10, 10, 80, 30);
g.drawRoundRect (100, 10, 80, 30, 15, 15);
Or is there any other way to do it? maybe using some Swing component, for example the JTextField is like a rectangle and I could change the background color and if I could set it as a read-only component where the user could not write,that could work as a rectangle..
public void paintComponent( Graphics g) {
super.paintComp onent(g);
g.setColor(Colo r.blue);
g.drawRect(10, 10, 80, 30);
g.drawRoundRect (100, 10, 80, 30, 15, 15);
Or is there any other way to do it? maybe using some Swing component, for example the JTextField is like a rectangle and I could change the background color and if I could set it as a read-only component where the user could not write,that could work as a rectangle..
Comment