Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:请问如何绘制不规则窗口? [Re:happyshows]
Sunteya





发贴: 22
积分: 0
于 2005-03-31 18:27 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
swing 可能使用 JWindow做吧。
下面的这段代码是看.SWT:The Standard Widget Toolkit, Volume.1 看到的
用SWT 做的,希望对你有用

这个是刚刚看到人家推荐的网站。可能上面也有吧 你去找找咯
http://www.java2s.com/ExampleCode/SWT-JFace-Eclipse1.htm


static final int POINTS = 11;

public static void main(String[] args) {
final Point center = new Point(0, 0);
final int[] radial = new int[POINTS * 2];

final Display display = new Display();
final Color black = display.getSystemColor(SWT.COLOR_BLACK);

final Shell shell = new Shell(display, SWT.NO_TRIM);
shell.setBackground(black);
shell.setSize(200, 200);

Rectangle bounds = shell.getClientArea();

center.x = bounds.x + bounds.width / 2;
center.y = bounds.y + bounds.height / 2;

int pos = 0;
for (int i = 0; i < POINTS; ++i) {
double r = Math.PI * 2 * pos / POINTS;
radial[i * 2] = (int) ((1 + Math.cos(r)) * center.x);
radial[i * 2 + 1] = (int) ((1 + Math.sin(r)) * center.y);
pos = (pos + POINTS / 2) % POINTS;

}

Listener listener = new Listener() {
int offsetX = 0, offsetY = 0;

public void handleEvent(Event e) {
switch (e.type) {
case SWT.MouseDown:
if (e.button == 1) {
offsetX = e.x;
offsetY = e.y;
}
break;
case SWT.MouseMove:
if ((e.stateMask & SWT.BUTTON1) != 0) {
Point pt = shell.toDisplay(e.x, e.y);
pt.x -= offsetX;
pt.y -= offsetY;
shell.setLocation(pt);
}
break;
case SWT.KeyDown:
shell.dispose();
break;
}
}
};

shell.addListener(SWT.MouseDown, listener);
shell.addListener(SWT.MouseMove, listener);
shell.addListener(SWT.KeyDown, listener);

Region region = new Region(display);
region.add(radial);

shell.setRegion(region);
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
region.dispose();
display.dispose();
}


Sunteya edited on 2005-03-31 18:32


关于Jute Forum的长期发展给官方的建议

话题树型展开
人气 标题 作者 字数 发贴时间
4164 请问如何绘制不规则窗口? happyshows 89 2005-03-30 16:18
3294 Re:请问如何绘制不规则窗口? Sunteya 2168 2005-03-31 18:27
3198 Re:请问如何绘制不规则窗口? yipsilon 2480 2005-03-31 21:41
3265 Re:请问如何绘制不规则窗口? happyshows 34 2005-04-02 14:44

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923