切换图形可见性

时间:2014-07-24 04:53:34

标签: java graphics toggle

我正在尝试通过创建一个一次显示一个的方法来打开和关闭图形。我有8个图形,我需要通过一个方法一次打开一个图形,每次调用它时都会执行此操作。我真的需要帮助,我会很感激。我只需要知道如何制作一个允许我打开和关闭图形的方法。

public class StickFigure extends GCompound{
    private static GOval head;
    private GLine torso;
    private GLine armL;
    private GLine armR;
    private GLine legL;
    private GLine legR;
    private GLine footL;
    private GLine footR;

    public static Boolean statHead = true;
    public static Boolean statTor = true;
    public static Boolean statArml = true;
    public static Boolean statArmr = true;
    public static Boolean statLegl = true;
    public static Boolean statLegr = true;
    public static Boolean statFootl = true;
    public static Boolean statFootr = true;
    private static final int HEAD_SIZE = 100;

    public StickFigure(){
        head = new GOval(HEAD_SIZE, HEAD_SIZE);
        add(head, 200, 50);
        head.setVisible(statHead);
        torso = new GLine(250, 150, 250, 350);
        add(torso);
        torso.setVisible(statTor);
        armL = new GLine(250, 200, 150, 150);
        add(armL);
        armL.setVisible(statArml);
        armR = new GLine(250,200, 350, 150);
        add(armR);
        armR.setVisible(statArmr);
        legL = new GLine(250, 350, 200, 450);
        add(legL);
        legL.setVisible(statLegl);
        legR = new GLine(250, 350, 300, 450);
        add(legR);
        legR.setVisible(statLegr);
        footL = new GLine(200, 450, 175, 450);
        add(footL);
        footL.setVisible(statFootl);
        footR = new GLine(300, 450, 325, 450);
        add(footR);
        footR.setVisible(statFootr);
    }

0 个答案:

没有答案
相关问题