JPanel Graphics clearing and repainting?

前端 未结 4 612
情书的邮戳
情书的邮戳 2020-12-16 20:25

I have a JPanel with a paintComponent() function. I\'ll call it once, then when the user clicks a different JButton, I\'ll set some fl

4条回答
  •  盖世英雄少女心
    2020-12-16 20:45

    First, why not use an enum instead of a boolean?

    enum Enum { 
        RECTANGLE,
        LINE,
        CIRCLE
    }
    
    Enum choice = RECTANGLE; //default to RECTANGLE
    
    switch(choice) { 
       // case RECTANGLE, LINE, CIRCLE
    }
    

    With regards to your issue, can you answer my comments in your question?

提交回复
热议问题