java 么清除已画的图形_java程序设计时在JFrame中要清除一个圆再画一个矩形该怎么清除?...

展开全部

import java.awt.*;

import java.awt.event.*;

import java.awt.geom.Point2D;

import java.awt.image.BufferedImage;

import javax.swing.*;

import javax.swing.border.Border;

public class DrawShapes extends JFrame{

private static final long serialVersionUID = 3685715844170953607L;

//Graphic panel

private CVS cvs;

//作图方式选择按钮62616964757a686964616fe58685e5aeb931333330343834

private JToggleButton cycle,line,rect;

private JLabel red,blue,green;

private ButtonGroup bgroup;

//按钮布局面板

private JPanel menuPanel;

//复位按钮

private JButton clean;

public DrawShapes(){

super("Java 实训");

// this.setResizable(false);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setSize(640,480);

this.setLocationRelativeTo(null);

this.getContentPane().add(cvs=new CVS());

this.initComponents();

}

//初始化组件

private void initComponents() {

this.menuPanel = new JPanel(null);

this.menuPanel.setPreferredSize(new Dimension(400,28));

this.menuPanel.setBorder(BorderFactory.createLineBorder(Color.gray));

this.getContentPane().add(this.menuPanel,"South");

this.bgroup = new ButtonGroup();

this.cycle = new JToggleButton("圆形");

this.cycle.setBounds(20,4,68,20);

this.line = new JToggleButton("直线");

this.line.setBounds(100,4,68,20);

this.rect=new JToggleButton("矩形");

this.rect.setBounds(180,4,68,20);

red = new JLabel();

red.setOpaque(true);

red.setBackground(Color.red);

red.setBounds(258,4,20,20);

blue=new JLabel();

blue.setOpaque(true);

blue.setBackground(Color.blue);

blue.setBounds(282,4,20,20);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值