Created
February 22, 2020 18:18
-
-
Save MinSomai/a8057e5dcb59921f10ab0f655406e2dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hw; | |
import java.awt.Color; | |
import java.awt.EventQueue; | |
import java.awt.Graphics; | |
import java.awt.Graphics2D; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; | |
class Rotation extends JPanel { | |
private void doDrawing(Graphics g) { | |
Graphics2D g2d = (Graphics2D) g.create(); | |
g2d.setPaint(new Color(150, 150, 150)); | |
g2d.fillRect(40, 40, 100, 70); | |
g2d.translate(200, -50); | |
g2d.rotate(Math.PI/4); | |
g2d.fillRect(100,100, 90, 70); | |
} | |
@Override | |
public void paintComponent(Graphics g) { | |
super.paintComponent(g); | |
doDrawing(g); | |
} | |
private void rotate (double d) { | |
throw new UnsupportedOperationException("Error."); | |
} | |
} | |
public class Rotation13 extends JFrame { | |
public Rotation13() { | |
initUI(); | |
} | |
private void initUI() { | |
setTitle("Rotation Example: "); | |
add(new Rotation()); | |
setSize(500, 500); | |
} | |
public static void main(String[] args) { | |
EventQueue.invokeLater(new Runnable() { | |
public void run() { | |
// TODO Auto-generated method stub | |
Rotation13 Rot= new Rotation13(); | |
Rot.setVisible(true); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment