Draw Shapes That User Selects

后端 未结 2 1693
走了就别回头了
走了就别回头了 2021-01-27 11:21

I need to create a program to draw shapes(user chooses with radio button), and whether or not the shape is filled(user chooses with check box). This is the code I have so far:

2条回答
  •  长发绾君心
    2021-01-27 11:49

    Well, the following is definitely not valid Java code:

        dLine() {
            g.drawLine(10,10,160,10);
        }
    

    The same applies to the following dRect, etc.

    I'm not sure exactly what you're trying to achieve with that code. If it is to define a method called dLine, you would do the following instead:

    public void dLine(Graphics g) {
        g.drawLine(10, 10, 160, 10);
    }
    

    I also noticed the following code, which is not currently causing you problems, but it will:

    public void ItemStateChanged(itemEvent e) {
    

    This is not capitalized properly, so it will not compile, and you're also not listening to any events, so it will never get called.

    There are various other errors in the code, but this should get you started.

提交回复
热议问题