Remove "Padding" from GridLayout/Buttons  
Author Message
Jo





PostPosted: 2004-4-12 0:37:00 Top

java-programmer, Remove "Padding" from GridLayout/Buttons I have a 10x10 grid of buttons created using a GridLayout. Each button has a
30x30 pixel GIF icon on it.

Unfortunately, nomatter what I try, I can't seem to get each icon to sit
side by side (so that there's no gap between them). Currently there's an
approximately 5 pixel gap between each GIF image.

So far I've tried:

grid_button.setSize(new Dimension(30, 30)); // to set each button to 30x30

_board_panel.setSize(new Dimension(30*y_size, 300*x_size)); // sets grid
board to 30 times the number of grids in each dimension

... but neither seems to work.

How do I get it so that there's no gap between each GIF? I need the size of
each square in the grid to be fixed to exactly 30x30, not relative to the
size of it's holding panel.

TIA.


 
ak





PostPosted: 2004-4-12 1:31:00 Top

java-programmer >> Remove "Padding" from GridLayout/Buttons > Unfortunately, nomatter what I try, I can't seem to get each icon to sit
> side by side (so that there's no gap between them). Currently there's an
> approximately 5 pixel gap between each GIF image.

JButton#setMargin(new Insets(0,0,0,0));

____________

http://reader.imagero.com the best java image reader.


 
Jo





PostPosted: 2004-4-12 1:38:00 Top

java-programmer >> Remove "Padding" from GridLayout/Buttons "ak" <email***@***.com> wrote in message news:c5bvbn$dg6$email***@***.com...
> > Unfortunately, nomatter what I try, I can't seem to get each icon to sit
> > side by side (so that there's no gap between them). Currently there's an
> > approximately 5 pixel gap between each GIF image.
>
> JButton#setMargin(new Insets(0,0,0,0));

Sorry I forgot to say that I've tried that too:

grid_button.setMargin(new Insets(0, 0, 0, 0));

... but that hasn't worked either.


 
 
ak





PostPosted: 2004-4-12 2:26:00 Top

java-programmer >> Remove "Padding" from GridLayout/Buttons > > > Unfortunately, nomatter what I try, I can't seem to get each icon to
sit
> > > side by side (so that there's no gap between them). Currently there's
an
> > > approximately 5 pixel gap between each GIF image.
> >
> > JButton#setMargin(new Insets(0,0,0,0));
>
> Sorry I forgot to say that I've tried that too:
>
> grid_button.setMargin(new Insets(0, 0, 0, 0));
>
> ... but that hasn't worked either.

then try GridLayout#setHgap and setVgap

____________

http://reader.imagero.com the best java image reader.


 
 
Jo





PostPosted: 2004-4-12 3:06:00 Top

java-programmer >> Remove "Padding" from GridLayout/Buttons "ak" <email***@***.com> wrote in message news:c5c2js$grc$email***@***.com...
> > > > Unfortunately, nomatter what I try, I can't seem to get each icon to
> sit
> > > > side by side (so that there's no gap between them). Currently
there's
> an
> > > > approximately 5 pixel gap between each GIF image.
> > >
> > > JButton#setMargin(new Insets(0,0,0,0));
> >
> > Sorry I forgot to say that I've tried that too:
> >
> > grid_button.setMargin(new Insets(0, 0, 0, 0));
> >
> > ... but that hasn't worked either.
>
> then try GridLayout#setHgap and setVgap

Nope doesn't work either I use:

_board_panel = new JPanel(new GridLayout(_y_size, _x_size, 0, 0));

... where the 3rd and 4th parameters are HGap and VGap...

This is very annoying.


 
 
ak





PostPosted: 2004-4-12 5:50:00 Top

java-programmer >> Remove "Padding" from GridLayout/Buttons > > > > > approximately 5 pixel gap between each GIF image.
> > > >
> > > > JButton#setMargin(new Insets(0,0,0,0));
> > >
> > > Sorry I forgot to say that I've tried that too:
> > >
> > > grid_button.setMargin(new Insets(0, 0, 0, 0));
> > >
> > > ... but that hasn't worked either.
> >
> > then try GridLayout#setHgap and setVgap
>
> Nope doesn't work either I use:
>
> _board_panel = new JPanel(new GridLayout(_y_size, _x_size, 0, 0));
>
> ... where the 3rd and 4th parameters are HGap and VGap...
>
> This is very annoying.

I think it is time to show us appropriate piece of your code.

____________

http://reader.imagero.com the best java image reader.


 
 
Jo





PostPosted: 2004-4-12 6:13:00 Top

java-programmer >> Remove "Padding" from GridLayout/Buttons "ak" <email***@***.com> wrote in message news:c5cehi$tga$email***@***.com...
> > > > > > approximately 5 pixel gap between each GIF image.
> > > > >
> > > > > JButton#setMargin(new Insets(0,0,0,0));
> > > >
> > > > Sorry I forgot to say that I've tried that too:
> > > >
> > > > grid_button.setMargin(new Insets(0, 0, 0, 0));
> > > >
> > > > ... but that hasn't worked either.
> > >
> > > then try GridLayout#setHgap and setVgap
> >
> > Nope doesn't work either I use:
> >
> > _board_panel = new JPanel(new GridLayout(_y_size, _x_size, 0, 0));
> >
> > ... where the 3rd and 4th parameters are HGap and VGap...
> >
> > This is very annoying.
>
> I think it is time to show us appropriate piece of your code.

It's OK I managed to get round it by scrapping using JButtons and using the
ImageViewer class mentioned in my other thread. Thanks anyway.