先上图:
整体效果、操作风格等 与Chrome 保持高度接近,实现了标签新增、删除、移动、自适应宽度等特性。
核心代码,
1:创建Tab 页边框:
public void drawRect(Graphics g, Rectangle rect) { GraphicsPath path = new GraphicsPath(); path = new GraphicsPath(); path.AddBezier( new Point(rect.X, rect.Bottom), new Point(rect.X + 3, rect.Bottom - 2), new Point(rect.X + 3, rect.Bottom - 2), new Point(rect.X + 4, rect.Bottom - 4)); //path.AddLine(rect.X + 4, rect.Bottom - 4, rect.Left + 15 - 4, rect.Y + 4); path.AddBezier( new Point(rect.Left + 15 - 4, rect.Y + 4), new Point(rect.Left + 15 - 3, rect.Y + 2), new Point(rect.Left + 15 - 3, rect.Y + 2), new Point(rect.Left + 15, rect.Y)); //path.AddLine(rect.Left + 15, rect.Y, rect.Right - 15, rect.Y); path.AddBezier( new Point(rect.Right - 15, rect.Y), new Point(rect.Right - 15 + 3, rect.Y + 2), new Point(rect.Right - 15 + 3, rect.Y + 2), new Point(rect.Right - 15 + 4, rect.Y + 4)); //path.AddLine(rect.Right - 15 + 4, rect.Y + 4, rect.Right - 4, rect.Bottom - 4); path.AddBezier( new Point(rect.Right - 4, rect.Bottom - 4),