Results 1 to 3 of 3
  1. #1
    ninjaturtlez is offline Member
    Join Date
    Dec 2011
    Rep Power

    Default JFrame and paint()

    I am trying to create a program using JFrame but i dont understand how i am supposed to draw to the screen.

    Like in applets(not JApplets) you just have public void paint(Graphics g) and then you can do whatever you want. How do i do this with JFrame???

    I would appreciate an explanation or a link to a tutroial. Thanks

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Rep Power

    Default Re: JFrame and paint()

    Custom painting is done by overriding the paintComponent() method of a JPanel (or JComponent). Then you add the panel to the frame.

    See: Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)

  3. #3
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    London, UK
    Blog Entries
    Rep Power

    Default Re: JFrame and paint()

    Are you sure thats what you want to do with the JFrame? You said you are trying to create a program so what kind of program is it? Just wondering if you read the Swing tutorials?

Similar Threads

  1. JFrame cannot paint?
    By pandaman0212 in forum AWT / Swing
    Replies: 7
    Last Post: 05-04-2013, 08:19 AM
  2. Replies: 6
    Last Post: 04-27-2011, 06:27 AM
  3. Replies: 2
    Last Post: 02-23-2011, 06:14 PM
  4. Replies: 5
    Last Post: 06-14-2010, 07:10 PM
  5. Replies: 4
    Last Post: 04-23-2009, 12:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts