Scrolling a canvas

Hi
I am tring to scroll a canvas
Here is the code
JScrollPane scrollPane = new JScrollPane(ca, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setPreferredSize(new Dimension(500,500));
scrollPane.revalidate();
add(scrollPane, BorderLayout.CENTER);
where ca is the canvas
How do i get the scroll bars to dispaly and move the canvas, presently all is shown is the canvas with blank tracks?
Thanx

yeah it works but i don't want to implement a textArea but a canvas.
The code i have for the canvas is
class Canvas0 extends Canvas{
public Canvas0(){}
int ROOTx = 300;
int ROOTy = 20;
int rootx = 20;
int rooty = 20;
int textx = 275;
int texty = 25;
int KID1x = 250;
int KID1y = 60;
int kid1x = 20;
int kid1y = 20;
int text1x = 225;
int text1y = 65;
int KID2x = 200;
int KID2y = 100;
int kid2x = 20;
int kid2y = 20;
int text2x = 175;
int text2y = 105;
int KID3x = 150;
int KID3y = 140;
int kid3x = 20;
int kid3y = 20;
int text3x = 125;
int text3y = 145;
int LEAFx = 100;
int LEAFy = 180;
int leafx = 20;
int leafy = 20;
int text4x = 75;
int text4y = 185;
     public void paint(Graphics g){
          Font f = new Font("TimesRoman", Font.BOLD, 12);
          String text;
          String text1;
          String text2;
          String text3;
          String leaf;
          g.setFont(f);
          g.drawOval(ROOTx,ROOTy,rootx,rooty);
          g.drawLine(ROOTx+5,ROOTy+5,KID1x+5,KID1y+5);
          text = OViewer.getMain();
          g.drawString(text,textx, texty);
          if(OViewer.getKids1().toString().compareTo("null") != 0){
               System.out.println("111aaaaa");
               g.drawOval(KID1x,KID1y,kid1x,kid1y);
               g.drawLine(KID1x+5,KID1y+5,KID2x+5,KID2y+5);
               KID1x = KID1x + 15;
               KID1y = KID1y + 15;
               text1 = OViewer.getKids1();
               g.drawString(text1,text1x, text1y);
               text1x = text1x+15;
               text1y = text1y+15;
               System.out.println("1111bbbbb");
          while(OViewer.getKids2().toString().compareTo("null") != 0){
               g.drawOval(KID2x,KID2y,kid2x,kid2y);
               g.drawLine(KID2x+5,KID2y+5,KID3x+5,KID3y+5);
               KID2x = KID2x + 15;
               KID2y = KID2y + 15;
               text2 = OViewer.getKids2();
               g.drawString(text2,text2x, text2y);
               text2x = text2x+15;
               text2y = text2y+15;
          while(OViewer.getKids3().toString().compareTo("null") != 0){
               g.drawOval(KID3x,KID3y,kid3x,kid3y);
               g.drawLine(KID3x+5,KID3y+5,LEAFx+5,LEAFy+5);
               KID3x = KID3x + 15;
               KID3y = KID3y + 15;
               text3 = OViewer.getKids3();
               g.drawString(text3,text3x, text3y);
               text3x = text3x+15;
               text3y = text3y+15;
          while(OViewer.getLeaf().toString().compareTo("null") != 0){
               g.drawOval(LEAFx,LEAFy,leafx,leafy);
               LEAFx = LEAFx + 15;
               LEAFy = LEAFy + 15;
               leaf = OViewer.getLeaf();
               g.drawString(leaf,text4x, text4y);
               text4x = text4x+15;
               text4y = text4y+15;
}//end of Canvas0
Is this the problem with the scroll, will i have to use a swing draw facility instead of a java class?

Similar Messages

  • Scrolling Tab Canvas

    Hi,
    how do we achieve horizontal scroll in a tab canvas ? It doesnt allow to place a stacked canvas on a Tab canvas. Do we have to put a content canvas on top of a tab and then place stacked on top of content ?
    Regards,
    Suresh

    its simple
    - Create Stack canvas simple separately without any canvas with all necessary items buttons etc etc SET its X and Y position according to the visibility with the Tab page
    - on tab page there should not be any item
    - Write on WHEN-TAB-PAGE-CHANGED trigger at form level call that stack canvas
    Note: i dont remember exact system variable name right now :D :system.new_tab_page check online help
      if :system.new_tab_page = 'MYPAGE' then
          go_block('Myblock');
          hide_all_views; --- custom procedure to hide all other stack canvases
          show_view('MyStack');
    end if;- For ease u can set the same name of the stack canvas as tab page and block name if possible then the code would be simple
       go_block(:system.new_tab_page);
       hide_all_views;
       show_view(:system.new_tab_page);
    if responses are helpful or correct plz mark it
    Baig,
    http://baigsorcl.blogspot.com

  • Need help scrolling a canvas (verticalScrollPosition)

    I've now spent about six hours trying to get this to work and just can't seem to get it to work.
    I want to implement a "scrolling credits" component like at the end of a Hollywood movie.
    I'm using a canvas component and trying to use the verticalScrollPosition to tell it to scroll (1 unit every 100 ms).  However, it never moves.  I can't seem to ever get it off 0,0.   The scroll bar is always at the top!
    The canvas will be 1000 units high (or so) with period text "Starring Bob Smith", "Directed by Willie Gordon," etc.  But I only want 300 units (vertical) to show.
    Can someone please present a very simple solution where a canvas inside of a canvas component is scrolled up? What property do I set to have it scroll within the clipped region?
    Pete

    Ihavn't worked too much with the scrollBar, but I think I have an idea of what you want, though I'm not very sure if it might work.
    Can you try to add a Move effect to the panel containement, and at each effectEnd, set the verticalScrollBarPosition at currentPosition+1 unit (I understood correct, and this is what you want?)
    Also, at each effectEnd event, you could restart the move effect, and so on, until the position of the verticalscrollBar is at the end.
    Stephanie

  • Scroll canvas?

    Is there a way in FCE 4 to scroll the canvas? When I'm trying to adjust motion, it would be nice to be able to zoom in and scroll around a bit to make the keyframes and handles bigger, but paths are often off the visible screen requiring me to set the zoom factor to 25% or 50%. Making the canvas bigger doesn't help since it scales everything, it doesn't change the area of what is displayed.
    thanks

    The scrollbar can be placed on a separate stacked canvas, the same dimensions as the scrollbar. Then the canvas can be shown or hidden.

  • Alternative to Double-Buffered Canvas

    I am working on a program in which I use a double-buffered Canvas inside a JScrollPane. The problem is that the Canvas draws over the scrollbars. I have tried extending JComponent, JPanel, JApplet, and Component instead of Canvas, and none of them are double buffered. Here is the code I used to debug this problem:
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class Test implements  Runnable
         JFrame f;
         JScrollPane scroller;
         JPanel panel;
         TestCanvas canvas;
         Thread runner;
         BufferStrategy strategy;
         public static void main (String[] args) {
              Test app = new Test();
              app.init();
         public void init() {
              f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              panel = new JPanel();
              canvas = new TestCanvas();
              panel.add(canvas);
              scroller = new JScrollPane(panel);
              scroller.setWheelScrollingEnabled(true);
              f.getContentPane().add(scroller);
              f.pack();
              f.setSize(300,300);
              f.setVisible(true);
              canvas.createBufferStrategy(2);
              strategy = canvas.getBufferStrategy();
              runner = new Thread(this);
              runner.run();
         public void run() {
              int x = 0;
              while(x != 65536) {
                   Graphics2D g = (Graphics2D)strategy.getDrawGraphics().create();
                   g.setColor(new Color(x%256,0,0));
                   g.fill(new Ellipse2D.Double(0,0,600,600));
                   strategy.show();
                   x++;
    }Any suggestions?

    The main culprit is that you are mixing AWT components with Swing ones.
    In addition, your are doing so many of useless things and wrong things in your code.
    Swing components are defaulted for using double-buffering.
    See: http://java.sun.com/products/jfc/tsc/articles/painting/index.html
    Try and study this code.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class Fox1229{
      JFrame f;
      JScrollPane scroller;
      TestCanvas canvas;
      int x;
      Timer t;
      public static void main (String[] args) {
        Fox1229 app = new Fox1229();
        app.init();
      public void init() {
        x = 0;
        f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        canvas = new TestCanvas();
        scroller = new JScrollPane(canvas);
        scroller.setWheelScrollingEnabled(true);
        f.getContentPane().add(scroller, BorderLayout.CENTER);
        f.setSize(300, 300);
        f.setVisible(true);
        t = new Timer(50, new ActionListener(){
          public void actionPerformed(ActionEvent e){
            canvas.setOc(new Color(x % 256, 0, 0));
            canvas.repaint();
            if (++x == 1024){
              t.stop();
        t.start();
    class TestCanvas extends JPanel{
      Color oc;
      public TestCanvas (){
        oc = new Color(0, 0, 0);
      public void setOc(Color c){
        oc = c;
      public Dimension getPreferredSize(){
        return new Dimension(600, 600);
      public void paintComponent(Graphics g){
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D)g;
        g2d.setColor(Color.blue);
        g2d.fill(new Rectangle(0, 0, 600, 600));
        g2d.setColor(oc);
        g2d.fill(new Ellipse2D.Double(0, 0, 600, 600));
    }

  • Is it possible to add the Gauge to Canvas?

    Hi All!
    Does anybody know if it is possible to add Gauge to Canvas?
    Thanks so much in advance. Any help would be appreciated.

    Yes, for sure it is easy. I simply wondering maybe something standard exist. :-)
    Btw, do you know any way except own implementation of the scrolling for Canvas?
    Thanks.

  • Scroll bar problem

    How can i attach scrollbar to my tab canvas?

    rupearlkaushal wrote:
    How can i attach scrollbar to my tab canvas?Do you show any block in the tab canvas ?
    If yes, go to the block property. Under Scrollbar section, set the following property
    Show scroll Bar: Yes
    Scroll bar canvas: your_tab_canvas
    scroll bar tab page: Tab_page_name
    scroll bar width and lengthHope this helps...
    If someone's response is helpful or correct, please mark it accordingly.

  • Scroll bar not working..help me.

    i have a form with vertical scroll bar on it..in browsing to some other records using the mouse it does not sroll up or down, yet if I use the down key or up-key (keyboard) it works. What is the possible way to make the vertical scroll bar works. your immediate response will be highly appreciated.

    In Forms 6.0 using Frames the toolbar properties is in the frame properties.
    In Forms 4.5 or 6.0 without frames the toolbar's properties is in the data blocks properties.
    The scroll bar canvas must be in the same canvas that the data block.
    Martin Medina

  • Scroll bar in 10 g

    How to attach scroll bar to my form in oracle forms 10g.

    hi,
    i read it.
    and i set my Window's Show Vertical Scrollbar property to Yes.
    Though it is not being displayed.
    When i Set my Block's Show Scroll bar Property to Yes and Scroll Bar Canvas Property to CANVAS6, Scrollbar is displayed byt it is not activated.not clear, but if you are trying to scroll the canvas and see the items then you have to set the canvas's horizontal scroll bar to 'yes'.

  • Mouse wheel scroll question

    Hello to all, i want to make the following question:
    I have a canvas which has a vertical scroll bar, inside this
    canvas there is a textarea control which has a vertical scroll bar
    too. That i want to make is:
    when the user put the mouse cursor on to the textarea and use
    the mouse wheel i want to make scrolling the canvas and not the
    textarea.
    any help will be appreciated.
    thanks in advance

    Thanks for the replies. The solution to my question is this:
    package
    import flash.events.MouseEvent;
    import mx.controls.TextArea;
    public class newTextArea extends TextArea
    public function newTextArea()
    super();
    override protected function createChildren():void
    super.createChildren();
    textField.mouseWheelEnabled = false;
    private var scrollAnterior:Number=-1;
    private var direccionScroll:Number=0;
    override protected function
    mouseWheelHandler(event:MouseEvent):void
    var dirScroll:int = event.delta <= 0 ? 1 : -1;
    if (verticalScrollPosition==scrollAnterior &&
    direccionScroll==dirScroll)
    return;
    scrollAnterior=verticalScrollPosition;
    direccionScroll=dirScroll;
    super.mouseWheelHandler(event);
    it works fine, but now i want to make the same with the
    canvas, but seems is not possible override mouseWheelHandler event
    in it. Any help or suggestion ?
    Thanks in advance

  • Displaying PathGeometry into canvas take too long time

    Hi every one,
    I am working on spatial data with an application WPF and I would like to draw a map from data queries.
    I got my data and I am able to draw them on a canvas with scroll bar and zoom.
    My problem is when I want to zoom or scroll the canvas take a long time before draw the map.
    The big problem is there :
    Dim poly As New Polygon
    poly.Stroke = Brushes.Red
    poly.Fill = Brushes.Orange
    poly.StrokeThickness = 5
    Dim colPoint As New PointCollection
    For i = 1 To geo.STNumPoints
    Dim ls As New LineSegment()
    colPoint.Add(New Point(geo.STPointN(i).STX.Value - extentA, geo.STPointN(i).STY.Value - extentB))
    Next
    colPoint.Add(New Point(geo.STPointN(1).STX.Value - extentA, geo.STPointN(1).STY.Value - extentB))
    poly.Points = colPoint
    masterCanvas.Children.Add(poly)
    so the canvas is "masterCanvas" and i add each Polygon one by one. I would like if it is possible to gather all polygon into one "image" and then when it will refresh the canvas it will draw only one thing. 
    Regards.

    Hi,
    I found that you have posted it in the forum Acamar suggested.
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/e2d50b4e-0d76-4a3c-b229-521b648b54b3/displaying-pathgeometry-into-canvas-take-too-long-time?forum=wpf#e2d50b4e-0d76-4a3c-b229-521b648b54b3
    Please just focus on that thread, and you could mark if any reply which is helpful as answer.
    Thanks for your understanding.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Stacked canvas not visible in Content view???

    I am following Oracle Forms Interactive Workbook and have downloaded a solution which involves implementing a scrolling stacked canvas. When looking at the solution I can see the scrolling stacked canvas items in the layout editor when the content canvas is selected. But when i look at MY form in the layout editor and do the same the only way i can see the stacked canvas items is by choosing STACKED in the object viewer.
    So how do i view the content canvas with the stacked canvas items/frame together.
    Presently when i run the form I see both no problem but the placement of the stacked canvas items is askew so i need to see both together in editior mode.
    Thanks in anticipation
    Fergus

    Hi Frank,
    Many thanks for that and I should have known but would have chased my tail for ages. Just one thing how do you subsequently deselect the stacked view. When I go to "View" --> "Stacked Views" and select the view to show it shows, great, but how on earth do i deselect it? I have tried everything.
    Regards
    Fergus

  • Forms 6i scroll bar

    This is a form running in Forms 6i and Windows 2000.
    I have a block on a Tabbed Canvas. I want to activate the scroll bar on it.On the Block property,
    I set Show Scroll Bar as Yes
    Scroll Bar Canvas - The Tab Canvas Name
    Scroll Bar Tab Page - The Tab Page name
    But in Runtime, the Scroll show , but they are not active. The Window Canvas is active though(because there were some items in the page which went beyond the screen). I resized the window to a smaller size and the Window Scroll bars disappeared - which is what it should do. But I wonder why the Block scroll bars never get activated...
    Even when I set I set the block scroll bar property to No, the scroll bars on the block are visible thought not active...
    Anybody have any clue why this is happening...
    Thanks.
    Aruna
    null

    Hi,
    There are two kinds of scrollbars. The one you are talking about belongs to the block. This is used to navigate between records in the block. The other scrollbar belongs to the "window" object. Unfortunately that scrollbar will become active only if you have a canvas of type "content". If you have just a tabbed canvas the scrollbar is not active. You can try the following solution suggested by Oracle on their Metalink site
    ===========================================
    Doc ID: Note:1071311.6
    Subject: How to place scrollbars on a tabbed canvas in Forms
    Type: PROBLEM
    Status: REVIEWED
    Content Type: TEXT/PLAIN
    Creation Date: 25-MAY-1999
    Last Revision Date: 08-JAN-2001
    <Note to Author: DO NOT DELETE the following Disclaimer>
    This article is being delivered in Draft form and may contain
    errors. Please use the MetaLink "Feedback" button to advise
    Oracle of any issues related to this article.
    Problem Description
    ===================
    How do you place scrollbars on a tabbed canvas in forms?
    Solution Description
    ====================
    First create a content canvas. Then create a tabbed canvas to
    place on top of the content canvas. These two canvases should
    be the same size.
    Place your block/items on the tabbed canvas. Then go to property
    sheet for the window and set the primary canvas to the content
    canvas and set your scrollbars on this canvas. Make sure the window
    is smaller than the canvases and you will see the scrollbars.
    ===========================================
    The only problem with this approach is that even when you have a big screen or high screen resolution,the window will come up in small size with the scrollbar. If you have allowed the end user to adjust the size of the screen then they can increase the window size and make the scrollbar to go away. For people with smaller screens or lower resolutions the scrollbar will come in handy. If you have any further questions let me know.
    Prahalad

  • Scroll a window programmatically

    This is what I want to do. I have a large image that is
    larger than it's canvas container. When I click and drag, I want to
    move the image around kinda like Google Maps. I know I can
    accomplish this task by scrolling the canvas when I receive a mouse
    move. I can't figure out how to scroll the canvas in code.
    If there is a better way of doing this, let me know.

    assuming you are using actionscript rather than flex xml to
    create this project, you should look into the 'scrollRect' property
    of the DisplayObject. I haven't used this myself, but its purpose
    matches your needs... Otherwise it can be done with
    masking...

  • Make a tooltip scroll with the component?

    Hi,
    I have a Canvas with many input fields so that Canvas is scrolling vertically. i have a default flex validation tooltips for the input fields, when i'm scrolling the canvas Tooltips are not scrolling.
    Is there any solution in Flex 3 for this problem?
    Thanks in advance,
    Sreedhar

    From you current code, your tooltip message is same for all the textinput. so but obviously , it will show you the same tooltip which
    indicates statitionary tooltip...
    Solution is created dynamic tooltip for each textbox for example
    message = "I have a tooltip!" + TextInput(e.currentTarget).id ;
    I mean to say any dynamic text which keep on changing with different textbox.
    Hope you got my point!!!

Maybe you are looking for

  • HT4623 I keep trying to update my iphone with 10.6.3 but what I do is not working and I'm a dork in this system.

    My "device" no longer appears when I go into Itunes.  It says I need to update to 10.6.3 but when I go under help and ask for updates.  It shows me the update and I press to download and nothing happens.

  • Advice on upgrading to 10.5, & windows compatibility

    I am just getting used to my iMac, and my problem is I'm going Virtual PA home-based and need advice on what software to use to be compatible to all computer users, (etc windows XP, 98, Vista) and also on voice digital transcription, sorry for being

  • How to run the VI developed in labVIEW 2011 in its previous versions

    Hi all, I am currently using LabVIEW 2011 in my home PC. But, all my school computers are installed with LabVIEW 2010 and 2010 SP1. How to run the VI developed in LabVIEW 2011 in its previous versions? Is there any conveter for that? Regards Prasanth

  • Empty Tables using Softwise SAP Connector

    All, I am new to SAP but am a very experienced .NET developer.  My client wants to build a ASP.NET 2.0 web portal that integrates directly into SAP, but of course the SAP.NET Connector doesn't work with VS2005.  I did find, on this forum, a product b

  • Partitioning suggestion?

    I am working on Oracle 11gR2 2 node RAC(OLAP database) in Linux. I have a huge table (estimated to be around 300G) which I need to partition. Still on the designing phase so the table doesn't exist. The reporting queries will be looking at data for a