import java.awt.*import java.awt.event.*import java.awt.geom.*import javax.swing.*//不规则图形的
绘制public class IrregularShapeDemo extends JFrame {GeneralPath gPath= new GeneralPath()//GeneralPath对象实例Point aPoint//构造函数public IrregularShapeDemo() {super("不规则图形的绘制")//调用父类构造函数enableEvents(AWTEvent.MOUSE_EVENT_MASK|AWTEvent.MOUSE_MOTION_EVENT_MASK)//允许
事件setSize(300, 200)//
设置窗口尺寸setVisible(true)//设置窗口可视setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)//关闭窗口时退出程序}public void paint(Graphics g) { //重载窗口组件的paint()方法Graphics2D g2D = (Graphics2D)g //获取图形环境g2D.draw(gPath)//绘制路径}public static void main(String[] args) {new IrregularShapeDemo()}protected void processMouseEvent(MouseEvent e) { //鼠标事件处理if(e.getID() == MouseEvent.MOUSE_PRESSED) {aPoint = e.getPoint()//得到当前鼠标点gPath = new GeneralPath()//重新实例化GeneralPath对象gPath.moveTo(aPoint.x,aPoint.y)//设置路径点}}protected void processMouseMotionEvent(MouseEvent e) { //鼠标运动事件处理if(e.getID() == MouseEvent.MOUSE_DRAGGED) {aPoint = e.getPoint()//得到当前鼠标点gPath.lineTo(aPoint.x, aPoint.y)//设置路径gPath.moveTo(aPoint.x, aPoint.y)repaint()//重绘组件}} }QGraphicsSimpleTextItem provides a simple text label item
QGraphicsTextItem provides an advanced text browser item
这两个(反正第二个肯定可以的,第一个应该只是简单的lable),生成实例设置flag为Qt::TextEditorInteraction添加到screen就好了。
1. 拖入一个textBox
2.修改textBox属性:
BorderStyle=None
BackColor=Control
3.选中整个Form1,对Form1的Paint事件进行编程,代码如下:
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(new Pen(Color.Black, 1), this.textBox1.Location.X, this.textBox1.Location.Y + this.textBox1.Height , this.textBox1.Location.X + this.textBox1.Width, this.textBox1.Location.Y + this.textBox1.Height )
}
你要的效果就有了。 至于背景颜色要不要,自己改BackColor就行
评论列表(0条)