Subclassing Canvas

Hi everyone!
I'm trying to subclass the Canvas class to create a double buffered rectangular area where to draw some image sequence.
This code doesn't work:
public class ImageCanvas extends Canvas {
ImageCanvas () {
this.createBufferStrategy(2);
and I get a "Component must have a valid peer" exception. I tried to add a call to addNotify() before createBufferStrategy(2) but I get a nullPointerException instead.
I'm not a skilled java programmer, so there must be a mistake! Could someone show it to me?
Many many thanks!
Zalexx

I believe that your ImageCanvas must be displayable. See Component.isDisplayable for details.
You may have to supply a Window or a Frame as a parameter to the constructor, or delay setting the buffer strategy until your containment hierarchy is set up.

Similar Messages

  • Problem with Canvas component.

    Hello all,
    I am building a sort of flowcharting software using Swing. The software is standalone. The "flowcharting" component is a sort of canvas, However it does not extend the Canvas class from AWT, but rather extends a JComponent. The paint() method simpy says g.fillRect(color) and this produces the backdrop. Ok, to the point, every once in a while, some components or text will not render at all on this canvas. If if I were to close and load the flowchart, the same component will not render, and usually it is text with user defined fonts that will not render. I would say they render correctly on 80% of the machines on which it has been installed. It may be a font problem, but other text with the same exact font will render. Assuming that the components are instructed to render(I am fairly convinced of this) are there any possible reasons that these components will not render. All components render on my machine, and some will not render on other machines. Has anyone ever dealt with anything like this? Perhaps my canvas should actually subclass Canvas from AWT? Any feedback is much appreciated.
    Thanks.

    Thanks,
    Actually, this canvas overrides the JComponent class and is not an AWT Canvas component. A couple of things I did notice however....
    Maybe overriding JPanel would be more suitable.
    Currently the paint() method is being overridden as opposed to the paintComponent() method. I think overriding paintComponent would be the right thing to do.
    Thanks for help anyways.

  • Combining Canvas subclasses for Animation

    Hi,
    I need to have some sort of surface on which I can put movable objects in order to create an animated visualization.
    I thought of subclassing Canvas for:
    a) having an AnimationCanvas that contains a Vector of objects
    b) having movable objects (let's call them AnimationItem) that can draw themselves.
    Now I have some problems which I wasn't able to solve yet:
    a) How do I make an AnimationItem draw not onto itself but onto the AnimationCanvas object?
    b) I'm getting Null Pointer Exceptions at the moment, when trying to create an offscreen Image for double buffering. I tried to put a private Image and a private Graphics object inside each AnimationItem, then create those in the constructor.
    I'm a little stuck with this graphics stuff, can anyone help me?
    Thanks,
    Robert

    Man that could really be better, but I'm not even close to understand the process! I'm really a beginner with AE, could you try to explain me how to do it?
    I generally work with pre-set animations and include the logo I want in them, so as I don't make the entire composition I don't know how to handle them properly... anyway I believe a little ste-by-step would help!
    thanks again

  • Custom-made components & midp4palm

    Hi all,
    I've developed two simple custom-made components by subclassing canvas. One is a simple button, which you can push with the palm pointer.
    The other is a sort of textfield. The problem arises when I try to input text into this component... the Palm does not have a keyboard! And the little keyboard which pops when you press the dot under the "abc" image does not pop!
    Is there some way to make that keyboard appear?
    Any help would be greatly apreciated.
    Thanks,
    Estanis.

    the current api does not allow text to be placed into the canvas class. i would recommend u to use a textbox class. so if the user clicks on the canvas screen, it will call up the textbox class and allows the user to key in some data.then upon returning back to the canvas class, u can just update the display using repaint method.
    hope this helps.
    regards,
    joseph

  • How can I display an image in AWT Panel

    notes: I can't use swing, don't tell me something relate to swing, I need to use pure AWT

    Load it with [url http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Toolkit.html#createImage(java.net.URL)]Toolkit.createImage or [url http://java.sun.com/j2se/1.5.0/docs/api/javax/imageio/ImageIO.html]ImageIO
    Subclass Canvas
    [url http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Graphics.html#drawImage(java.awt.Image,%20int,%20int,%20java.awt.image.ImageObserver)]Graphics.drawImage

  • Applet based Text Editor

    Hi Genies
    How can i create a Text Editor without using TextArea? I would like to use only AWT not Swing or Java 2. Any Idea ?
    Shan

    The AWT tools are woefully inadequete for creating a text editor. The AWT textarea does not support fonts, colors, custom line wrapping, line numbers, or anything else that would make a good text editor.
    You could do it as an applet, but you would have to create your own text display by subclassing Canvas and writing text to specific locations. You would also have to write your own scrollbar, toolbar, button class that supports icons, etc.
    It is usually just easier to make sure that people have swing installed. If you use a later version of Java, you can also do Java WebStart which will allow you to open and save files on the hard drive if the user chooses them. You can't do that easily with applets (requires signing your applet for $200 per year).
    If you end up writing a text editor, I would suggest putting my syntax highlighting libraries into it:
    http://ostermiller.org/syntax/
    Stephen

  • Graphics 2D in program

    Im new to java and was wondering how id go about using Graphics in a program as apposed to an applet. All of the graphics examples ive seen have been for applets...
    I apologize if this is a very obvious and stupid question...

    At the level of Graphics, there's nothing different between Applet and "regular" application. Every Component is given a Graphics into which it draws its stuff. Therefore, if you want a graphically oriented application, just subclass Canvas, and draw away, and it doesn't matter whether it's an Applet or not.
    BTW, you can make an Applet launchable as a regular application approximately as follows (if you look at Applet's class hierarchy, you find it's just a Panel)
    public class B extends java.applet.Applet {
    ... set up Components for Applet ...
    public void init() {
    ..normal initialization, including Component setup..
    public void start() {
    ..start stuff ...
    ... implement other Applet methods...
    void makeFrame() {
    Frame f = new Frame("Title");
    f.addWindowListener( new WindowAdapter() {
    ... set up listener to close the Frame properly
    f.setLayout(new BorderLayout());
    f.add(this, "Center");
    ... Depending on your application, you might want to
    set up a toolbar in another section of the Frame
    f.pack();
    f.show();
    public static void main(String[] args) {
    ...process args...
    B b = new B();
    b.init();
    b.makeFrame();
    b.start();

  • Canvas copy or subclass not working

    Hi,
    I am trying to copy a canvas from a template form.
    This canvas has -
    1. Frame
    2. Rectangle
    3. List Item
    4. Two Push buttons.
    When I copy this canvas in destination form all the objects are changed to small size, from 100 to 0.1, from 303 to 0.303, all the objects are cluttered.
    I tried creating object library and subclassing the canvas from object library, but with same effect as above.
    Can anyone guide on this?
    Av.
    Edited by: Avi4Ora on Mar 31, 2010 3:55 PM

    Hi,
    When i tried to copy, its copying without any issue. Check whether the Zoom is changed. Try clicking the menu View--> Normal Size.
    Regards,
    Manu.
    If my response or the response of another was helpful or Correct, please mark it accordingly

  • Changing current display to a canvas subclass... still see the last form

    Hello,
    I'm sure most people can answer this in 10 seconds. I am changing the current display from a form to a canvas subclass in a midlet app. I keep seeing the last form displayed even though i assigned the initialized canvas subclass as the current display. Do I need to do something else to make the canvas visible? I pulled this source code right out of a game programming book.
    TestCanvas canvas = new TestCanvas();
    //game is a reference to the midlet
    game.getDisplay().setCurrent(canvas);
    I had the paint method in the canvas paint the back ground black, but I still see the form's image no matter what I do. Anyone know what I am doing wrong here? ... Thanks, Paul

    I figured it out, soory it was really stupid

  • Stacked canvasses changing color when changing subclassed VA colors

    I am using Forms developer 10g and I have a visual attribute STD_CURRENT_RECORD in my object library which is subclassed in all forms in the application.
    This VA is referenced from the 'Current record visual attribute' property (and nowhere else) of all multi record blocks in all forms of the application.
    Through a user preferences form, the user can select his/her preferred background and foreground color for the current record in multi blocks. These selected colors are saved in a user preferences table.
    In a library which is attached to all forms, I have a procedure SET_USER_PREFERENCES which is called from the When-New-Form-Instance of all forms. The latter procedure checks if the STD_CURRENT_RECORD VA is present in the form and if so it changes the backgroud and foreground color of the VA to those colors selected by the user. The VA works fine on the current record in multiblocks but for some reason forms is changing the color of all stacked canvases to white (irrespective of the colors the user might have selected for background or foreground).
    Does anyone have this problem and possibly found or know of a solution to it please?

    You didn't mention your Java or Forms version. It has been my experience that odd behavior like this are usually bugs and are fixed by upgrading the JRE to the current update and patching Forms to the current version. I recommend you upgrade your JRE to 1.6.0_30 and Forms to 10.1.2.3.
    Craig...

  • Overlay Images and Shapes on the same canvas

    The example copde below was taken from: http://math.hws.edu/eck/cs124/javanotes3/source/
    Is it possible to update the code so that images (jpg,gif) can be added as well as shapes?
    Any help with this is much appreciated.
        The ShapeDraw applet lets the user add small colored shapes to
        a drawing area and then drag them around.  The shapes are rectangles,
        ovals, and roundrects.  The user adds a shape to the canvas by
        clicking on a button.  The shape is added at the upper left corner
        of the canvas.  The color of the shape is given by the current
        setting of a pop-up menu.  The user can drag the shapes with the
        mouse.  Ordinarily, the shapes maintain a given back-to-front order.
        However, if the user shift-clicks on a shape, that shape will be
        brought to the front.
        A menu can be popped up on a shape (by right-clicking or performing
        some othe platform-dependent action).  This menu allows the user
        to change the size and color of a shape.  It is also possible to
        delete the shape and to bring it to the front.
        This file defines the applet class plus several other classes used
        by the applet, namely:  ShapeCanvas, Shape, RectShape, OvalShape,
        and RoundRectShape.
        David Eck
        July 28,  1998
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    import java.util.Vector;
    public class ShapeDrawWithMenu extends Applet {
       public void init() { 
            // Set up the applet's GUI.  It consists of a canvas, or drawing area,
            // plus a row of controls below the canvas.  The controls include three
            // buttons which are used to add shapes to the canvas and a Choice menu
            // that is used to select the color used for a shape when it is created.
            // The canvas is set as the "listener" for these controls so that it can
            // respond to the user's actions.  (The pop-up menu is created by the canvas.)
          setBackground(Color.lightGray);
          ShapeCanvas canvas = new ShapeCanvas();  // create the canvas
          Choice colorChoice = new Choice();  // color choice menu
          colorChoice.add("Red");
          colorChoice.add("Green");
          colorChoice.add("Blue");
          colorChoice.add("Cyan");
          colorChoice.add("Magenta");
          colorChoice.add("Yellow");
          colorChoice.add("Black");
          colorChoice.add("White");
          colorChoice.addItemListener(canvas);
          Button rectButton = new Button("Rect");    // buttons for adding shapes
          rectButton.addActionListener(canvas);
          Button ovalButton = new Button("Oval");
          ovalButton.addActionListener(canvas);
          Button roundRectButton = new Button("RoundRect");
          roundRectButton.addActionListener(canvas);
          Panel bottom = new Panel();   // a Panel to hold the control buttons
          bottom.setLayout(new GridLayout(1,4,3,3));
          bottom.add(rectButton);
          bottom.add(ovalButton);
          bottom.add(roundRectButton);
          bottom.add(colorChoice);
          setLayout(new BorderLayout(3,3));
          add("Center",canvas);              // add canvas and controls to the applet
          add("South",bottom);
       public Insets getInsets() {
            // Says how much space to leave between the edges of the applet and the
            // components in the applet.
          return new Insets(3,3,3,3);
    }  // end class ShapeDraw
    class ShapeCanvas extends Canvas implements ActionListener, ItemListener,
                                                MouseListener, MouseMotionListener {
          // This class represents a canvas that can display colored shapes and
          // let the user drag them around.  It uses an off-screen images to
          // make the dragging look as smooth as possible.  A pop-up menu is
          // added to the canvas that can be used to performa certain actions
          // on the shapes;
       Image offScreenCanvas = null;   // off-screen image used for double buffering
       Graphics offScreenGraphics;     // graphics context for drawing to offScreenCanvas
       Vector shapes = new Vector();   // holds a list of the shapes that are displayed on the canvas
       Color currentColor = Color.red; // current color; when a shape is created, this is its color
       ShapeCanvas() {
            // Constructor: set background color to white, set up listeners to respond to mouse actions,
            //              and set up the pop-up menu
          setBackground(Color.white);
          addMouseListener(this);
          addMouseMotionListener(this);
          popup = new PopupMenu();
          popup.add("Red");
          popup.add("Green");
          popup.add("Blue");
          popup.add("Cyan");
          popup.add("Magenta");
          popup.add("Yellow");
          popup.add("Black");
          popup.add("White");
          popup.addSeparator();
          popup.add("Big");
          popup.add("Medium");
          popup.add("Small");
          popup.addSeparator();
          popup.add("Delete");
          popup.add("Bring To Front");
          add(popup);
          popup.addActionListener(this);
       } // end construtor
       synchronized public void paint(Graphics g) {
            // In the paint method, everything is drawn to an off-screen canvas, and then
            // that canvas is copied onto the screen.
          makeOffScreenCanvas();
          g.drawImage(offScreenCanvas,0,0,this);
       public void update(Graphics g) {
            // Update method is called when canvas is to be redrawn.
            // Just call the paint method.
          paint(g);
       void makeOffScreenCanvas() {
             // Erase the off-screen canvas and redraw all the shapes in the list.
             // (First, if canvas has not yet been created, then create it.)
          if (offScreenCanvas == null) {
             offScreenCanvas = createImage(getSize().width,getSize().height);
             offScreenGraphics = offScreenCanvas.getGraphics();
          offScreenGraphics.setColor(getBackground());
          offScreenGraphics.fillRect(0,0,getSize().width,getSize().height);
          int top = shapes.size();
          for (int i = 0; i < top; i++) {
             Shape s = (Shape)shapes.elementAt(i);
             s.draw(offScreenGraphics);
       public void itemStateChanged(ItemEvent evt) {
              // This is called to respond to item events.  Such events
              // can only be sent by the color choice menu,
              // so respond by setting the current color according to
              // the selected item in that menu.
          Choice colorChoice = (Choice)evt.getItemSelectable();
          switch (colorChoice.getSelectedIndex()) {
             case 0: currentColor = Color.red;     break;
             case 1: currentColor = Color.green;   break;
             case 2: currentColor = Color.blue;    break;
             case 3: currentColor = Color.cyan;    break;
             case 4: currentColor = Color.magenta; break;
             case 5: currentColor = Color.yellow;  break;
             case 6: currentColor = Color.black;   break;
             case 7: currentColor = Color.white;   break;
       public void actionPerformed(ActionEvent evt) {
              // Called to respond to action events.  The three shape-adding
              // buttons have been set up to send action events to this canvas.
              // Respond by adding the appropriate shape to the canvas.  This
              // also be a command from a pop-up menu.
          String command = evt.getActionCommand();
          if (command.equals("Rect"))
             addShape(new RectShape());
          else if (command.equals("Oval"))
             addShape(new OvalShape());
          else if (command.equals("RoundRect"))
             addShape(new RoundRectShape());
          else
             doPopupMenuCommand(command);
       synchronized void addShape(Shape shape) {
              // Add the shape to the canvas, and set its size/position and color.
              // The shape is added at the top-left corner, with size 50-by-30.
              // Then redraw the canvas to show the newly added shape.
          shape.setColor(currentColor);
          shape.reshape(3,3,50,30);
          shapes.addElement(shape);
          repaint();
       // ------------ This rest of the class implements dragging and the pop-up menu ---------------------
       PopupMenu popup;
       Shape selectedShape = null;     // This is null unless a menu has been popped up on this shape.
       Shape draggedShape = null;      // This is null unless a shape has been selected for dragging.
       int prevDragX;  // During dragging, these record the x and y coordinates of the
       int prevDragY;  //    previous position of the mouse.
       Shape clickedShape(int x, int y) {
             // Find the frontmost shape at coordinates (x,y); return null if there is none.
          for ( int i = shapes.size() - 1; i >= 0; i-- ) {  // check shapes from front to back
             Shape s = (Shape)shapes.elementAt(i);
             if (s.containsPoint(x,y))
                return s;
          return null;
       void doPopupMenuCommand(String command) {
             // Handle a command from the pop-up menu.
          if (selectedShape == null)  // should be impossible
             return;
          if (command.equals("Red"))
             selectedShape.setColor(Color.red);
          else if (command.equals("Green"))
             selectedShape.setColor(Color.green);
          else if (command.equals("Blue"))
             selectedShape.setColor(Color.blue);
          else if (command.equals("Cyan"))
             selectedShape.setColor(Color.cyan);
          else if (command.equals("Magenta"))
             selectedShape.setColor(Color.magenta);
          else if (command.equals("Yellow"))
             selectedShape.setColor(Color.yellow);
          else if (command.equals("Black"))
             selectedShape.setColor(Color.black);
          else if (command.equals("White"))
             selectedShape.setColor(Color.white);
          else if (command.equals("Big"))
             selectedShape.resize(75,45);
          else if (command.equals("Medium"))
             selectedShape.resize(50,30);
          else if (command.equals("Small"))
             selectedShape.resize(25,15);
          else if (command.equals("Delete"))
             shapes.removeElement(selectedShape);
          else if (command.equals("Bring To Front")) {
             shapes.removeElement(selectedShape);
             shapes.addElement(selectedShape);
          repaint();
       synchronized public void mousePressed(MouseEvent evt) {
             // User has pressed the mouse.  Find the shape that the user has clicked on, if
             // any.  If there is a shape at the position when the mouse was clicked, then
             // start dragging it.  If the user was holding down the shift key, then bring
             // the dragged shape to the front, in front of all the other shapes.
          int x = evt.getX();  // x-coordinate of point where mouse was clicked
          int y = evt.getY();  // y-coordinate of point
          if (evt.isPopupTrigger()) {            // If this is a pop-up menu event that
             selectedShape = clickedShape(x,y);  // occurred over a shape, record which shape
             if (selectedShape != null)          // it is and show the menu.
                popup.show(this,x,y);
          else {
             draggedShape = clickedShape(x,y);
             if (draggedShape != null) {
                prevDragX = x;
                prevDragY = y;
                if (evt.isShiftDown()) {                 // Bring the shape to the front by moving it to
                   shapes.removeElement(draggedShape);  //       the end of the list of shapes.
                   shapes.addElement(draggedShape);
                   repaint();  // repaint canvas to show shape in front of other shapes
       synchronized public void mouseDragged(MouseEvent evt) {
              // User has moved the mouse.  Move the dragged shape by the same amount.
          if (draggedShape != null) {
             int x = evt.getX();
             int y = evt.getY();
             draggedShape.moveBy(x - prevDragX, y - prevDragY);
             prevDragX = x;
             prevDragY = y;
             repaint();      // redraw canvas to show shape in new position
       synchronized public void mouseReleased(MouseEvent evt) {
              // User has released the mouse.  Move the dragged shape, then set
              // shapeBeingDragged to null to indicate that dragging is over.
              // If the shape lies completely outside the canvas, remove it
              // from the list of shapes (since there is no way to ever move
              // it back onscreen).
          int x = evt.getX();
          int y = evt.getY();
          if (draggedShape != null) {
             draggedShape.moveBy(x - prevDragX, y - prevDragY);
             if ( draggedShape.left >= getSize().width || draggedShape.top >= getSize().height ||
                     draggedShape.left + draggedShape.width < 0 ||
                     draggedShape.top + draggedShape.height < 0 ) {  // shape is off-screen
                shapes.removeElement(draggedShape);  // remove shape from list of shapes
             draggedShape = null;
             repaint();
          else if (evt.isPopupTrigger()) {        // If this is a pop-up menu event that
             selectedShape = clickedShape(x,y);   // occurred over a shape, record the
             if (selectedShape != null)           // shape and show the menu.
                popup.show(this,x,y);
       public void mouseEntered(MouseEvent evt) { }   // Other methods required for MouseListener and
       public void mouseExited(MouseEvent evt) { }    //              MouseMotionListener interfaces.
       public void mouseMoved(MouseEvent evt) { }
       public void mouseClicked(MouseEvent evt) { }
    }  // end class ShapeCanvas
    abstract class Shape {
          // A class representing shapes that can be displayed on a ShapeCanvas.
          // The subclasses of this class represent particular types of shapes.
          // When a shape is first constucted, it has height and width zero
          // and a default color of white.
       int left, top;      // Position of top left corner of rectangle that bounds this shape.
       int width, height;  // Size of the bounding rectangle.
       Color color = Color.white;  // Color of this shape.
       void reshape(int left, int top, int width, int height) {
             // Set the position and size of this shape.
          this.left = left;
          this.top = top;
          this.width = width;
          this.height = height;
       void resize(int width,int height) {
             // Set the size without changing the position
          this.width = width;
          this.height = height;
       void moveTo(int x, int y) {
              // Move upper left corner to the point (x,y)
          this.left = x;
          this.top = y;
       void moveBy(int dx, int dy) {
              // Move the shape by dx pixels horizontally and dy pixels veritcally
              // (by changing the position of the top-left corner of the shape).
          left += dx;
          top += dy;
       void setColor(Color color) {
              // Set the color of this shape
          this.color = color;
       boolean containsPoint(int x, int y) {
             // Check whether the shape contains the point (x,y).
             // By default, this just checks whether (x,y) is inside the
             // rectangle that bounds the shape.  This method should be
             // overridden by a subclass if the default behaviour is not
             // appropriate for the subclass.
          if (x >= left && x < left+width && y >= top && y < top+height)
             return true;
          else
             return false;
       abstract void draw(Graphics g); 
             // Draw the shape in the graphics context g.
             // This must be overriden in any concrete subclass.
    }  // end of class Shape
    class RectShape extends Shape {
          // This class represents rectangle shapes.
       void draw(Graphics g) {
          g.setColor(color);
          g.fillRect(left,top,width,height);
          g.setColor(Color.black);
          g.drawRect(left,top,width,height);
    class OvalShape extends Shape {
           // This class represents oval shapes.
       void draw(Graphics g) {
          g.setColor(color);
          g.fillOval(left,top,width,height);
          g.setColor(Color.black);
          g.drawOval(left,top,width,height);
       boolean containsPoint(int x, int y) {
             // Check whether (x,y) is inside this oval, using the
             // mathematical equation of an ellipse.
          double rx = width/2.0;   // horizontal radius of ellipse
          double ry = height/2.0;  // vertical radius of ellipse
          double cx = left + rx;   // x-coord of center of ellipse
          double cy = top + ry;    // y-coord of center of ellipse
          if ( (ry*(x-cx))*(ry*(x-cx)) + (rx*(y-cy))*(rx*(y-cy)) <= rx*rx*ry*ry )
             return true;
          else
            return false;
    class RoundRectShape extends Shape {
           // This class represents rectangle shapes with rounded corners.
           // (Note that it uses the inherited version of the
           // containsPoint(x,y) method, even though that is not perfectly
           // accurate when (x,y) is near one of the corners.)
       void draw(Graphics g) {
          g.setColor(color);
          g.fillRoundRect(left,top,width,height,width/3,height/3);
          g.setColor(Color.black);
          g.drawRoundRect(left,top,width,height,width/3,height/3);
    }

    Manveer-Singh
    Please don't post in old threads that are long dead. When you have a question, please start a topic of your own. Feel free to provide a link to an old thread if relevant.
    I'm locking this 3 year old thread now.
    db
    edit You have earlier been advised not to post in old dead threads.
    [http://forums.sun.com/thread.jspa?threadID=354443]
    Continuing to ignore this advice will render your account liable to be blocked.
    Edited by: Darryl.Burke

  • Problem with IFCMP60, subclassing, property classes and Object Libraries

    I'm looking to write a little batch script that recompiles all my forms. I've got one off the net - Mine is a little more complicated but I'm basing it on
    FOR %%F in (*.fmb) do call ifcmp60 %%F userid=uname/pwd@dbase batch=YES Window_State=Minimize
    Many of my forms have those items shown on the canvas subclassed using a property class. Those property classes are held in an object library (.olb) and subclassed into the form. the .olb is resident in the same directory as the forms.
    When I run my batch script some forms compile okay but some don't. I've figured out that the ones that don't are the ones like the above - and looking at the .err produced, they fail on the subclassed fields.
    e.g.
    Compilation error on procedure PROCESS_MULTI_QUERY:
    PL/SQL ERROR 49 at line 139, column 33
    bad bind variable 'multi_query.input_file'
    there is a block multi_query with a field input_file and this field uses a property_class subclassed from the object library. So ifcmp60 doesn't realise that ":MULTI_QUERY.INPUT_FILE" refers to the block item. However it is just fine with the other items on the canvas that are not subclassed.
    Anyone else encountered this? Can I fix it without breaking all the subclassing?

    False alarm: A colleague had recompiled the OLB under 10g, so Forms 6i didn't recognise it.

  • Cant add() a Canvas into a JPane

    Hello all!
    i having problem to include canvas within a JPanel.
    i subclass the Canvas with an image , i test it and its works :
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    import java.net.*;
    public class testImage extends JFrame{
      public testImage(){
        imageViewer m = new imageViewer();
        m.initImage("http://127.0.0.1/image/samifox.gif");
        getContentPane().add(m);
      public static void main(String[] args) {
        JFrame frame = new testImage();
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              System.exit(0);
          //frame.pack();
          frame.setSize(300,300);
          frame.setVisible(true);
    class imageViewer extends Canvas{
      Image image;
      URL url;
      Toolkit tool;
      public void initImage(String path){
        try{
          url = new URL(path);
        }catch(Exception e){
          System.out.println(e.toString());
        image = Toolkit.getDefaultToolkit().getImage(url);
        setImage(image);
      void setImage(Image image){
        this.image = image ;
        repaint() ;
      public void paint(Graphics g){
        super.paint(g) ;
        try{
           g.drawImage(image,0,0,this) ;
           //g.drawString("ssss",25,25,this);
        } catch (NullPointerException e) {
              System.out.println(e.toString());
    }but i cant include this canvas subclass into a JPane i tried :
    //xxx
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;              //for layout managers
    import java.awt.event.*;        //for action and window events
    import com.borland.jbcl.layout.*;
    public class testPanel extends JFrame{
      myJPane mypanel;
       public testPanel(){
        mypanel=new myJPane();
        getContentPane().add(mypanel);
      public static void main(String[] args) {
        JFrame frame = new testPanel();
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              System.exit(0);
          //frame.pack();
          frame.setSize(300,300);
          frame.setVisible(true);
    class myJPane extends JPanel{
      imageViewer imgViewer;
      public myJPane(){
        imgViewer = new imageViewer();
        imgViewer.initImage("http://127.0.0.1/image/samifox.gif");
        add(imgViewer);
    i add and remove from  JPanel lots of component but when i had the use canvas it seem like i dont understand someting that very basic...
    any kind of help will be appriciated
    Shay

    hi Pual!
    Are you getting error messages? no , i dont get any compiler or run-time error
    Or does the program run and not do what you expect? yes , exectly , you see i extend Canvas and i draw in it an Image. now i have extended JPane , i need to add the extended canvas to JPane, like i said i dont recieve any error but the program doesnt show the canvas on the JPane like i except it.
    the Canvas does show in a JFrame but when i try too add the Canvas to JPanel , i faild.
    i hope its more understandable now!
    thank you
    Shay

  • Oracle 10G Forms and Reports Developer Issue (CANVAS Property)!!!

    Okay guys. I have a form that uses a canvas named as CANVAS4 and another canvas (horizontal toolbar) named HEADER that is the subclass of HEADER and a library called TDAS.
    What happening is, my CANVAS4 color is r240g240b255 and when i try to set the color of HEADER as r240g240b255, it sets the color but don't display this color on screen.
    How i come to know that it sets the color?
    I've used get_canvas_property() to get the background color property of HEADER.
    I almost spent four to five hours but all in vain.
    I want you guys to help me as soon as possible. I'll be very thankful to you.
    And please do it soon.
    Regards...

    CANVAS 4 set to color r240g240b255 and it shows while HEADER when sets to r240g240b255, doesn't set it.
    Both canvases has default color gray12

  • Re: adding canvas to applet

    Hi
    I am trying to add a canvas to an applet. I am successful in doing so. There is a JMenuBar added to the applet. when I click on the file menu The contents are being displayed behind the canvas and as a result I am neither able to see the buttons nor select them. Could some one help me with this.
    Note: Once you compile the code you wouldn't be able to see the contents right away. Click on left top,immidiately below the applet menu. This will repaint the contentpane. This is some thing I am working on.
    applet class
    package aple;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Shape;
    import java.awt.geom.AffineTransform;
    import java.util.ArrayList;
    import javax.swing.JApplet;
    public class NewJApplet extends JApplet{
        public Graphics2D g2;
        AffineTransform atf = new AffineTransform();
        sketch sk = new sketch();   
            @Override
        public void init() {      
            getContentPane().add(sk);
           Gui gui = new Gui();
            // menubar
            this.setJMenuBar(gui.Gui());     
        @Override
    gui class
    package aple;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    public class Gui {
        JMenuBar menuBar;
        JMenu file,edit,insert,view,draw,circle;
        JMenuItem nu,close,saveAs,open,centreandradius,line,rectangle,point,arc;
        public JMenuBar Gui(){
            //Menubar
            menuBar = new JMenuBar();
            //Menus
            file = new JMenu("File");
            menuBar.add(file);
            edit = new JMenu("Edit");
            menuBar.add(edit);
            view = new JMenu("View");
            menuBar.add(view);
            insert = new JMenu("Insert");       
            draw = new JMenu("Draw");
            circle = new JMenu("Circle");
            draw.add(circle);
            insert.add(draw);       
            menuBar.add(insert);
            //MenuItems
            nu = new JMenuItem("New");
            file.add(nu);
            open = new JMenuItem("Open");
            file.add(open);
            saveAs = new JMenuItem("SaveAs");
            file.add(saveAs);
            close = new JMenuItem("Close");
            file.add(close);
            line = new JMenuItem("Line");
            draw.add(line);
            centreandradius = new JMenuItem("Centre and Radius");
            circle.add(centreandradius);
            rectangle = new JMenuItem("Rectangle");
            draw.add(rectangle);
            point = new JMenuItem("Point");
            draw.add(point);
            arc = new JMenuItem("arc");
            draw.add("Arc");
            return(menuBar);
    sketch class
    package aple;
    import java.awt.Canvas;
    import java.awt.Color;
    import java.awt.Graphics;
    public class sketch extends Canvas{
        public void sketch(){
            this.setBackground(Color.green);
        @Override
        public void paint(Graphics g){
         // g.fillRect(50,50, 50, 50); 
    }

    When you were using JPanel, your "setBackground" didn't work because you were overriding its paint(Graphics) method without calling "super.paint(g);". If you don't do this, the panel won't paint its background.
    You should also override "protected void paintComponent(Graphics g)" in any JComponent, such as JPanel, instead of just "paint(Graphics)". (And don't forget to call super.paintComponent(g) FIRST in your subclass's overridden method, if you want the background painted):
    class MyJPanelSubclass extends JPanel {
       protected void paintComponent(Graphics g) {
          super.paintComponent(g); // Paints background and any other stuff normally painted.
          // Do your custom painting here.
    }

Maybe you are looking for