lab10
This commit is contained in:
15
lab/lab10/Question6/MyPanel.java
Normal file
15
lab/lab10/Question6/MyPanel.java
Normal file
@@ -0,0 +1,15 @@
|
||||
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()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user