16 lines
391 B
Java
16 lines
391 B
Java
import java.awt.Color;
|
|
import java.awt.Graphics;
|
|
import javax.swing.JPanel;
|
|
|
|
public class MyPanel extends JPanel {
|
|
@Override
|
|
protected void paintComponent(Graphics g) {
|
|
// clean the panel
|
|
super.paintComponent(g);
|
|
// draw
|
|
g.setColor(Color.RED);
|
|
g.drawString("hello", (int) Math.round(Math.random() * this.getWidth()),
|
|
(int) Math.round(Math.random() * this.getHeight()));
|
|
}
|
|
}
|