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

📄 icondemo.java

📁 《精通Java Swing程序设计S》这本书所附带的JAVA程序写得很漂亮,都是SWING的实例子,很适合初学者。
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class IconDemo implements Icon
{
    int height = 50;
    int width = 70;
    
    public int getIconHeight()
    {
        return height;
    }
    
    public int getIconWidth()
    {
        return width;
    }
    
    public void paintIcon(Component c, Graphics g, int x, int y)
    {
        g.drawRect(x, y, width, height);
        g.fillRect(x, y, width, height);
        g.setColor(Color.blue);
    }
        
    public static void main(String args[])
    {
        JFrame f = new JFrame("IconDemo");
        Container contentPane = f.getContentPane();
        
        Icon icon = new IconDemo();
        JLabel label = new JLabel(icon,JLabel.CENTER);
        contentPane.add(label);
        f.pack();
        f.show();
        
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                    System.exit(0);
            }
        });
    }
}
        

⌨️ 快捷键说明

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