JMenu is behind Canvas. problem ?

I have created a JFrame with a JMenuBar,
I have added a ImageCanvas (sub class of Canvas) in the center of the JFrame
but whenever i click on Menu it appears behind the canvas
what to do pls help?

Hey,
Canvas is an awt component meaning it is a heavyweight
component. The swing components are lightweight.
Thats the problem.
Have a look at the following URL.
http://java.sun.com/products/jfc/tsc/articles/mixing/
It should explain about mixing heavyweight/lightweight
components
Basically you either need to use Frame, Menu and
canvas or JFrame, JMenu and JPanel.
nesAnd heres the important part:
"When a lightweight component overlaps a heavyweight component, the heavyweight component is always on top,
regardless of the relative z-order of the two components."
Use JPanel instead of canvas if your using swing.
regards,
Tim

Similar Messages

  • FW CS4 Canvas problems - PC Vista Home

    Hi
    I have just installed CS4 and am having a few problems with
    Fireworks.
    1. If I have several floating canvases (separate images) and
    I open another image, the image opens behind all the other open
    windows. When I click the new image; it remains behind and obscured
    by all the other canvases and doesn't come to the front as it would
    in any other application.to get the new image to the front, I have
    to close all the other image!! Sometimes I can get the new canvas
    to the front by clicking each and every other canvas once, which
    kind of wakes it up. Does anyone know a way around this?
    2. Similar to above. Often when I open a new image with other
    images already open on separate canvases, the new image loads into
    another already open canvas. This generates a tab on that canvas.
    There doesn't seem to be any control over which canvas it
    populates. It doesn't even load into the last canvas I was using
    before opening it. It seems quite random. If I have many canvases
    open, I have to literally hunt for the new image. Does anyone know
    how to get new opened images to load onto their own canvases?
    3. This is maybe more of a niggle. When I drag a canvas
    around the workspace, the whole canvas turns grey until I release
    the canvas again. This is a pain if I am trying to place an image
    next to another image to reference it.
    1 and 2 above have hampered my productivity so much, I am
    using CS3 again.
    Any help would be much appreciated
    Thanks
    Mr M

    MMisterMM wrote:
    > 1. If I have several floating canvases (separate images)
    and I open another
    > image, the image opens behind all the other open
    windows. When I click the new
    > image; it remains behind and obscured by all the other
    canvases and doesn't
    > come to the front as it would in any other
    application.to get the new image to
    > the front, I have to close all the other image!!
    Sometimes I can get the new
    > canvas to the front by clicking each and every other
    canvas once, which kind of
    > wakes it up. Does anyone know a way around this?
    Why not maximize them so rather than floating document
    windows, they are
    tabbed? Just out of curiosity, why do you have so many opened
    at once?
    > Does anyone know how
    > to get new opened images to load onto their own
    canvases?
    Choose file > open.
    >
    > 3. This is maybe more of a niggle. When I drag a canvas
    around the workspace,
    > the whole canvas turns grey until I release the canvas
    again. This is a pain if
    > I am trying to place an image next to another image to
    reference it.
    Under Preferences > Edit make sure that Preview Drag is
    selected.
    Linda Rathgeber - Adobe Community Expert
    http://www.adobe.com/communities/experts/members/8.html

  • Popup menu appears behind canvas component

    Has anybody encountered this problem?
    I attach the popup menu to the canvas component, like this:
    public void mousePressed(MouseEvent e)
         if (e.getSource() == psuCanvas && e.getButton() == MouseEvent.BUTTON3)
              pmenu.show((Component)psuCanvas, e.getX(), e.getY());
              contextText.setText("Right Click!!!");
    The popup menu is only visible when I click the edge of the Canvas component, that is how I know that the popup is actually showing but behind the Canvas component!!!
    Please help

    You mean your 1 step of calling "JPopupMenu.setDefaultLightWeightPopupEnabled(false);"?
    That method is meant specifically for using popup menus when you are mixing AWT and Swing components. The reason is because of the problem you first posted about. It's a way to get around that problem. But really, it's more of a hack that is used when dealing with old AWT-based components which you can't (or won't), for whatever reason, "update" to Swing versions. (Say from a 3rd-party library).
    It is not recommended to mix AWT and Swing components, as already mentioned. The provided link above is an article that explains the issues with this. The fact that you can doesn't mean you should.
    If you are writing this Canvas subclass yourself, and it's going to be typically used in a Swing application, you will have problems later, most likely. For example, why don't you try puting your Canvas class in a JScrollPane so you can make it bigger then the window and scrollable? You'll have scrollbar visibility issues. Fine, you can use java.awt.ScrollPane, I guess. Then I can think of several things one might do with JLayeredPanes which would create problems as well. And there is no simple "setDefaultLightWeightEnabled()" option to fix those.
    So eventually, as your app, or library, matures, you start running into these problems cuz you are using AWT components where you should be using Swing components, and you start making more hack-like fixes for all these problems like using setDefaultLightWeightPopupEnabled() and explicit sizing instead of layout managers and limiting yourself to what you can do with your components.
    That's why.

  • (another) stacked canvas on content canvas problem

    I've searched the forums for the last 2+ hours and can't find a solution for my problem, although there are hundreds of questions on this subject.
    I have a stacked canvas on top of a content canvas. The canvases share the same window. They also share a data block. I added radio buttons on the main canvas to "show/hide" the stacked (my ultimate goal is to have 2-3 stacked and toggle. When hide, the stacked canvas is hidden, but when i click show, it is not. I understand reading all the posts that the block with focus will display, and I've added both a go_block and go_item prior to the show_view. Below is my code. MEL_DETAILS is content and MEL_LINE_ITEM is stacked.
    IF :stack = 'SHOW_STACK' THEN
    GO_BLOCK('MEL_ITEM');
    GO_ITEM('MEL_ITEM.MIS_PROJECT_NO');
    SHOW_VIEW('MEL_LINE_ITEM');
    SET_VIEW_PROPERTY('MEL_LINE_ITEM', visible, property_true);
    SET_VIEW_PROPERTY('MEL_LINE_ITEM', display_position, 718, 583);
    SET_ITEM_PROPERTY('PROJECTS.STACK',MOUSE_NAVIGATE,PROPERTY_FALSE); -- radio button
    ELSif :stack = 'HIDE_STACK' THEN
    HIDE_VIEW('MEL_LINE_ITEM');
    SET_VIEW_PROPERTY('MEL_LINE_ITEM', visible, property_false);
    SET_ITEM_PROPERTY('PROJECTS.STACK',MOUSE_NAVIGATE,PROPERTY_TRUE);
    END IF;

    user12198246 wrote:
    I've searched the forums for the last 2+ hours and can't find a solution for my problem, although there are hundreds of questions on this subject.
    I have a stacked canvas on top of a content canvas. The canvases share the same window. They also share a data block. I added radio buttons on the main canvas to "show/hide" the stacked (my ultimate goal is to have 2-3 stacked and toggle. When hide, the stacked canvas is hidden, but when i click show, it is not. I understand reading all the posts that the block with focus will display, and I've added both a go_block and go_item prior to the show_view. Below is my code. MEL_DETAILS is content and MEL_LINE_ITEM is stacked.
    IF :stack = 'SHOW_STACK' THEN
    GO_BLOCK('MEL_ITEM');
    GO_ITEM('MEL_ITEM.MIS_PROJECT_NO');
    SHOW_VIEW('MEL_LINE_ITEM');
    SET_VIEW_PROPERTY('MEL_LINE_ITEM', visible, property_true);
    SET_VIEW_PROPERTY('MEL_LINE_ITEM', display_position, 718, 583);
    SET_ITEM_PROPERTY('PROJECTS.STACK',MOUSE_NAVIGATE,PROPERTY_FALSE); -- radio button
    ELSif :stack = 'HIDE_STACK' THEN
    HIDE_VIEW('MEL_LINE_ITEM');
    SET_VIEW_PROPERTY('MEL_LINE_ITEM', visible, property_false);
    SET_ITEM_PROPERTY('PROJECTS.STACK',MOUSE_NAVIGATE,PROPERTY_TRUE);
    END IF;Here, it seems two problem..
    The line..
    SET_VIEW_PROPERTY('MEL_LINE_ITEM', visible, property_true);
    and
    SET_VIEW_PROPERTY('MEL_LINE_ITEM', visible, property_false);No needed
    Hope this helps
    Hamid

  • Another Drag and Drop from horizontal list to canvas problem

    Hi,
    This is vaguely similar to the this
    topic
    but I seem to have made things even more complicated.
    Basic set up is a horizontal list that uses a custom
    component itemrenderer to display a thumbnail and label:
    <?xml version="1.0"?>
    <!-- Thumbnail.mxml -->
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100" height="120" verticalAlign="top" verticalGap="3"
    verticalScrollPolicy="off" horizontalAlign="center"
    backgroundAlpha="0.0" alpha="1.0">
    <mx:Image id="img" height="60" width="80"
    source="assets/{data.file}" scaleContent="true"/>
    <mx:Label text="{data.text}" fontWeight="bold"
    width="100%" textAlign="center"/>
    </mx:VBox>
    The data is loaded up from an external XML file with this
    sort of format:
    <?xml version="1.0" encoding="UTF-8"?>
    <thumbnails>
    <thumb>
    <file>thumb_image_1.jpg</file>
    <text>Thumb 1</text>
    <url>
    http://www.blah.com</url>
    <id>thumb1</id>
    </thumb>
    </thumbnails>
    That's loaded up using the HTTPService and stored in a Model
    thing.
    I've got the dragging from the HL happening quite nicely and
    it drops fine on to the canvas area, code all hack off from the
    help files. The problem I'm having is finding out the data about
    the item I've just dropped, I should at least be able to get the
    source url for the thumbnail and the label text string, but I just
    don't know how to get it. The call back I'm using looks like this:
    private function doDragDrop(event:DragEvent,
    target1:Canvas):void {
    var vX:int = target1.mouseX;
    var vY:int = target1.mouseY;
    var vW:int = target1.width;
    var vH:int = target1.height;
    // follow variables give relative coordinate values so that
    if window size is altered
    // we don't have to do tricky calulations to reset rating
    positions.
    var vRx:Number = vX/vW;
    var vRy:Number = vY/vH;
    Alert.show(event.dragSource + " " + vX + " " + vY + " " +
    vRx + " " + vRy, 'Mouse drop loc', mx.controls.Alert.OK);
    I just don't know how to get the info out of the
    event.dragSource.
    Here's the full mxml:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="srv.send()">
    <mx:Script>
    <![CDATA[
    private function xmlLoaded():void {
    thumbAC = srv.lastResult.thumbnails;
    import mx.core.DragSource;
    import mx.managers.DragManager;
    import mx.events.*;
    import mx.containers.Canvas;
    import mx.controls.Alert;
    // Called when the user clicks the mouse on either colored
    canvas.
    // Initializes the drag.
    private function dragIt(event:MouseEvent, text:String,
    format:String):void {
    // Get the drag initiator component from the event object.
    var dragInitiator:Canvas=Canvas(event.currentTarget);
    // Called if the user dragged a proxy onto the drop target
    canvas.
    private function doDragEnter(event:DragEvent):void {
    // Get the drop target component from the event object.
    var dropTarget:Canvas=Canvas(event.currentTarget);
    DragManager.acceptDragDrop(dropTarget);
    // Called if the target accepts the dragged object and the
    user
    // releases the mouse button while over the canvas.
    // Handles the dragDrop event for the List control.
    private function doDragDrop(event:DragEvent,
    target1:Canvas):void {
    var vX:int = target1.mouseX;
    var vY:int = target1.mouseY;
    // follow variables give relative coordinate values so that
    if window size is altered
    // we don't have to do tricky calulations to reset rating
    positions.
    Alert.show(event.dragSource + " " + vX + " " + vY, 'Mouse
    drop loc', mx.controls.Alert.OK);
    ]]>
    </mx:Script>
    <mx:HTTPService id="srv" url="assets/thumbnails.xml"
    useProxy="false" result="xmlLoaded();"/>
    <mx:Model id="thumbAC"/>
    <mx:Panel height="160" layout="absolute" title="Thumbnail
    Browser" cornerRadius="10" id="thumbScrollBrowser" bottom="10"
    left="10" right="10">
    <mx:HorizontalList x="0" y="10" width="100%"
    height="110" id="thumbBrowser"
    dataProvider="{thumbAC.thumb}"
    dragEnabled="true" rollOverColor="#FFFFFF"
    selectionColor="#ffffff" borderColor="#FFFFFF"
    borderSides="0" borderStyle="none" alpha="1"
    backgroundAlpha="1.0"
    itemRenderer="Thumbnail">
    </mx:HorizontalList>
    </mx:Panel>
    <!-- THIS IS THE WALL -->
    <mx:ArrayCollection id="wallAC"/>
    <mx:Canvas id="myCanvas" backgroundColor="#ffffff"
    cornerRadius="10"
    borderStyle="solid"
    dragEnter="doDragEnter(event);"
    dragDrop="doDragDrop(event, myCanvas);" left="10" right="10"
    top="10" bottom="180">
    </mx:Canvas>
    </mx:Application>
    Thanks for any thoughts.
    Cheers,
    Rob

    This in the drop handler should give you back the XML you
    just dropped:
    var getListData:XML=
    evtDrag.dragSource.dataForFormat("items");

  • Color flicker? Florescent lights? Viewer to Canvas problem?

    Hello everyone,
    I shot on a Sony HZ5u,
    in Smooth Slow Record,
    HDV1080i, 60i
    inside a semi truck bay under fluorescent lighting (I think).
    In both the Viewer and Canvas there is a frame to frame shift in White Balance hue
    from cyan to magenta.
    The issue does not occur outside the bay, so I'm guessing it's due to lighting.
    Now my problem is that the visibility of this is more noticeable in the Canvas
    where there is an extreme flicker. It hurts my eyes. It is very rapid.
    *Is there a reason why it gets worse in the canvas? How can I fix this?
    It is not my monitors, I moved both windows over to each monitor and it's consistent.
    And for anyone who knows, why does this camera, and other cameras, react so drastically to normal fluorescent lighting?
    I have had earlier issues where the color did not flicker but rolled, like a tv static roll, slowly and constantly.
    Thank you for ANY help!
    Landon S.

    No it's the other way around.
    If you shot at 60i/30fps with today's cameras you may not have a problem, even with the old magnetic ballasts with a florescent bulb you're really not at odds with the AC cycle at 30fps. It's when you shot slo-mo and change the frame rate to something that's not divisible into 60Hz that you get in trouble.
    Of course all that changes if the the AC current isn't stable.
    There are little tricks like not using auto white balance, and using proper shutter speeds. I'm not much of a shooter, I've just come across the problem before and understand the cause. I produced a film shoot in a newsroom once where we had to re-light the whole room and bag the florescent lights.
    We ran tests, it's smart to run tests. If you shoot in that place again I would bring in your own lights.

  • Stoke behind text problem?

    Basically i know how to set the stroke to go behind the text, my problem is i dont however want the stoke to get bigger on the outside of the text (like a normal stroke does) i just want it to fill in behind of the text. Anyone got a solution or way to do this?
    For example...
    As you can see ive applied the stroke behind the text. what i dont want though is such a big stroke on the outside of the text? Please help!!

    Billy,
    It is true that you can create the appearance described in post #8 in a simpler way without expanding as follows,
    1) Create the live Type;
    2) In the Appearance palette flyout click Add New Fill and drag it down beneath the Characters;
    3) With the Fill selected in the Appearance palette, change the colour as desired, then Effect>Path>Offset Path by a positive amount sufficient to give you a sufficient filling between the letters, then Effect>Pathfinder>Unite or Merge, then Effect>Path>Offset Path by a negative amount that gives you the desired appearance round the outermost individual letters (the difference between the needed offset applied first and the desired addition to the letters),
    but as I forgot to mention my assumption that you would wish to reshape certain parts of the background transitions, such as S to t, y to C, and C to l, when the overall shape is established. To do that (properly), I believe you will need to expand.
    So, the simplest way may be as described above with 3 steps, and then Object>Expand Appearance and reshape the background transitions between letters if wished/needed.
    Basically it is the same procedure, where the crucial three steps are offset > unite/merge > reversed offset (smaller value).

  • Canvas problem on a s60 device

    Hi i am having a problem displaying a canvas on top of the previous canvas that was displayed. basicly i have tow canvas, one is a full screen canvas and the otehr is simply a rectangle box witha txt inside...
    on the default colour phone emulator i can display both canvas on screen at the same time but on the s60 device it just displays the 2nd canvas with a white background?
    here is the code for the 2nd canvas under the paintFrame method
    public void paint(Graphics g)
            try
    //             g.drawImage(bg,0,0,Graphics.TOP|Graphics.LEFT);
    //             g.drawImage(load[counter],midx,midy,Graphics.VCENTER|Graphics.HCENTER);
                int midy = getHeight() / 2;
                g.setColor(49,65,143);
                g.fillRect(5,midy+15,230, 36);
                g.setColor(255,255,255);
                g.drawString("Connecting to the server. Please wait.", 40,midy+8+15,Graphics.TOP | Graphics.LEFT);
                g.drawImage(load[counter],18,midy+8+19,Graphics.VCENTER|Graphics.HCENTER);
            catch(Exception e)
                    e.printStackTrace();
                    Alert alert = new Alert("error");
                    alert.setString("counter is " + counter);
                    alert.setTimeout(alert.FOREVER);
                    Display.getDisplay(root).setCurrent(alert);
        }All the canvas's are in Threads. i simply call display object to set this canvas has the corrent display.
    I hope someone can help has lately this forum has not been so generous recently to peoples problems. i see alot of threads with absoluetly no response so hope someone here can take 5min of there time to help a fellow j2me developer. Thanks guys

    Ok is it possible to create a thread within a Thread class?i am trying to create a loading screen. At first, i displayed the loadings creen on full screen mode, but the idea was changed by the designer so now i have to display a small loading screen animation whilst the user can still see the previous screen. Similar to a Alert screen.
    i have two sultions:
    as explained above, create another thread from within this thread class.
    Or create an alert screen(Tried this with a gauge and diddnt work properly)
    Which solutution is better or can you find a better solution? cheers

  • Canvas problem FCP4.5

    I can't figure out why the picture fills up the viewer (setting is automatically 77%) and is a small picture in the canvas (setting is 50%). The canvas view's next step up is 100% and that is too much which distorts the picture. In the Pro Training tutorial I bought for this program, the picture filled both the viewer and canvas nicely. Did I change a setting somewhere along the line that I can't find?

    New Discussions ResponsesThe new system for discussions asks that you take the time to mark any posts that have aided you with the tag and the post that provided your answer with the tag. This not only gives points to the posters, but points anyone searching for answers to similar problems to the proper posts. When you mark a post with the tag, it will also mark the thread as Answered. If you receive the solution or answer to your question outside of the thread, then, and only then, at the top of the thread, mark the thread as Answered. This will mark the thread as Answered without marking an individual post as .
    If we use the forums properly they will work well...

  • JMenu pop-up SubMenu problem

    Hi,
    I'm having a problem displaying a submenu on a JMenu. My app has a tree with various nodes. After clicking on one of the nodes, you can either view the menu in pop-up form by right clicking on the node, or from a regular menu at the top of the screen. These menu's are identical and are generated by the same functions except one if pop-up and the other is not.
    Everything works fine, EXCEPT, when opening the pop-up menu, the submenu's do not appear - the "Select Files" item does not even have the submenu arrow next to it. I know this methos is entered and run without failure as I have debugged it but the submenus just do not appear.
    Here is the source:
    JMenuItem[] m_actions m_actions = new JMenuItem[actionNames.length];     // items for display in the popup menu for this object
    JMenu m_selectFiles = new JMenu("Select Files");                    // sub menu for select files option
    public void setMenu(JMenu aMenu, boolean aMultipleSelection) {          
         aMenu.removeAll();
         for(int i=0; i<m_actions.length; i++) {
              if (m_actions[i] instanceof JMenu) {
                   if (!m_actions.getText().equals("Select Files"))
                        aMenu.add((JMenu)m_actions[i]);
                   else                         
                        addSelectMenu (aMenu);                                             
              } else     {
                   aMenu.add(m_actions[i]);
                   if(aMultipleSelection & !m_multipleActions[i])
                        m_actions[i].setEnabled(false);
                        if(!aMultipleSelection & m_permittedActions[i])
                        m_actions[i].setEnabled(true);
    private void addSelectMenu (JMenu aMenu) {
         if (m_selectFiles.getItemCount() > 0) {
              m_selectFiles.removeAll();
         templateSubMenus = new JMenu("Output Templates");          
         if (templateNames == null)
              templateNames = getTemplates();
         else {
              templateNames.removeAllElements();
              templateNames = getTemplates();
         if (templateSubMenus.getItemCount() > 0) {
              templateSubMenus.removeAll();
         JMenu[] templateSubOptions = new JMenu[templateNames.size()];          
         for(int j=0; j<templateNames.size(); j++) {               
              templateSubOptions[j] = new JMenu((String)templateNames.elementAt(j));
              templateSubOptions[j].add(new JMenuItem("Modify"));
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).addActionListener(monListener);
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).setActionCommand("TempModify:"+(String)templateNames.elementAt(j));
              templateSubOptions[j].add(new JMenuItem("Copy"));
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).addActionListener(monListener);
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).setActionCommand("TempCopy:"+(String)templateNames.elementAt(j));
              templateSubOptions[j].add(new JMenuItem("Delete"));
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).addActionListener(monListener);
              templateSubOptions[j].getItem(templateSubOptions[j].getItemCount()-1).setActionCommand("TempDelete:"+(String)templateNames.elementAt(j));
              templateSubMenus.add((JMenu)templateSubOptions[j]);               
         templateSubMenus.addSeparator();
         templateSubMenus.add(new JMenuItem("New Template"));          
         templateSubMenus.getItem(templateSubMenus.getItemCount()-1).addActionListener(monListener);          
         m_selectFiles.add(templateSubMenus);
         aMenu.add((JMenu)m_selectFiles);          
    Any ideas would be greatly appreciated.
    Thanks!!!!!

    Hi,
    I have the same problem. Can anybody help please?
    Thanks,
    Kaveh

  • Loading an image to a Canvas problem.

    I have constructed a simple GUI, with a menu and a Canvas for displaying images(jpg,gif).
    In the menu I have a Load button(menuItem), which is coupled with an ActionPerformed so that the image will be loaded when I choose Load in the menu.
    Here is the problem: When I choose Load, nothing happens the first time. When i hit Load again, the picture is loaded and displayed. Why?
    Code:
    private void LoadActionPerformed(java.awt.event.ActionEvent evt) {
    // Add your handling code here:
    // Loads the image to memory
    Image img=Toolkit.getDefaultToolkit().getImage("c:/radiohit.jpeg");
    //Shows the Canvas Picture
    pictureCanvas.getGraphics().drawImage(img,0,0,pictureCanvas);

    The problem is that the image hasent finished loading when you try painting it.
    make img a member of your class.
    public void LoadActionPerformed(ActionEvent evt) {
    myCanvas.img=Toolkit.getDefaultToolkit().getImage("c:/radiohit.jpeg");
    myCanvas.repaint();
    }and in the canvas class:
    public void paint(Graphics g)
    g.drawImage(img,0,0,this);
    }The call to repaint will not cause the image to get painted, however, the "this" argument in drawImage will cause "this" (the canvas) to get repainted again when the image is fully loaded -and then the image will get painted. You should have your painting code in paint anyway, because if not a system call to paint would cause your image to disappear even though it was allready there. You could also look at the MediaTracker class and the waitForAll method, if you want to know how to wait for an image to be fully loaded.
    Ragnvald Barth
    Software engineer

  • Java3D Disappearing canvas problem

    I have a Canvas3D embedded in a JPanel, which is embedded in a JTabbedPane. When I resize the application, on average about one time out of six or so, the Canvas3D won't repaint properly and I'm left with an empty gray panel.
    The recommended solution to this problem (which hasn't worked for me) is to subclass Canvas3D and override the paint method to call Toolkit.sync().
    I'm using Java 1.5.0_06 and Java3D 1.4 (latest "release" build)
    Here's some sample code to reproduce the problem:
        public static void main(String[] args){
            // Main Application Frame
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            // Frame contains one component - a tabbed pane
            JTabbedPane tabbedPane = new JTabbedPane();
            frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
            // First tab in tabbed pane is blank blue panel
            JPanel bluePanel = new JPanel();
            bluePanel.setBackground(Color.BLUE);
            tabbedPane.add("Blank", bluePanel);
            // Second tab in tabbed pane contains the canvas enclosed in a JPanel
            JPanel panel3D = new JPanel(new BorderLayout());
            Canvas3D canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration()){
                public void paint(Graphics g) {
                    super.paint(g);
                    Toolkit.getDefaultToolkit().sync();
            panel3D.add(canvas3D, BorderLayout.CENTER);
            tabbedPane.add("3D", panel3D);
            // Create a simple universe with a root branch grouop
            SimpleUniverse universe = new SimpleUniverse(canvas3D);
            universe.getViewingPlatform().setNominalViewingTransform();
            BranchGroup bgRoot = new BranchGroup();
            // Create a colored cube that is slightly rotated
            TransformGroup tg = new TransformGroup();
            Transform3D transform = new Transform3D();
            transform.rotY(Math.PI / 8.0d);
            tg.setTransform(transform);
            tg.addChild(new ColorCube(0.2));
            // Place the cube inside the universe and compile
            bgRoot.addChild(tg);
            bgRoot.compile();
            universe.addBranchGraph(bgRoot);
            // Display the frame
            frame.pack();
            frame.setSize(500,500);
            frame.setVisible(true);
        }

    After experimenting with this for a while, I can confirm this issue happens even if you don't use a JTabbedPane (i.e. you have a Canvas3D inside a JPanel inside a JFrame). Seems to be a race condition of some sort, because the following (ugly) piece of code will solve the problem (for now):
            Canvas3D canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration()){
                public void paint(Graphics g) {
                    try {
                        Thread.sleep(100);
                    } catch (Exception e){}
                    super.paint(g);
    //                Toolkit.getDefaultToolkit().sync();
            };    Would really appreciate input from anyone who has experienced a similar problem. Thanks.

  • Transparent Canvas problem

    Any one know hov i can create a compleatly transparent Canvas?
    Please give me some code :)

    Thanks!!!
    I found that JComponent har a setOpaque(boolean) metod that is very handy. I also found that i could add this component to a JFrame using setGlassPane(component)...Problem sort of fixed

  • Blank Canvas Problem - Newbie

    Just started using Motion today.
    When I start a Tutorial, Template or even a blank file the canvas stays white and won't display anything.
    If I set the video output to my second monitor the project plays back perfectly but still nothing on the canvas.
    I've reinstalled but it still doesn't work.
    I've been through al the prefs etc. and nothing seems to be out of place.
    Any help appreciated.

    I solved this through discussion with phone support.
    I swapped my two 30" monitors about.
    I connected my primary monitor to the second 7300 card.
    I then swapped the 'virtual layout' in monitor prefs so that even if the monitor was connected to card 2 it was set in software to be my primary monitor.
    This solved the problem !!

  • Canvas-problems

    at my home pc i can get the canvas to draw a graph,
    but when i compile and run this exact same java-file at my laptop
    i only see a flash of my graph and
    then it just gets white and this isn't the background.

    im sorry
    it is the background, but it doesnt fix the problem.
    I cant get the canvas to stay visible

Maybe you are looking for

  • Id column in gc buffer busy waits

    Hello, What's the id column show for gc buffer busy or gc current request waits.. I could not find any description for "gc current request". However, Here is what I found in oracle doc .. It's not so clear.. Parameter Description file# See "file#" on

  • My email will not connect when i am connected to wifi

    When my iPhone4 is connected to my wifi network at home or my office, it will no longer connect to mail.  I just get the spinning circle, and "Checking for mail..." message. I've had this for 11.5 months, and it's always been connected to my wifi at

  • Transferring Lightroom 4 from desktop to laptop

    How do i transfer a recentl purchased cop of Lightroom 4 from an old desktop to new laptop. I have registration key, but still wouldn't work.

  • 5 days to deliver mail from BT to @btinternet!

    Has there been some server issues?  Have I got other mail stuck in a queue? Received: from mx1.bt.trclient.com (202.43.5.28) by rgin07.bt.ext.cpcloud.co.uk (8.6.122.06) id 539977C30A2CE123 for [email protected]; Wed, 18 Jun 2014 05:50:53 +0100 Receiv

  • Count how many XML tag existed

    I am new in BI publisher and hope someone can give me some help. I need to display an invoice number and term-sequence_number. If the invoice number has only 1 term_sequence_number, just display the invoice number. However, if the invoice has 2 or mo