在application窗口中有没有“横线”组件?

darkdoom 2002-03-12 02:12:10
象windows窗口工具栏之间的分隔线
...全文
5 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
CanFly 2002-03-12
jbuilder好像有吧!
不过你这样画线!
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;

public class TLine extends JFrame
{
private CanvasDisplay cavas;
public TLine()
{
Container content=getContentPane();
cavas=new CanvasDisplay();
content.setLayout(new FlowLayout());
content.add(cavas);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
pack();
show();
}
public static void main(String args[])
{
new TLine();
}
class CanvasDisplay extends Canvas
{
public CanvasDisplay()
{
setBackground(Color.white);
setForeground(Color.blue);
setSize(600,600);
}
public void paint(Graphics g)
{
Graphics2D g2D=(Graphics2D) g;

//move the X and Y
g2D.translate(100,100);

//rotate the line
g2D.rotate(5,200,200);

//fangda the line de bashu
g2D.scale(2,2);

//set the line's width
BasicStroke stroke=new BasicStroke(5);
g2D.setStroke(stroke);
drawhome(g2D);
}
public void drawhome(Graphics2D g2D)
{
Line2D line1=new Line2D.Float(100f,200f,200f,200f),
line2=new Line2D.Float(100f,200f,100f,100f),
line3=new Line2D.Float(100f,100f,150f,50f),
line4=new Line2D.Float(150f,50f,200f,100f),
line5=new Line2D.Float(200f,100f,200f,200f),
line6=new Line2D.Float(140f,200f,140f,150f),
line7=new Line2D.Float(140f,150f,160f,150f),
line8=new Line2D.Float(160f,150f,160f,200f);

g2D.draw(line1);
g2D.draw(line2);
g2D.draw(line3);
g2D.draw(line4);
g2D.draw(line5);
g2D.draw(line6);
g2D.draw(line7);
g2D.draw(line8);
}
}
}
回复
hanson_yi 2002-03-12
你用JToolBar控件。它在显示时会有一条“横线”
回复
hexiaofeng 2002-03-12
自己划一条线吧
回复
相关推荐
发帖
非技术区
创建于2007-09-28

2.3w+

社区成员

Java 非技术区
申请成为版主
帖子事件
创建了帖子
2002-03-12 02:12
社区公告
暂无公告