Stop Painting over JComboBoxes?
I'm programming a game in Java (MasterMind) that uses simple graphics, and JComboBox to get inputs. The problem is that the graphics "paint over" the options in my JComboBoxes. When I mouse hover over the options, the problem fixes itself, but the initial graphics getting in the way is annoying. My code is kind of a mess so far, so it would probably be better to just post a screenshot, since I haven't made any sense so far:
As you can see, the colored pegs get in the way of my selections. Any way around this? Any help would be greatly appreciated... my project is due Tuesday! Thanks in advance!
The boutique server has really gotten its nickers in a
twist his morning. - My first reply got 'lost' at first,
so I rewrote it and here I am with two.
I suspect that you are adding standard components/
layoutmanagers to the container that you have
overridden the paint/update methods for ( ? )
If that is the case I can only wish you good luck;
I have naver been able to find a failsafe method for
making that mixture work. The only component I have
been able to use like that is the popUpMenu, and that
might be an option for you.
If not, then you should zip your source code (however
messy) and post it here so we can have a look at it.
Here's my Code... (6 classes, MasterMind.java is where all the magic happens though).
Please help! Thanks!
I was right in my guess; in your MasterMind JFrame
you add your comboboxes to the container that you
have overridden the paint method for. The game
works 'fine' when I pull the frame in the right side,
increasing the width so the comboboxes land outside
Judging from your code you shouldn't have any problems
replacing the comboBox strategy with a popupMenu
that, on a rightButtonClick, appearred in one of four
squares laid out horisonatlly over one line of peg-holes.
Or the more longwinded solution where you build the
whole gameBoard up with panels. Then you can at
least keep the comboBoxes.
...but the ComboBoxes are in a JPanel. What do you mean exactly? (regarding the "long winded" solution)
As far as I can see that JPanel is added to the container
thet you have overridden the paint() method for.
The long winded solution is converting the game board,
that currently is being drawn 'manually' to a setup (e.g.
with a boxLayout) where all the squares on the game-
board are JPanels. The panel that will contain the
comboboxes will then be shifted upwards during the
guess-progression. Also; the colorCircles could be
replaced by iconImages.
I am pretty sure that this setup will work, and I even
beleive it will reduce & simplyfy the code.
Thanks for the info sjalle. The project is due Tuesday, so I think I'm just going to live with my comboBoxes, but I appreciate your advice. If I get more time, I might try that setup. Thanks again.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL