JMenuItems drawn over by JPanel. How to fix?

Hi.
When i add my menu to the frame the actual menu bar displays fine. but when you open the menu the items are drawn over by my jpanel.
I tried a way to work around it by adding the menu to the jpanel. when i did this the menu worked and displayed fine, but it wasn't really wanted (it wasn't being mounted to the top of the frame like the title bar, but instead a component centered on the canvas).
I want the menu bar to be positioned like any other gui application and use my jpanel for the drawing area. is there some way to let java know i want to display the menu over the jpanel?
Heres the basic structure of the code i'm using:
public class Simulate extends JApplet implements MouseMotionListener, MouseListener {
  static private JFrame frame;
  private Container content;
  private Display drawing_surface;
  private JMenuBar menu_bar;
  public static void main(String []args) {
    init_frame();
  public Simulate() {
      drawing_surface=new Display();
      setContentPane(drawing_surface);
      content=getContentPane();
      /* add menu items */
  static void init_frame() {
    frame=new JFrame();
    frame.getContentPane().add(new Simulate());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
class Display extends JPanel {
public void paintComponent(Graphics g) {
      paint_buffer(g);
  public void paint_buffer(Graphics g) {
  /* paint here */
}

Swing related questions should be posted in the Swing forum.
Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html]How to Use Menus for a working example.
A JApplet is a top level container you don't add one top level container to another. See the tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/components.html]Swing Components.
Also you should be invoking super.paintComponent(...) in the paintComponent() method. Again, see the tutorial from above for the section on "Custom Painting".

Similar Messages

  • Mail keeps asking for password, over and over and over again. How to fix?

    How do I stop this behavior of Mail?
    I tried disableing my account and resetting it up, but it won't let me do that either. I use Mac OS 10.6.8.

    OK. When you say that Mail doesn’t save the password, are you basing this solely on the fact that Mail keeps asking for it? Or is there something else that makes you believe Mail doesn’t save the password?
    Open /Applications/Utilities/Keychain Access, choose Keychain First Aid from the application menu, and proceed to repair the keychain. If that doesn’t work, try removing the password entry from the keychain and let Mail create it again the next time it asks for it.

  • HT204266 Friend Apple ID has taken over my iPad, how to fix this?

    Whenever I want to update an app, it will always show my friends email and request I put in his password. This makes no sense as he has one app on my iPad and nothing else, and yes, I'm singed in as me on the app store. Even in my purchases it asks me to

    sorry my email is [email protected]
    please help me to fix it
    iam waiting for replays  thanks.

  • Every time I play a video on youtube it sounds like another version of that video is playing five seconds later, (and keeps doing so over and over) any idea how to fix this?

    When I load a video on youtube, it plays, and then it sounds like another version of that video plays 5 seconds later, and after 5 seconds more, another version etc- etc.

    iTunes saves out a new copy of the entire library file every time a change is made to the library. This is not new behavior.
    The slowdowns I have seen like this have ususally been caused by:
    A virus
    or
    Some anti-virus software is incorrectly interpreting the rewriting of the file and is causing a problem.
    Either way, you should definitely update your anti-virus software and definitions to the latest, and run a full scan of your system. If that does not help, you may want to recreate your iTunes library.

  • Fire fox is running slow advice all over internet on how to fix says click menu then select help option there is no help option in the menu

    Surely someone must have tried this before putting up a solution that cannot possibly work

    hello Rusty8899, you'll find the help menu here:

  • How to fix - print cartridge(s) missing or not detected

    have an all-in-one c4280 photosmart, CC210A.  getting message that cartridges are not detected.  Both are properly loaded.  I suspect a sensor is crapped out.  maybe ink over-spray over time?  how to fix??

    I had been printing and the message "Print cartidge missing or not detected" came up. I knew I was in trouble when I tried a new HP cartridge and it didn't change the message. Found this site and I have tried all the steps in the "How to Fix - Print Cartridges missing or not detected" and nothing has worked so far. Also found a thread on another site about how to do a partial reset on your printer. That didn't work either.   I have had the printer 4 years. What are the chances of repairing...and where can I take it to get repaired ....or is it worth it?

  • My storage is mostly full of a category labeled "other." I'm out of memory to the extent that it won't even allow me to update apps. I have moved all photos over to my computer and my music streams through the cloud. Any advice on how to fix this problem?

    My storage is mostly full of a category labeled "other." I'm out of memory to the extent that it won't even allow me to update apps. I have moved all photos over to my computer and my music streams through the cloud. Any advice on how to fix this problem?

    http://discussions.apple.com/thread/3418045?tstart=60

  • How to fix this error "this iPad is not able to complete the activation process. Please press Home and start over. If the issue persists, please visit your nearest Apple Store or Authorized service provider for more information or replacement"?

    How to fix this error "this iPad is not able to complete the activation process. Please press Home and start over. If the issue persists, please visit your nearest Apple Store or Authorized service provider for more information or replacement"? When I plugged in my iPad this popped up!

    Hi csreddy, 
    If you are receiving a message to contact an Apple Retail Store or Authorized Service Provider for help updating from iOS 3, click on the link below to initiate that support:
    Update the iOS software on your iPhone, iPad, and iPod touch - Apple Support
    http://support.apple.com/en-us/HT204204
    Update your device using iTunes
    If you can’t update wirelessly, or if you want to update with iTunes, follow these steps:
    Install the latest version of iTunes on your computer.
    Plug in your device to your computer.
    In iTunes, select your device.
    In the Summary pane, click Check for Update. 
    Click Download and Update.
    If you don't have enough free space to update using iTunes, you'll need to delete content manually from your device.
    Find out what to do if you get other error messages while updating your device.
    Last Modified: Jan 12, 2015
    Apple - Find Locations
    https://locate.apple.com
    Contact Apple for support and service - Apple Support
    http://support.apple.com/en-us/HT201232
    Regards,
    - Judy

  • Trial version of Illustrator CC 2014 takes over my CS6 old version and forces me to use CC 2014 on launch. How to fix?

    Trial version of Illustrator CC 2014 takes over my CS6 old version and forces me to use CC 2014 on launch. How to fix? FIle> get info>won't let me choose >Open this file with CS6. Forces me to use CC 2014 Illustrator which I don't want because I am doing client work in CS6 that I own and I do not have time to try out the CC version.
    I also do not like the black interface in illustrator as I cannot even see the layer icon at the bottom. I won't want to buy it if this is all that's offered.

    You can change the UI brightness in the prefs. Otherwise I'm not clear what your issue is. Handling file associations are operating system basics and you can look them up on a simple web search and from drag&drop onto the launchpad/ dock icon for CS6 to opening the files directly from within AI there sure are enough alternatives, don't you think?
    Mylenium

  • Just purchased the iphone6 and can hardly hear when I get a call, despite volume up, bluetooth off and nothing obstructing device.  This issue is all over the Web, come to find out.  How to fix?

    Just purchased the iphone6 and can hardly hear when I get a call, despite volume up, bluetooth off and nothing obstructing device.  This issue is all over the Web, come to find out.  How to fix?

    Turns out there was a film on the glass side of the phone that I didn't even know was there! All is well now! Yay, cause I'm really liking this phone. Had a blackberry for ever. Thank you for your prompt response. Ann
    Sent from AOL Mobile Mail
    Get the new AOL app: mail.mobile.aol.com

  • HT4061 Hi I dropped my iphone 5 in water last night, it is working but has shadow over the screen how can I get this fixed?

    Hi I dropped my iphone 5 in water last night, it is working but has shadow over the screen how can I get this fixed?

    Probably too late to do anything but replace the device at this point.
    Once electronics get wet, the best thing to do is turn it off and put it in silica gels packs or uncooked rice for a minimum of 72hrs.  Only then should the user attempt to power the device on.

  • HT200116 imovie is trying to open, opens and then the spinning wheel takes over, why and how do I fix this issue?

    imovie is trying to open, opens and then the spinning wheel takes over, why and how do I fix this issue?

    Finder Go menu --> Go To Folder... "~/Library/Preferences", then
    delete iMovie related plist such as "com.apple.iMovieApp.plist" and  "com.apple.iMovie.plist".

  • How get area covered by text drawn on a jpanel?

    I'm trying to get the full area that a string of text covers when drawn on a JPanel. I use the below code and the width seems to be correct, but the height is wrong (I use it to make the mouse cursor change when over it). I can't seem to get the exact location of every pixel of the characters. It's either too low or misses the bottom part (I've been altering the code a lot). What am I doing wrong?
    //Widest line
    int widest = 0;
    int totalHeight = 0;
    //Loop through lines and calculate width and height
    StringTokenizer lines = new StringTokenizer( text, LINE_BREAK );
    //The actual visual bounds of the characters
    Rectangle2D visualBounds = font.createGlyphVector( fontRenderContext, text ).getVisualBounds();
    //Line metrics (info on height, ascent, descent
    LineMetrics metrics = font.getLineMetrics( text, fontRenderContext );
    //Only have one line, so use GlyphVector
    if ( lines.countTokens() == 1 )
         widest = ( int ) visualBounds.getWidth();
         totalHeight = ( int ) visualBounds.getHeight();
    else
         while ( lines.hasMoreTokens() )
              String line = lines.nextToken();
              //Get boundary
              Rectangle2D bounds = font.getStringBounds( line, fontRenderContext );
              //Set the width
              widest = Math.max( widest, ( int ) bounds.getWidth() );
              //Add to the total height
              totalHeight += bounds.getHeight();
         //Need to remove any extra lineheight for last line (since is invisible)
         totalHeight -= ( int ) ( metrics.getHeight() - visualBounds.getHeight() );
    //Set descent
    descent = ( int ) metrics.getDescent();
    //Adjust y for descent as Graphics draws a string from the baseline and we want the bottom
    y = y + descent;
    //Set width, height
    width = widest;
    height = totalHeight;

    DarrylBurke wrote:
    To get a more exact bounding rectangle, use TextLayout.
    [http://forums.sun.com/thread.jspa?threadID=5241409]
    dbThat's weird - it works! The problem is when i use the LineMetrics, the value it gives for getAscent() is actually the text's height! TextLayout has this correctly as the height.

  • Is anyone else having sensory issues since updating to the IOS 7.1.1? My phone is all over the place when trying to scroll or play a game. Know how to fix? It didn't do this till after this update.

    My phone is all over the place when trying to scroll or play a game. Know how to fix? It didn't do this till after this update.

    Do a
    Reset: Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Note: You will not lose any data

  • TC does not have "Access disks over WAN" option, how do I fix this?

    Hello,
    My time capsule has the lastest firmware installed as of 12/28/11. I have it setup with (bridge-mode). There is no option to use the TC over WAN. There is only the option to access TC over WAN using Bonjour. Can someone please explain why this option is not avavible and how to fix it? If anyone needs more information please fell free to ask me.
    Thanks,
    Brett

    If the TC is bridged.. there is no wan port. LOL!!
    So there is no need to access it over wan.. because it doesn't have one.
    You can fix it by using it in router mode.. so it has a wan port again.
    Or.. you can simply access it via port forwarding of port 548 on the existing router.
    You can only remotely access AFP. You cannot access it remotely any other way.. without using vpn that is.

Maybe you are looking for

  • Upgrade from 10.2.0.4 to 11.1.0.6

    Hi, I am planning to upgrade my production database from 10.2.0.4 to 11.1.0.6. I initially started with my development database but i get the following error when i ran the dbupgdiag.sql utility to verify the status of the 10.2.0.4 database as part o

  • How to delete to-do list items in 5800 XM

    I transfered the data from my old PDA to Nokia 5800 XM. Now there are hundreds of to-do list items with showing up every day at the top of to-do list. I would like to delete lots of them. So, i can delete only one at a time. How do I select and delet

  • Java.lang.IllegalStateException

    I am working with typical Model1 JSPs for web interface,Where I am facing 'java.lang.IllegalStateException' problem,In which scenarios it could occur. Thanks Ashok Kumar

  • Integrating MS SQL 2005  using DBAT Connector 9102

    Hi, I am trying to integrate MS SQL 2005 using DBAT Connector 9102 using GTC. My OIM version is 9102. Though the table exist in MS SQL still it is not able to find it. It is able to connect but throwing error that table "test" does not exist. I also

  • Help with making DVD from quicktime movie

    I just made a dvd using IDVD of my FCE sequence. I selected make dvd from movie. The FCE sequence was comprised of two parts. The first part of the time line was a sequence I imported as a quicktime movie and the remaining time line was the edited se