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

    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
    Posts
    1,236
    Rep Power
    7

    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
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    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, 07:19 AM
  2. Replies: 6
    Last Post: 04-27-2011, 05:27 AM
  3. Replies: 2
    Last Post: 02-23-2011, 05:14 PM
  4. Replies: 5
    Last Post: 06-14-2010, 06:10 PM
  5. Replies: 4
    Last Post: 04-22-2009, 11:02 PM

Posting Permissions

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