Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-29-2007, 01:24 AM
Member
 
Join Date: Dec 2007
Posts: 2
Swingset is on a distinguished road
Selecting a JMenu paints over the JPanel on the content pane
Hi.

As the title says, every time I select a JMenu from the menu bar and menu items drop down, the space taken over by the menu items gets painted over.

An example of it happening can be seen here:



where the gray area is where the Input menu has dropped down.

Does anybody know how to stop this from happening?

Thanks.

.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-29-2007, 02:43 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,124
hardwired is on a distinguished road
Possible areas of trouble may include:
1 — Mixing AWT and Swing (J-prefix) components
2 — improper implementation of paint/paintComponent method overrides.
Need more information to go farther.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-29-2007, 06:29 PM
Member
 
Join Date: Dec 2007
Posts: 2
Swingset is on a distinguished road
Hi.

Cheers for replying.

I'll try and go into a bit more detail.

I've got a class which extends a JPanel.

I've got some boolean variables which can be set by calling methods (e.g. blankScreen). The JPanel's repaint() method is then called.

I've overriden the paintComponent() method to call certain methods dependent on the value of the booleans.

The appropriate method is called using the paingComponent's Graphics object as a parameter.

When the JPanel is painted for the first time when the GUI is created, the painting over effect does not occur. It only seems to happen once it has been repainted.

Thanks for any help people can give.

Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-06-2008, 12:13 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,124
hardwired is on a distinguished road
Make sure you call super to avoid artifacts:
Code:
protected void paintComponent(Graphics g) { super.paintComponent(g); // carry on with custom drawing...
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JFileChooser example (selecting a directory) Java Tip Java Tips 0 03-14-2008 01:02 PM
Selecting parts of an image shaungoater Java 2D 1 12-15-2007 11:06 PM
JMenu calling another Forms/Panels plodos New To Java 2 12-10-2007 09:02 AM
selecting a record in database ramachandran New To Java 0 10-25-2007 08:06 AM
JMenu and JRadioButtonMenuItem doron70 AWT / Swing 3 07-18-2007 07:13 PM


All times are GMT +3. The time now is 01:02 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org