Results 1 to 3 of 3
  1. #1
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Question How do you draw a grid in a JFrame

    Is it possible to draw a grid within a JFrame? If so, how?
    I am trying to create a grid to divide my JFrame into sections, but I cannot figure out how to draw a grid.
    Can anyone explain to me how you draw a grid in a JFrame?
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    There can be several ways to do this, from using several JComponents in a grid and giving them line borders, to using a BufferedImage, getting its Graphics object and drawing lines within to drawing a grid within a JPanel's paintComponent method using the Graphics object passed as a parameter and calling Graphics#drawLine(...) on this Graphics object,...

    More importantly: how much do you know about Swing graphics? Have you gone through the Sun Graphics tutorial? If not, I strongly urge you to do so before embarking on this as it will give you the underpinnings you'll need to understand what you are doing. You understand of course that you'll almost never want to draw directly on the JFrame, right?

    Best of luck!

  3. #3
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    I do realize you rarely want to draw on the JFrame.

    could you give me a link to that tutorial? I cant find it.
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

Similar Threads

  1. Database Grid
    By leoleo4614 in forum AWT / Swing
    Replies: 1
    Last Post: 12-13-2008, 07:02 AM
  2. [SOLVED] How to create a Grid?
    By Nakira in forum New To Java
    Replies: 11
    Last Post: 11-12-2008, 10:45 AM
  3. how to get the grid values
    By jazz2k8 in forum Advanced Java
    Replies: 2
    Last Post: 11-06-2008, 02:11 PM
  4. Help creating a changing grid
    By adlb1300 in forum New To Java
    Replies: 11
    Last Post: 10-24-2007, 01:41 PM
  5. Help with Grid Layout
    By coco in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 08:03 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
  •