0

How can I paint the grid itself (e.g. grid lines) on a Figure, which has grid layout. I think i need to paint it in another layer, but i can not figure out what exactly to do, to paint 'above' the layer with grid layout.

execc
  • 1,083
  • 12
  • 25
  • What do you mean by painting the grid? gridlayout is not a grid on which you can align figures, it just defines that the figures added inside the parent figure are arranged in rows and columns. Are you sure this is what you are looking for? – vainolo Feb 06 '12 at 13:09
  • @vainolo I mean, i want to see a grid, in which elements are arranged. Basically, i'm creating the UI editor, for some table-layouted xml-based UI schema. So I want to make sure users can see actual grid, in which elements are positioned. – execc Feb 07 '12 at 09:22

2 Answers2

1

What you can do is use a GridLayout, and paint Rectangle figures that on top of them you paint your items. Right now I cannot think of a more elegant way to do this.

vainolo
  • 6,907
  • 4
  • 24
  • 47
1

You can just override the paint(Graphics) method of your figure with the grid layout:

public void paint(Graphics g)
{
  super.paint(g);

  // draw your grid here
}

Everything you paint where the comment is will appear above the figure and its children.

Frettman
  • 2,251
  • 1
  • 13
  • 9