⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 player.java

📁 Usefull sample codes for Java. Containt all type of programs.
💻 JAVA
字号:
import java.awt.*;
import javax.swing.*;

public class Player extends JFrame {
    public Player() {
        super("Player");
        setSize(294, 396);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        PlayerPanel fp = new PlayerPanel();
        add(fp);
        setVisible(true);
    }

    public static void main(String[] arguments) {
        Player frame = new Player();
    }
}

class PlayerPanel extends JPanel {
    public PlayerPanel() {
        ImageIcon player = new ImageIcon("johnny-evers-1913.jpg");
        JLabel playerLabel = new JLabel(player);
        add(playerLabel);
    }
    
    public void paintComponent(Graphics comp) {
        super.paintComponent(comp);
        Graphics2D comp2D = (Graphics2D)comp;
        comp2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
        int width = getSize().width;
        int height = getSize().height;
        Font currentFont = new Font("Dialog", Font.BOLD, 18);
        comp2D.setFont(currentFont);
        comp2D.drawString("JOHNNY EVERS", width - 155, height - 50);
        currentFont = new Font("Dialog", Font.ITALIC, 12);
        comp2D.setFont(currentFont);
        comp2D.drawString("second baseman", width - 155, height - 30);
        currentFont = new Font("Dialog", Font.PLAIN, 12);
        comp2D.setFont(currentFont);
        comp2D.drawString("CHICAGO CUBS", width - 155, height - 10);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -