Results 1 to 3 of 3
  1. #1
    ryuzog is offline Member
    Join Date
    Jan 2010
    Posts
    32
    Rep Power
    0

    Default Can I change the border of a JPanel cell?

    I have a somewhat spaced checkerboard of JPanel[][] "cells" in a larger JPanel.

    The 2-d array is rainbow colored while the background is white.

    I want to make it so that hovering on a panel changes the border of one cell to a different color.

    I can only .getComponent() though and change the cell itself, like size and background.

    I saw someone else be able to do this though, so is there some method I don't know about?

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

    Default

    If you check out the JPanel API, you should find a method that would work well here that JPanel inherits from a parent. It starts with set and ends with Border. :)

  3. #3
    ryuzog is offline Member
    Join Date
    Jan 2010
    Posts
    32
    Rep Power
    0

    Default

    Ok I got it, the thing was the .getComponenet() just returned a component.

    I'm not sure what exactly that means, but I could setBackground with it.

    To change the border however I needed to directly change the cell[][].So I needed to get the x and y coordinates some other way...I used getComponent().getX and getY and divided by pixel length/width.

    Another thing that confused me was that I though the cells were on a white background. Actually, the cells originally had a whiten border and were just packed densely into the larger JPanel.

    Thanks~

Similar Threads

  1. Change border color from blue to green of JFrame
    By altu57 in forum AWT / Swing
    Replies: 1
    Last Post: 07-10-2010, 05:19 AM
  2. how to change controls border color
    By altu57 in forum AWT / Swing
    Replies: 1
    Last Post: 07-10-2010, 05:11 AM
  3. Change JPanel background after its been set once
    By mevets in forum AWT / Swing
    Replies: 4
    Last Post: 04-14-2010, 02:07 AM
  4. Set border
    By anilkumar_vist in forum New To Java
    Replies: 1
    Last Post: 02-06-2010, 12:25 PM
  5. how can create border
    By yuen in forum AWT / Swing
    Replies: 6
    Last Post: 11-08-2009, 12:42 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
  •