是关于java Swing2 的一些源代码

源代码在线查看: testapplet.java

软件大小: 4413 K
上传用户: zwaheron
关键词: Swing2 java 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				// Copyright 1998, Sabreware Inc.
				
				import com.sun.java.swing.*;
				import com.sun.java.swing.border.*;
				import java.awt.*;
				
				public class TestApplet extends JApplet {
					JPanel jpanel = new RainPanel();
					TitledBorder border = new TitledBorder("JPanel Border");
				
					public void init() {
						jpanel.setBorder(border);
						getContentPane().add(jpanel, BorderLayout.CENTER);
				
						System.out.println("opaque = " + border.isBorderOpaque());
						System.out.println(
								"insets = " + border.getBorderInsets(jpanel));
					}
				}
				class RainPanel extends JPanel {
					public void paintComponent(Graphics g) {
						Icon icon = new ImageIcon("rain.gif");
						Dimension size = getSize();
						Rectangle interior = AbstractBorder.getInteriorRectangle(
												this, getBorder(), 0, 0, size.width,
												size.height);
				
				        int patchW = icon.getIconWidth(),
				        	patchH = icon.getIconHeight();
				
				        for(int r=interior.x; r < interior.width; r += patchW) {
				            for(int c=interior.y; c < interior.height; c += patchH)
								icon.paintIcon(this, g, r, c);
				        }
				    }
				}
							

相关资源