Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- //import java.awt.event.*;
- class Test extends JFrame /*implements ActionListener*/{
- public static void main(String[] args) {
- Test frame = new Test("タイトル");
- frame.add(new DrawCanvas());
- frame.setVisible(true);
- }
- Test(String title){
- setTitle(title);
- setSize(600,400);
- setLocationByPlatform(true);
- setLAF();
- //setResizable(false);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- /*JPanel p = new JPanel();
- JButton btn1 = new JButton("ヘルプ");
- JButton btn2 = new JButton("スタート");
- JButton btn3 = new JButton("オプション");
- btn2.addActionListener(this);
- p.add(btn1);
- p.add(btn2);
- p.add(btn3);
- getContentPane().add(p, BorderLayout.SOUTH);*/
- }
- void setLAF() {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /*public void actionPerformed(ActionEvent e){
- setLAF();
- setTitle("ゲーム");
- setSize(640,480);
- setLocationByPlatform(true);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }*/
- }
- class DrawCanvas extends JPanel{
- public void paintComponent(Graphics g) {
- super.paintComponent(g);
- Graphics2D g2 = (Graphics2D)g;
- g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- g2.fillOval(133, 234, 50, 50);
- Font font = new Font("HGP創英角ポップ体",Font.PLAIN,30);
- g2.setFont(font);
- g2.drawString("GAME", 150, 150);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement