鮨という文字が回るだけ
鮨という文字が回るだけ
import javax.swing.*; import java.awt.*; import java.math.*; import java.awt.event.*; class rotSushi { public static void main ( String args[] ) { MyFrame mf = new MyFrame("rotSushi"); mf.setVisible(true); } } class MyFrame extends JFrame implements ActionListener { Container contentPane = getContentPane(); Sushi sushi = new Sushi(); JPanel p = new JPanel(); MyFrame ( String title ) { setTitle(title); setSize(512,512); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); p.add(sushi); contentPane.add(p); Timer tm = new Timer(30,this); tm.start(); } public void actionPerformed ( ActionEvent e ) { this.repaint(); sushi.angle = (sushi.angle+1) % 360; } } class Sushi extends JLabel { public static int angle=0; Sushi () { setText("鮨"); setForeground(Color.RED); setPreferredSize(new Dimension(512,512)); setFont(new Font("MS 明朝",Font.BOLD,140)); setHorizontalAlignment(JLabel.CENTER); } @Override public void paintComponent ( Graphics g ) { Graphics2D g2 = (Graphics2D) g; g2.rotate(Math.toRadians(angle),256,256); super.paintComponent(g); } }