Article View: cn.bbs.comp.lang.java
Article #20047swing �������
From: Carl
Date: Wed, 24 Dec 2003 09:31
Date: Wed, 24 Dec 2003 09:31
57 lines
2148 bytes
2148 bytes
����OvalIcon.java�����paintIcon����ô�����õ�
лл
// OvalIcon.java
// A simple icon implementation that draws ovals.
//
import javax.swing.*;
import java.awt.*;
public class OvalIcon implements Icon {
private int width, height;
public OvalIcon(int w, int h) {
width = w;
height = h;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
g.drawOval(x, y, width-1, height-1);
}
public int getIconWidth() { return width; }
public int getIconHeight() { return height; }
}
// TestOval.java
// A simple application to test the functionality of the OvalIcon class.
//
import javax.swing.*;
import java.awt.*;
public class TestOval {
public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label1 = new JLabel(new OvalIcon(20,50));
JLabel label2 = new JLabel(new OvalIcon(50,20));
JLabel label3 = new JLabel
("Round!", new OvalIcon(60,60), SwingConstants.CENTER);
label3.setHorizontalTextPosition(SwingConstants.CENTER);
Container c = f.getContentPane();
c.setLayout(new FlowLayout());
c.add(label1);
c.add(label2);
c.add(label3);
f.pack();
f.setVisible(true);
}
}
--
[m[1;33m�� ��Դ:��Ʈ��ˮ�Ƽ� Freecity.dhs.org��[FROM: WZF][m
Technical Details
Message-ID:
<49lTe8$A0O@Freecity.dhs.org>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!news-xfer1.atl.newshosting.com!167.206.3.103.MISMATCH!news3.optonline.net!news.bylinux.net!news.ccie.net.cn!FreecityShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,GB X-Google-Thread: f6cb0,8887024091e7de75,start X-Google-Attributes: gidf6cb0,public X-Google-ArrivalTime: 2003-12-24 01:30:14 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!news-xfer1.atl.newshosting.com!167.206.3.103.MISMATCH!news3.optonline.net!news.bylinux.net!news.ccie.net.cn!Freecity From: WZF.bbs@Freecity.dhs.org (Carl) Newsgroups: cn.bbs.comp.lang.java Subject: swing ������� Date: 24 Dec 2003 09:31:45 GMT Organization: Ʈ��ˮ�Ƽ� Message-ID: <49lTe8$A0O@Freecity.dhs.org> Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Filename: Java/M.1072258184.A Lines: 57