Painting components on Canvas

I'm making a game that doesn't rely on layouts, containers, etc. Just a Canvas and a paint( Graphics ) override where the game is drawn. In the menu system for my game, I need a combo box. I don't want to implement one as it'd be kinda difficult, scrollbars on popup windows, etc. So, I would like to use the Swing version, JComboBox. Any suggestions on how?
I've tried
g.translate( tx, ty );
mCmbTime.paint( g );
g.translate( -tx, -ty );where mCmbTime is a JComboBox of course. Well, this displays a grey box to the Canvas. At least the box is visible, but the actual component does not seem to be drawn. BTW, before I do this i do:
setBounds( 0, 0, 75, 25 );
setVisible( true );Welp, any help would be appreciated.
Thanks

You post no code so we can't guess what you doing
wrong (at least I can't). Theres no trick involved.
You would simply do:It's more of a theoretical question than a "my program doesn't work" question. So it's hard to narrow it down to a segment of code.
JComboBox comboBox = new JComboBox(....);
comboBox.setBounds(....);
panel.add( comboBox );I don't want to add it, just use it.
Of course you have to make sure you don't paint over
top of it in your game.Exactly the question, how do I paint it on top and use it's features, drop down list, etc.
I'm not sure why you need to put the combobox in the
same container as the game. Why not just create aIt's in the menu system before the game actually starts. I want to use it in a custom form where I already have created my own lightweight radio buttons and checkboxes. I just don't want to have to create my own combo box, and I think the Swing version will look just fine.
panel with a border layout. Add the the combobox to
the North and add your game JPanel to the center.It's not a regular application. The point is I'm painting EVERYTHING! And now I just want to put a combo box in a particular place on a JPanel and have it work like normal. Is this possible? I would think so considering Swing is a lightweight gui set anyway and it works like this by design. I would like a response from someone that has done this before.
Thanks for the reply.

Similar Messages

  • Trying to do something very strange with layouts and painting components

    I'm trying to do something very strange with changing the layout of a container, then painting it to a bufferedImage and changing it back again so nothing has changed. However, I am unable to get the image i want of this container in a new layout. Consider it a preview function of the different layouts. Anyway. I've tried everything i know about swing and have come up empty. There is probably a better way to do what i am trying to do, i just don't know how.
    If someone could have a look perhaps and help me out i would be much appreciative.
    Here is a self contained small demo of my conundrum.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics2D;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import javax.swing.BoxLayout;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.border.LineBorder;
    // what is should do is when you click on the button "click me" it should place a image on the panel of the buttons in a
    // horizontal fashion. Instead it shows the size that the image should be, but there is no image.
    public class ChangeLayoutAndPaint
         private static JPanel panel;
         private static JLabel label;
         public static void main(String[] args)
              // the panel spread out vertically
              panel = new JPanel();
              panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
              // the buttons in the panel
              JButton b1, b2, b3;
              panel.add(b1 = new JButton("One"));
              panel.add(b2 = new JButton("Two"));
              panel.add(b3 = new JButton("Three"));
              b1.setEnabled(false);
              b2.setEnabled(false);
              b3.setEnabled(false);
              // the label with a border around it to show size in a temp panel with flowlayout to not stuff around
              // with the actual size we want.
              JPanel thingy = new JPanel();
              label = new JLabel();
              label.setBorder(new LineBorder(Color.black));
              thingy.add(label);
              // the button to make things go
              JButton button = new JButton("click me");
              button.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e)
                        //change layout
                        panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
                        panel.doLayout();
                        //get image
                        BufferedImage image = new BufferedImage(panel.getPreferredSize().width, panel.getPreferredSize().height, BufferedImage.TYPE_INT_ARGB);
                        Graphics2D g = image.createGraphics();
                        panel.paintComponents(g);
                        g.dispose();
                        //set icon of jlabel
                        label.setIcon(new ImageIcon(image));
                        //change back
                        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                        panel.doLayout();
              // the frame
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(400,200);
              frame.setLocation(100,100);
              frame.getContentPane().add(panel, BorderLayout.NORTH);
              frame.getContentPane().add(thingy, BorderLayout.CENTER);
              frame.getContentPane().add(button, BorderLayout.SOUTH);
              frame.setVisible(true);
    }

    Looks like you didn't read the API for Container#doLayout().
    Causes this container to lay out its components. Most programs should not call this method directly, but should invoke the validate method instead.
    There's also a concurrency issue here in that the panel's components may be painted to the image before revalidation completes. And your GUI, like any Swing GUI, should be constructed and shown on the EDT.
    Try this for size -- it could be better, but I've made the minimum possible changes in your code:import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics2D;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import javax.swing.BoxLayout;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.border.LineBorder;
    public class ChangeLayoutAndPaint {
      private static JPanel panel;
      private static JLabel label;
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            // the panel spread out vertically
            panel = new JPanel();
            panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
            // the buttons in the panel
            JButton b1, b2, b3;
            panel.add(b1 = new JButton("One"));
            panel.add(b2 = new JButton("Two"));
            panel.add(b3 = new JButton("Three"));
            b1.setEnabled(false);
            b2.setEnabled(false);
            b3.setEnabled(false);
            // the label with a border around it to show size in a temp panel with flowlayout to not stuff around
            // with the actual size we want.
            JPanel thingy = new JPanel();
            label = new JLabel();
            // label.setBorder(new LineBorder(Color.black));
            thingy.add(label);
            // the button to make things go
            JButton button = new JButton("click me");
            button.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                //change layout
                panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
                //panel.doLayout();
                panel.revalidate();
                SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                    //get image
                    BufferedImage image = new BufferedImage(panel.getPreferredSize().width,
                        panel.getPreferredSize().height, BufferedImage.TYPE_INT_ARGB);
                    Graphics2D g = image.createGraphics();
                    panel.paintComponents(g);
                    g.dispose();
                    //set icon of jlabel
                    label.setIcon(new ImageIcon(image));
                    //change back
                    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                    //panel.doLayout();
                    panel.revalidate();
            // the frame
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(400, 200);
            frame.setLocation(100, 100);
            frame.getContentPane().add(panel, BorderLayout.NORTH);
            frame.getContentPane().add(thingy, BorderLayout.CENTER);
            frame.getContentPane().add(button, BorderLayout.SOUTH);
            frame.setVisible(true);
    }db
    edit I prefer this:import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    public class LayoutAndPaint {
      JPanel panel;
      JLabel label;
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            new LayoutAndPaint().makeUI();
      public void makeUI() {
        JButton one = new JButton("One");
        JButton two = new JButton("Two");
        JButton three = new JButton("Three");
        one.setEnabled(false);
        two.setEnabled(false);
        three.setEnabled(false);
        panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        panel.add(one);
        panel.add(two);
        panel.add(three);
        label = new JLabel();
        JButton button = new JButton("Click");
        button.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            layoutAndPaint();
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 400);
        frame.add(panel, BorderLayout.NORTH);
        frame.add(label, BorderLayout.CENTER);
        frame.add(button, BorderLayout.SOUTH);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      private void layoutAndPaint() {
        panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
        panel.revalidate();
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            BufferedImage image = new BufferedImage(panel.getPreferredSize().width,
                panel.getPreferredSize().height, BufferedImage.TYPE_INT_ARGB);
            Graphics g = image.createGraphics();
            panel.paintComponents(g);
            g.dispose();
            label.setIcon(new ImageIcon(image));
            panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
            panel.revalidate();
    }db
    Edited by: DarrylBurke

  • Paint bucket tool not painting color on canvas

    Ok - I'm new to photoshop (I just got cs4) and can't seem to get the paint bucket tool to paint the background.  I've started out with a new canvas, selected paint bucket and color from color menu on right side.  Foreground is selected and the paint bucket tool is showing on my cursor - when I click on it over my canvas I expected it to change to the color I selected and it does nothing.  Help??

    I am having the same problem and have checked the mode.  Normal.  Still not working- I have tried eve
    rything includig unlocking the layer- checking the opacity and tolerance.
    using it with other photos and still nothing.

  • What's the chain of methods called for painting components?

    Hi, I'm trying to find out at what point components are painted within a container, as in what methods are being called for that component to be rendered to the graphics context.
    I've tried watching for calls going to paint, paintAll and paintComponents, but if a component has been added to a container it seems that even if I override all of those methods of the container the components that have been added still get displayed.
    So I suppose I have two questions:
    * - What is the chain of methods called when a container is told to paint/repaint itself?
    * - What are the purpose of paintAll & paintComponents, I can't find anything that actually uses these calls.
    Thanks in advance,
    L

    Well it seems that the paint method of the component is being called from sun.awt.RepaintArea.paint(...) which itself is being kicked off from handling an event that's been thrown.
    That's clearer now....but has anyone seen when paintAll, paintComponents or the printXXX counterparts have actually been called by a part Sun's code? I can see how they (Sun) would advocate a practice lke this, but it would seem kinda lame for them to suggest it and then for them not to use it themselves.....that's why I think there's probably something in the JRE that does call these methods at sometime....can anyone cast some light on this?

  • Painting the outer canvas background?

    I would like to change the colour of my outer canvas how is this done? I thought I could just pick a colour and with my paint bucket tool and double click on the outer canvas but nothing happens?
    Basically i would like the outer canvas to be the same colour as the main page.
    I am using photoshop Cs3 extended for Mac OSX 10.4
    lister

    right-click (or command-click) in the outer canvas, and watch for the pop-up menu options.

  • Painting components to buffers

    Hi,
    My class, GamePanel, is extending JPanel and implementing Runnable, therefore all my painting is done in run(). I am using a buffer to draw images on, I would also like to draw Component�s on it as well. Here is the code I�m using to draw the Component�s:
    From gameRender()
    // Get all the components
    Component[] comms=this.getComponents();
    // Go round all
    for (int i=0;i<comms.length;i++)
    System.out.println("Swing component name: "+comms.getName());
         // Paint it on here
         comms[i].paint(g);
    Where g is the BufferedImage.getGraphics().
    Then in another method also call from run(), the buffer is drawn on it the panel.
    From paintScreen()
    // Get the graphics from the panel
    Graphics g=super.getGraphics();
    // If the graphic and the buffer are not null
    if (g!=null&&buffer!=null)
         // Draw the buffer
    g.drawImage(buffer,0,0,null);
    // Sync the display
    Toolkit.getDefaultToolkit().sync();
    // Dispose of the graphics
    g.dispose();However, no components are painted.
    Is there any way this can be done?
    Thanks
    Luke

    I�ve managed to do something that seems to work now:
    protected void paintScreen()
         try
              // Get the graphics from the panel
              Graphics g=super.getGraphics();
              // If the graphic and the buffer are not null
              if (g!=null&&buffer!=null)
                   // Draw the buffer
                   //g.drawImage(buffer,0,0,null);
                   paintComponent(g);
              // Sync the display
              Toolkit.getDefaultToolkit().sync();
              // Dispose of the graphics
              g.dispose();
         } catch (Exception ex) {}
    protected void paintComponent(Graphics g)
         if (buffer!=null)
              // Get the buffer graphics
              Graphics bufG=buffer.getGraphics();
              // Paint the border to the buffer
              super.paintBorder(bufG);
              // Paint the children to the buffer
              super.paintChildren(bufG);
              // Draw the buffer
              g.drawImage(buffer,0,0,null);
    }I should properly dispose of bufG in panitComponent(), and I�m not sure how proper it is as the tutorials did advise against invoking the paintBorder() and paintChildren().
    The other thing I need to do I the class is tiling of the image, I thought I mencion that here instead of starting a new thread.
    I have a class, Backdrop, that draws an image using a start Point object, each time a call to moveXxx() is made, the start point is translated, - or + depeding on the direction.
    At the moment, the image is drawn onto the background colour, but I would like to tile that image over the screen to fill in the gaps, if you see what I mean.
    One idea I did have is , each time draw() is called, to move the start point, in intervals of image width and height, until both the x and y or less then or equal to 0, this would put the image into the top left hand corner, perhaps further depending on where the point started out. Once the image is in the corner, some kind of loop can be used to draw it up and down the owner panel.
    What do you think? I just came up with that while writing.

  • How to resize painted components

    Hi All,
    I am working on a simple project called "WhiteBoard" which is veryu similar to MS-Paint. Could anyone please tell me how to resize the components which I have drawn on the panel. Thanks in advance.
    Regards,
    Shankar.

    Cast the Graphics instance passed to the paintComponent() method of your board to a Graphics2D.
    Then use the scale(double sx, double sy) method of the Graphics2D instance to zoom
    your board in or out.
    IMPORTANT NOTE: If you use a mouse listener on the board, you'll have to convert the mouse
    coordinates according to the zoom factor.

  • How to use form components in canvas

    Hai folks
    Im bit cofused here. Some say that v can use forms in canvas and some say cant. Im in a hurry in developing a real time appln. Please any one come up with a solution. Is it difficult to use J2ME Polish.

    Hi,
    the installer jar is a jar file that needs to be un-jarred, usually by double clicking the jar file. Once you (install) un-jar the
    1) For example, if you download the latest solutions catalog from
    https://blueprints.dev.java.net/servlets/ProjectDocumentList?folderID=4144&expandFolder=4144&folderID=0
    you will download bpcatalog-ee5-ea-0.6-installer.jar
    2) then you have to install/unjar it
    To Install: Double-click the jar file bpcatalog-ee5-ea-0.6-installer.jar, or run 'java -jar bpcatalog-ee5-ea-0.6-installer.jar'      
    3)This creates a folder bpcatalog-ee5-ea-0.6/ which has the contents of the blueprints solutions catalog, including the JSF component libraries.
    4) then if you want to use a JSF component library such as bp-ui-14.jar which contains the calendar component, then move/copy the bp-ui-14.jar to your application that you want to us it in.
    Then you use it like any JSF component library (see the links I put on previous posting if need more detail on that)
    I think the confusion you were having is that you were using the installation jar bpcatalog-1.0.1_01-installer.jar instead of the JSF component library bp-ui-14.jar in your app?
    hth,
    Sean
    Thank you for Reply.
    hen i use
    "bpcatalog-1.0.1_01-installer.jar" in
    my projects lib folder its not working
    an exception occurred
    Jan 4, 2007 6:01:49 AM
    org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet jsp threw
    exception
    org.apache.jasper.JasperException: The absolute uri:
    http://java.sun.com/blueprints/ui/14 cannot be
    resolved in either web.xml or the jar files deployed
    with this application
    at
    t
    org.apache.jasper.compiler.DefaultErrorHandler.jspErro
    r(DefaultErrorHandler.java:50)....
    can you tell me what are all the java blueprint jar
    file should be placed in my project....
    Since bpcatalog-1.0.1_01-installer.jar is in
    installation type...... plz tell me a step by step
    process....

  • Paint components on a graphics

    Hi,
    I have made the following:
    public class Pmsg extends Panel{
    public Pmsg()
    super();
    public paint(g)
    g.drawString("http://www.java.sun.com",10,50);
    g.drawLine(10,50,120,50);
    My problem is that I want to make the link http://www.java.sun.com clickable. I tried to paint a component (label) to my graphics but I failed.
    Does anyone know how to do this?
    Have a nice Day,
    Pieter Pareit

    Hi,
    Create a panel exclusively for the hyperlink and add it to your main panel. And write a mouselistener to trap the mouseClicked event and on that event call AppletContext's showDocument() method , passing the url and the target.
    JP

  • Painting on canvas in native cocoa

    Hi Friends,
    I need a make a java canvas in which i have to paint thumbnail images by native cocoa code.
    I had got drawing surface(ds) and drawing surface interface(dsi).Also i am able to read the thumbnail images but donot know how to paint images in canvas using cocoa.
    Please suggest and if possible give some example or code sample.
    Thanks in advance.

    the bare minimum to render to a fullscreen frame in the fastest way possible...
    Frame f = new Frame();
    f.getGraphicsConfiguration().getDefaultDevice().setFullScreenWindow(f);
    f.createBufferStrategy(2);
    BufferStrategy bs = f.getBufferStrategy();
    Random r = new Random();
    while(true)
       Graphics g = bs.getDrawGraphics();
       g.setColor(new Color(r.nextInt));
       g.fillRect(0,0,getWidth(),getHeight());
       g.dispose();
       bs.show();
    }

  • Native Canvas Painting and Refresh

    Hi,
    I have a project where I get live video from a firewire camera, and paint it to an awt Canvas natively using JNI. I need additional items painted on the canvas (on top of the video), like a pair of crosshairs and rulers to measure certain widths, etc. The software tracks an object moving across the screen, so the crosshairs need to be moved around and refreshed often.
    I am getting a strange problem - the natively painted video is working just fine, but the painted objects are not refreshing properly. For example, instead of getting a crosshair that moves around the screen, I get a trail of crosshairs. And underneath the crosshairs, the video is refreshing just fine. What's going on? I'm using libXv, an X-windows extension to paint YUV4:2:2 camera buffers directly to the screen.
    Here are relevant class snippets:
    public class NativeCanvas extends Canvas{
        public void update(Graphics g)                 <-- overridden to eliminate flicker
            paint(g);
        public native void paint(Graphics g);         <-- here's the native video drawing function
    public class CanvasWithOverlays extends NativeCanvas
        public void paint(Graphics g)
               super.paint();
               Graphics2D g2 = (Graphics2D)g;
               //(paint crosshairs, etc)
    } Any help will be greatly appreciated. Thanks very much!
    --Ismail Degani
    High Energy Synchrotron Source
    Cornell University

    Hi,
    I'm not sure how the crosshairs can be out of sync with the video stream - the canvas paint routines paint the video frame natively, and then paint the crosshairs. It's all sequential -
    super.paint();    // goes into a native function XvPutImage that quickly blits the frame on screen
    Graphics2D g2 = (Graphics2D)g;          
    //(paint crosshairs, etc) This should work properly with the Event Queue, to the best of my knowledge. I schedule a TimerTask that continually calls the repaint() method to refresh the video:
    public class LiveVideoPainter extends TimerTask
        static Logger logger = Logger.getLogger(LiveVideoPainter.class.getName());
        NativeCanvas nc;
        VideoDataSource vs;
        public LiveVideoPainter(NativeCanvas nc, VideoDataSource vs)
            if(nc == null)  {
                logger.error("The Native Canvas is null!");
                return;
            if(vs == null)  {
                logger.error("The Video Data Source is null!");
                return;
            this.nc = nc;
            this.vs = vs;
        public void run()
            vs.getFrame(nc.buffer);
            nc.repaint();
    } I actually had this same problem when designing this application with C++ using the Qt windowing toolkit a year ago. Basically, if I called XvPutimage, and then called regular X drawing routines like XDrawLine etc in a loop, it would draw successfully, but never refresh properly:
    while(true)
    get_decompressed_frame(buf);
    xv_image=XvCreateImage(display,info[0].base_id, XV_UYVY, (char*)buf, 1024, 768);
    XvPutImage(display, info[0].base_id, window, gc, xv_image,
                       0,0,1024,768,
                       0,0, 1024,768);
    if(crossHairDisplayed)
    // Draw Horizontal CrossHair                                                                                                                                                           
                XDrawLine(display, window, gc,
                          0,   (int)(DataSource::pixPerMicron*DataSource :: crossY + DataSource::zcenY),
                          1024,(int)(DataSource::pixPerMicron*DataSource :: crossY + DataSource::zcenY));
                // Draw Vertical CrossHair                                                                                                                                                             
                XDrawLine(display, window, gc,
                          (int)(DataSource::pixPerMicron*DataSource :: crossX + DataSource::zcenX), 0,
                          (int)(DataSource::pixPerMicron*DataSource :: crossX + DataSource::zcenX) , 768);
    }In this code bit, the crosshairs should move when the DataSource object changes member variables, line CrossX. But, the old crosshairs would not go away until the window was moved or resized. I'd get two crosshairs on the screen. I had to use a hack from the xwindows utility xrefresh everytime the crosshairs changed. It essentially simulated an x-window that opened over the Qt window, and then immediately closed. This worked well, but I thought I'd be free of that hack when I moved to java and JNI. Isn't this bizarre? Why would the window hold on to the old crosshair even when the varialbes change and there isn't any code that repaints it there after the video frame gets blitted?
    hack adapted from xrefresh.c:
          if(newCrossHair)
                              Visual visual;
                      XSetWindowAttributes xswa;
                      Display *dpy;
                      unsigned long mask = 0;
                      int screen;
                      Window win;
                      if ((dpy = XOpenDisplay(NULL)) == NULL) {
                        fprintf (stderr, "unable to open display\n");
                        return;
                      screen = DefaultScreen (dpy);
                      xswa.background_pixmap = ParentRelative;
                      mask |= CWBackPixmap;
                      xswa.override_redirect = True;
                      xswa.backing_store = NotUseful;
                      xswa.save_under = False;
                      mask |= (CWOverrideRedirect | CWBackingStore | CWSaveUnder);
                      visual.visualid = CopyFromParent;
                      win = XCreateWindow(dpy, DefaultRootWindow(dpy), 400, 600, 1, 1,
                                          0, DefaultDepth(dpy, screen), InputOutput, &visual, mask, &xswa);
                      XMapWindow (dpy, win);
                      /* the following will free the color that we might have allocateded */
                      XCloseDisplay (dpy);
                      newCrossHair = false;
          } Any ideas? There's probably just some type of refresh call I need to use.
    --Ismail                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Not able to see components on Xcelsius canvas

    Hello friends,
    Sometimes when I am in design mode of Xcelsius 2008, I am not able to see any component on my canvas but they are all in my component panel as well as I can see all functioning properly when I do the preview or export it to SWF. Since I am not able to see components on canvas, I canu2019t make any changes to my existing dashboard and its a show stopper for me. Is it known issue? any service pack or fix pack available for this error? Is this cause of size of XLF file or due to any limitation on number of components on canvas?
    How is my dashboard:
    My dashboard has a tab control with 6 tabs.
    Each tab has 1 accordian, 3 pie charts, 3 list views, 1 line chart, Many checkboxes, and a pair of radio buttons. Format of each tab is exactly same.
    Size of my XLF file now is 1.5 MB
    What I tried:
    I checked that global invisible button is not checked.
    I tried closing xcelsius and opening it again with same XLF file.
    I tried deleting registries folder from machine and restarting machine.
    I tried unistalling Xcelsius and install again.
    I tried the same with SP1.
    but no success till now. Any pointers will be appreciated.
    Thanks.

    Hi,
    I would suggest you posting this in the Xcelsius forum.
    Ingo

  • Painting slow

    Hello everybody!
    I have a problem with painting in my canvas. I�m trying to do something like a Flash presentation.
    What I have is a big JPanel With 12 canvas and I want to paint the first canvas, wait one second and paint the second canvas, wait anonther second and so on.
    My way of doing that is calling a method for waiting between the calls of the repaint for each canvas.
    The problem is all the canvas get paint at the same time and not one by one, or, at least all the canvas are displaying at the same time and what I want is the canvas to be displayed slowly.
    Can anybody help me???
    thx and sorry for my english

    First of all you should mix AWT components with Swing components. Use a JComponent of JPanel to hold you images.
    big JPanel With 12 canvas and I want to paint the first canvas,Use a [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]Card Layout to hold individual components
    Then use a [url http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html]Swing Timer to change the component as required.

  • Image not showing on Canvas in a JFrame

    Hi.
    I've got a problem with painting on a Canvas. I initialize a full-screen JFrame with a Canvas like this:
    final Rectangle screenRect = new Rectangle(tk.getScreenSize());
                final BufferedImage screenImage = r.createScreenCapture(screenRect);
                JFrame scrFrame = new JFrame();
                Canvas scrCanvas = new Canvas(){
                    BufferedImage img = new BufferedImage(screenRect.width, screenRect.height, BufferedImage.TYPE_INT_ARGB);
                    Graphics2D img_g = (Graphics2D)img.getGraphics();
                    public void update(Graphics g){
                        paint (img_g);
                        g.drawImage(img, 0, 0, this);
                    public void paint(Graphics g1){
                        Graphics2D g = (Graphics2D)g1;
                        g.drawImage(screenImage, 0, 0, null);
                scrFrame.setUndecorated(true);
                scrFrame.add(scrCanvas);
                scrCanvas.setBounds(screenRect);
                scrCanvas.setMinimumSize(screenRect.getSize());
                scrCanvas.setPreferredSize(screenRect.getSize());
                scrFrame.pack();
                scrFrame.setVisible(true);Then I paint something on the BufferedImage but nothing happens, nor when I call scrCanvas.repaint() or scrFrame.repaint(). It works only when I call scrCanvas.paint(scrCanvas.getGraphics()). But anyway, there has to be a way to do it without repainting, doesn't it? Can someone help me?
    Thanks in advance
    Ond&#345;ej

    Don't mix AWT and Swing components. Change your Canvas to a JPanel.
    To understand why this should not be done, see
    {color:0000ff}http://java.sun.com/products/jfc/tsc/articles/mixing/index.html
    http://java.sun.com/products/jfc/tsc/articles/painting/
    {color}
    db

  • Swing Filemenu below Canvas?

    I am writing a simple program that displays an image encoded in a raw data format. I am new to graphics programming and I am sure that there are better ways to write what I have done, so if anyone has any suggestiois along those lines they would be appreciated.
    My problem comes from my canvas being displayed on top of my menu bar, when file is clicked the menu cannot be seen. Is there some simple whay of fixing this or should I not even be using a canvas in the first place?
    import java.awt.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class SwingingMenu extends JFrame {
         public static void main(String args[]) {
              JFrame f = new SwingingMenu();
              f.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    f.pack();
    f.setVisible(true);
         public SwingingMenu() {
              Menus menu = new Menus();
              Canvas rawImage = null;
              JPanel j = new JPanel();
              RawImageArray rawImageArray = new RawImageArray();
              Container contentPane = getContentPane();
              try{
                   rawImage = new RawImage(128, 128, rawImageArray.generateArray("DB155S.in",128,128));
              catch(IOException e){e.printStackTrace();}
              setJMenuBar(menu);
              j.add(rawImage);
              contentPane.setBackground(Color.white);
              contentPane.setLayout(new BorderLayout());
              contentPane.add(j, BorderLayout.CENTER);
              setTitle("Raw Image Viewer");
    class RawImageArray{
         private static int[][] rawImageArray = null;
         private static DataInputStream in = null;
         public static int[][] generateArray(String fileName, int height, int width)throws IOException{
              rawImageArray = new int[height][width];
              in = new DataInputStream(new FileInputStream(fileName));
              for(int r =0; r<128;r++){
                   for(int c=0; c<128; c++){
                        rawImageArray[r][c] = in.readByte() & 0xff;
              in.close();
              return rawImageArray;
    class Menus extends JMenuBar implements ActionListener{
         JMenuBar bar = null;
         JMenu menu = null;
         JMenuItem item = null;
         public Menus(){
              menu = new JMenu("File");
              item = new JMenuItem("Open");
              item.addActionListener(this);
              menu.add(item);
              item = new JMenuItem("Close");
              item.addActionListener(this);
              menu.add(item);
              bar = new JMenuBar();
              add(menu);
         public void actionPerformed(ActionEvent e)
              String actionCommand = e.getActionCommand();
              System.out.println(actionCommand);
    class RawImage extends Canvas{
         int [][]rawImage = null;
         public RawImage(int height, int width, int[][] newRawImage){
              setSize(height,width);
              rawImage = newRawImage;
         public void paint(Graphics g){
              for(int r =0; r<128;r++){
                        for(int c=0; c<128; c++){
                             if(rawImage[r][c] == 255){
                             g.setColor(Color.black);
                             g.drawLine(c,r,c,r);
                             else if(rawImage[r][c] == 0){
                             g.setColor(Color.white);
                             g.drawLine(c,r,c,r);
    }

    As a general you should not mix AWT components with Swing components.
    Canvas is an AWT component, try using a JPanel instead. Also, in Swing you should override the paintComponent() method not the paint() method.
    If you click on the tutorial link on the left you will find a Swing tutorial that is worth reading (it can also be downloaded).

Maybe you are looking for

  • Why are my events in iCal NOT sorted by calendar? (in the month view))

    I use 5 calendars in iCal (iCloud). Even in iCloud beeing opened in a browser, the events are all mixed up. The events of "Calendar 1" are sometimes above those of "Calendar 2", sometimes below. Same thing with the other calendars. This causes much b

  • No. range not found for  maintenance plan

    Hi Team, I have maintained no. range for maintenance plan in SPRO. However I am getting this error while creating maintenace plan. Thanks

  • Certificate Not Verified for Wifi WPA Enterprise

    Hi all I have a MDM server to deploy profile to all enrolled devices (iPhone4s, iPad...etc) for wifi setting (WPA2 PEAP SSID: M_WEP_ENT). But I found one issue, if users have ever connected to M_WEP_ENT and accepted Certificate. After deploying profi

  • Laptop Connected Wireless = Slow Speed

    I have BT Infinity Option 2 and whilst my speed is great the majority of the time I have a problem when using my laptop via wireless connection, there is a big drop in speed when using wireless is this normal or is there any way to improve the speed.

  • New probs with connecting wirelessly

    I'm looked at various other post, but can't seem to find exactly the same problem (sorry if I didn't look hard enough!) Okay. So, at uni i've been connecting to the net via ethernet. that's fine. At home however I use airport & wireless connection. T