Search:

Type: Posts; User: copeg

Search: Search took 0.09 seconds.

  1. Replies
    26
    Views
    4,372

    Re: How to fix this code?

    Draw it out on a sheet of paper and define the appropriate coordinates. See Drawing Arbitrary Shapes
  2. Replies
    26
    Views
    4,372

    Re: How to fix this code?

    There are still a few things wrong with your code in general. First, no need to have your class extend JFrame when you are using a JFrame variable for most of everything (the init() function has...
  3. Replies
    26
    Views
    4,372

    Re: How to fix this code?

    Can you post a short compilable example of the code to this point that demonstrates the problem? With all these posts its hard to be sure where the code stands at this point.
  4. Replies
    26
    Views
    4,372

    Re: How to fix this code?

    It doesn't work because it only partially implements my suggestion from above. There are 2 setVisible calls...
  5. Replies
    26
    Views
    4,372

    Re: How to fix this code?

    You are adding components to the frame after it is realized (visible). Add things prior, in this example move the setVisible method to the last call in the init function (in which case repaint is not...
  6. Replies
    26
    Views
    4,372

    Re: How to fix this code?

    You need to initialize the object: (see Creating Objects)


    f = new JFrame();




    It may work, but you should not rely on deprecated methods. There is a reason they are deprecated, and its...
  7. Replies
    26
    Views
    4,372

    Re: How to fix this code?

    Are you reading the stack trace? Any exceptions? This is important information...on close look the variable 'f' is never initialized, and the program sequence sets the frame to visible then, when you...
  8. Replies
    26
    Views
    4,372

    Re: How to fix this code?

    First, I'd encourage you to use a JFrame rather than a Frame (see How to use JFrames). Second, show is deprecated. Use setVisible(true). Next, you shouldn't override the paint method, especially of...
Results 1 to 8 of 8