Link to home
Start Free TrialLog in
Avatar of muliLessa
muliLessa

asked on

GridLayout, BackgroundColor

I have a JPanel with a GridLayout, which contains 3rows and 3 cols of JToggleButtons:
        setLayout(new java.awt.GridLayout(iMax,jMax,0,0));
        this.setBackground(Color.white);
        this.setBounds(0,0,ID.toggleX*3,ID.toggleY*3);

The backgroundcolor of the JoggleButtons is currently white.

When compiled in Eclipse, there are grey lines in between the JoggleButtons, when compiled
in NetBeans there are no such lines.

How can I assure that those lines are not displayed?
       
Avatar of colr__
colr__

The location where you compiled it shouldnt matter, do you mean its showing as different in the gui designers? You need to set the background on the content pane to be white as well:

getContentPane().setBackground(Color.white);
Avatar of muliLessa

ASKER

Thx, colr!
...its showing as different in the gui designers: Yes, therefore I think that "something is missing"
in my code, which is "added" in NetBeans, but not in Eclipse.

I tried Your solution, but getContentPane() does not work for a JPanel.
Sorry, try setting the background directly on the JPanel instead
I am doing that (see above: this.setBackground(Color.white);
this is a class which extends JPanel).

I guess that perhaps the background of the gridlayout should be set - but
I don't know how to achieve that.
I suspect it is more likely to be the component which the JPanel has been added to, the content pane of the window itself
The component which contains the JPanel is a LayeredPane, which has (needs to have) the BG-color brown - so it can't be responsible for the grey lines between the gridcomponents.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thx objects! That's it!