Using a Canvas in a Panel

Im doing a programming project for uni, and I need to know how to use the Graphics class, even although we have never covered it. The task is to create a game of hangman, and I am fine with every aspect of the program except when it comes to showing the actual hangman display. This figure must make use of the Graphics class (problem 1- ive no material on how to use it), and be inside a panel (which is in turn inside another panel). I was told today that I would need to create a Canvas in the panel I want to use for the Graphic, then place the graphic on the canvas (problem 2- same as problem 1).
Question is: how do I do ANY of this?
I would be really thankful for any help, because its due in pretty soon. Thanks.

I wrote this game a year ago, it uses 2 gifs for the gallow and the hangman, if you like this 2 gif i can email them to you, or you can change it to plain graphics .
import java.awt.*;
import java.awt.event.*;
public class HangA extends Frame implements ActionListener
     Label      l1 = new Label();
     String     theX;
     char[]     theC;
     int        cntT;
     TheGallows theG;
     ATextField af = new ATextField(12);
public HangA() 
     addWindowListener(new WindowAdapter()
    {     public void windowClosing(WindowEvent ev)
          {     dispose();
               System.exit(0);}});
     setBounds(10,10,650,450);
     setBackground(new Color(206,206,206));
     setLayout(null);
     add(l1);
     theG = new TheGallows();
     add(theG);
     showAbc();     
     getWord();
     showl1();
     setVisible(true);
public void getWord()
     theX = "encapsulate";
     theX = "cap";
     theC = new char[theX.length()];
     for (int j = 0; j < theX.length(); j++) theC[j] = '.';
     theX = theX.toUpperCase();
     cntT = 0;
public void showl1()
     l1.setBounds(30,70,200,50);
     l1.setBackground(Color.pink);
     l1.setForeground(Color.black);
     l1.setText(new String(theC));
     l1.setFont(new Font("",0,20));
public void showAbc()
     String s[] =
     {"A","B","C","D","E","F","G","H","I","J","K","L","M",
      "N","O","P","Q","R","S","T","U","V","W","X","Y","Z"
     for (int j=0; j < s.length; j ++)
          Button jb = new Button(s[j]);
          jb.setFont(new Font("",1,16));
          jb.setBounds(j*24+10,30,22,22);
          jb.setName(s[j]);
          jb.addActionListener(this);
          add(jb);
public void newAbc()
     for (int i = 0; i < getComponentCount(); i++)
          Component jc = (Component)getComponent(i);
          jc.setEnabled(true);
     getWord(); 
     showl1();
     theG.clear();
public void actionPerformed(ActionEvent be)
     cntT++;
     boolean hit = false;
     char c = be.getActionCommand().charAt(0);
     for (int j=0; j < theX.length(); j++)
          if (theX.charAt(j) == c)
               theC[j] = c;
               hit = true;
     if (hit) showl1();
          else theG.hangm();
     String s = be.getActionCommand();
     for (int i = 0; i < getComponentCount(); i++)
          Component jc = (Component)getComponent(i);
          if (jc.getName() != null &&  jc.getName().equals(s))
               jc.setEnabled(false);
     if (theG.cntM > 9)
          new dialog(this,(""+cntT+ "    try's  Very Bad"));
          newAbc();
     if (theX.equals(new String(theC)))
          new dialog(this,(""+cntT+ "    try's  Very Nice"));
          newAbc();
public class TheGallows extends Canvas
     Image          gall;
     Image          hang;
     int            cntM;
public TheGallows()
     super();
     gall = getToolkit().getImage("gallows.gif");
     hang = getToolkit().getImage("gallowh.gif");
     MediaTracker tracker = new MediaTracker(this);
     tracker.addImage(gall,0);
     tracker.addImage(hang,0);
     try   {tracker.waitForID(0);}
     catch (InterruptedException e){}
     clear();
     setBounds(300,70,gall.getWidth(null),gall.getHeight(null));
public void clear()
     cntM = 0;
     repaint();
public void hangm()
     cntM = cntM + 1;
     repaint();
public void paint(Graphics g)
     if (cntM < 1) super.paint(g);
     int h = gall.getHeight(null) / 10 * cntM;
     int w = gall.getWidth(null);
     g.drawImage(gall,0,0,w,h,0,0,w,h,null);
     if (cntM > 9) g.drawImage(hang,0,0,null);
public void update(Graphics g)
     paint(g);
public class dialog extends Dialog
public dialog(Frame frame, String s)
     super(frame,"",true);
     Label l = new Label(" "+s);
     l.setFont(new Font("",0,16));
     add(l);
     pack();
     setLocation(200,200);
     this.addWindowListener(new WindowAdapter()
    {     public void windowClosing(WindowEvent ev)
               setVisible(false);
     setVisible(true);
public static void main (String[] args)
     new HangA();
Noah
unformatted
import java.awt.*;
import java.awt.event.*;
public class HangA extends Frame implements ActionListener
     Label l1 = new Label();
     String theX;
     char[] theC;
     int cntT;
     TheGallows theG;
     ATextField af = new ATextField(12);
public HangA()
     addWindowListener(new WindowAdapter()
{     public void windowClosing(WindowEvent ev)
          {     dispose();
               System.exit(0);}});
     setBounds(10,10,650,450);
     setBackground(new Color(206,206,206));
     setLayout(null);
     add(l1);
     theG = new TheGallows();
     add(theG);
     showAbc();     
     getWord();
     showl1();
     setVisible(true);
public void getWord()
     theX = "encapsulate";
     theX = "cap";
     theC = new char[theX.length()];
     for (int j = 0; j < theX.length(); j++) theC[j] = '.';
     theX = theX.toUpperCase();
     cntT = 0;
public void showl1()
     l1.setBounds(30,70,200,50);
     l1.setBackground(Color.pink);
     l1.setForeground(Color.black);
     l1.setText(new String(theC));
     l1.setFont(new Font("",0,20));
public void showAbc()
     String s[] =
     {"A","B","C","D","E","F","G","H","I","J","K","L","M",
     "N","O","P","Q","R","S","T","U","V","W","X","Y","Z"
     for (int j=0; j < s.length; j ++)
          Button jb = new Button(s[j]);
          jb.setFont(new Font("",1,16));
          jb.setBounds(j*24+10,30,22,22);
          jb.setName(s[j]);
          jb.addActionListener(this);
          add(jb);
public void newAbc()
     for (int i = 0; i < getComponentCount(); i++)
          Component jc = (Component)getComponent(i);
          jc.setEnabled(true);
     getWord();
     showl1();
     theG.clear();
public void actionPerformed(ActionEvent be)
     cntT++;
     boolean hit = false;
     char c = be.getActionCommand().charAt(0);
     for (int j=0; j < theX.length(); j++)
          if (theX.charAt(j) == c)
               theC[j] = c;
               hit = true;
     if (hit) showl1();
          else theG.hangm();
     String s = be.getActionCommand();
     for (int i = 0; i < getComponentCount(); i++)
          Component jc = (Component)getComponent(i);
          if (jc.getName() != null && jc.getName().equals(s))
               jc.setEnabled(false);
     if (theG.cntM > 9)
          new dialog(this,(""+cntT+ " try's Very Bad"));
          newAbc();
     if (theX.equals(new String(theC)))
          new dialog(this,(""+cntT+ " try's Very Nice"));
          newAbc();
public class TheGallows extends Canvas
     Image gall;
     Image hang;
     int cntM;
public TheGallows()
     super();
     gall = getToolkit().getImage("gallows.gif");
     hang = getToolkit().getImage("gallowh.gif");
     MediaTracker tracker = new MediaTracker(this);
     tracker.addImage(gall,0);
     tracker.addImage(hang,0);
     try {tracker.waitForID(0);}
     catch (InterruptedException e){}
     clear();
     setBounds(300,70,gall.getWidth(null),gall.getHeight(null));
public void clear()
     cntM = 0;
     repaint();
public void hangm()
     cntM = cntM + 1;
     repaint();
public void paint(Graphics g)
     if (cntM < 1) super.paint(g);
     int h = gall.getHeight(null) / 10 * cntM;
     int w = gall.getWidth(null);
     g.drawImage(gall,0,0,w,h,0,0,w,h,null);
     if (cntM > 9) g.drawImage(hang,0,0,null);
public void update(Graphics g)
     paint(g);
public class dialog extends Dialog
public dialog(Frame frame, String s)
     super(frame,"",true);
     Label l = new Label(" "+s);
     l.setFont(new Font("",0,16));
     add(l);
     pack();
     setLocation(200,200);
     this.addWindowListener(new WindowAdapter()
{     public void windowClosing(WindowEvent ev)
               setVisible(false);
     setVisible(true);
public static void main (String[] args)
     new HangA();

Similar Messages

  • How can I use the button in one panel to control the other panel's appearing and disappearing?

    How can I use the button in one panel to control the other panel's
    appearing and disappearing? What I want is when I push the button on
    one button . another panel appears to display something and when I
    push it again, that the second panel disappears.

    > How can I use the button in one panel to control the other panel's
    > appearing and disappearing? What I want is when I push the button on
    > one button . another panel appears to display something and when I
    > push it again, that the second panel disappears.
    >
    You want to use a combination of three features, a button on the panel,
    code to notice value changes using either polling in a state machine of
    some sort or an event structure, and a VI Server property node to set
    the Visible property of the VI being opened and closed.
    The button exists on the controlling panel. The code to notice value
    changes is probably on the controlling panel's diagram, and this diagram
    sets the Visible property node of a VI class property node to FALSE or
    TRUE to show or
    hide the panel. To get the VI reference to wire to the
    property node, you probably want to use the Open VI Reference node with
    the VI name.
    Greg McKaskle

  • HT204053 Enter the Apple ID you want to use for iCloud in Control Panel Network Internet iCloud.  Enter the Apple ID you want to use for store purchases (including iTunes in the Cloud and iTunes Match) in iTunes iTunes Store.

    Enter the Apple ID you want to use for iCloud in Control Panel > Network > Internet > iCloud. 
    Enter the Apple ID you want to use for store purchases (including iTunes in the Cloud and iTunes Match) in iTunes > iTunes Store.

    Welcome to the Apple community.
    iTunes and iCloud and different accounts, you will need to delete both accounts from your device before adding the new details in their place.
    For iCloud go to settings > iCloud, scroll down and hit the delete button. You can then sign back in using your correct details. For iTunes go to settings >store, tap your account ID and then sign out, you can then sign back in using your correct Apple ID.

  • How to  show additional items in the same window using stacked canvas

    How to show additional items in the same window using stacked canvas.
    My content canvas has 14 items, and I have to include more.
    I want to know how I can use a stacked canvas to show these additional items in the same window, so that I can scroll through horzontally , as if all the items are on one canvas.

    Well, I intially navigate into my content canvas. At this stage the stacked canvas is not visible, then how should I navigate to an item on the stacked canvas to make it visible?

  • Parallel use remote control and touch panel.

    Hi.
    Cisco TelePresence SX20 with firmware TC7.1.4.908e4a9 and was synchronized with touch panel. Can I use remote control when touch panel is enabled. Now remote control is locked.
    Thank's.    

    Hi
    No. When a codec is paired with a Touch controller it is not possible to use the remote control.
    You question number 677 in link bellow
    http://www.cisco.com/c/dam/en/us/td/docs/telepresence/endpoint/articles_doc/telepresence_endpoints_knowledge_base_articles.pdf
    br Oleksandr

  • Using a canvas as an itemrenderer - how to access the datafield?

    Yes... another ItemRenderer related question...
    So I have this advancedDataGrid of which I dynamically
    generate the columns in actionscript. Each of these columns get
    their own datafield.
    This code works well, since all the data displays nicely
    where I want it to be.
    However, in the columns there are numbers from like 0 to 10,
    these are put there by the default itemrenderer by using the
    datafield. Instead of just displaying these numbers, I'd like to
    use a canvas as an itemrenderer to draw something in the box based
    on the value of the number. So all I need to access in my Canvas is
    the value that is parsed by the datafield.
    I thought to do so by overriding public function set
    data(value:Object):void
    But what does value contain? I tried doing something with it
    but I keep getting errors. Does value just contain the entire
    dataProvider? Or is there a way to acces just the number that would
    be put on that position in the grid if I wouldn't be using a custom
    itemrenderer at all?
    I've searched tons of blogs but haven't found the exact
    answer to my question yet.
    Many thanks in advance.

    "Lvw2000" <[email protected]> wrote in
    message
    news:gnucks$8kh$[email protected]..
    > Yes... another ItemRenderer related question...
    >
    > So I have this advancedDataGrid of which I dynamically
    generate the
    > columns in
    > actionscript. Each of these columns get their own
    datafield.
    >
    > This code works well, since all the data displays nicely
    where I want it
    > to be.
    >
    > However, in the columns there are numbers from like 0 to
    10, these are put
    > there by the default itemrenderer by using the
    datafield. Instead of just
    > displaying these numbers, I'd like to use a canvas as an
    itemrenderer to
    > draw
    > something in the box based on the value of the number.
    So all I need to
    > access
    > in my Canvas is the value that is parsed by the
    datafield.
    >
    > I thought to do so by overriding public function set
    > data(value:Object):void
    >
    > But what does value contain?
    It contains the information needed for the entire row. Just
    put a break
    point in the code in your override function and then run the
    application in
    debug mode. Use the variables window to inspect the value.
    > I tried doing something with it but I keep
    > getting errors.
    Are the errors related to the value or are they related to
    something else,
    such as trying to set properties on subcomponents that have
    not been
    instatiated yet.
    > Does value just contain the entire dataProvider? Or is
    there a
    > way to acces just the number that would be put on that
    position in the
    > grid if
    > I wouldn't be using a custom itemrenderer at all?
    Look at implementing IDropInListItemRenderer and then look at
    listData.label.
    HTH;
    Amy

  • [svn:fx-trunk] 5019: ASDoc updates to indicate that some Halo containers do not work with the Spark equiv (ControlBar does not work with Spark Panel/ AppControlBar does not work with Spark Application), and indicate that Canvas, Box, Tile, Panel have Spa

    Revision: 5019
    Author: [email protected]
    Date: 2009-02-19 13:17:21 -0800 (Thu, 19 Feb 2009)
    Log Message:
    ASDoc updates to indicate that some Halo containers do not work with the Spark equiv (ControlBar does not work with Spark Panel/AppControlBar does not work with Spark Application), and indicate that Canvas, Box, Tile, Panel have Spark equivs
    QE Notes: None
    Doc Notes: None
    Bugs: -
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Accordion.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/ApplicationControlBar.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Box.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Canvas.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/ControlBar.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/HBox.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Panel.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/TabNavigator.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/Tile.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/VBox.as
    flex/sdk/trunk/frameworks/projects/framework/src/mx/containers/ViewStack.as

    Hi DST
    This is a great effort and gesture. thank you on behalf of all the newbies.
    PJ

  • I wanted to send some photos out but was told I need to create a new profile, use mail icon in control panel no icon there how do I get it done?

    I want to send some photos from Firefox, when I tried it said I need to create a new profile, use mail icon in control panel. I went to control panel and do not know what to do.'''bold text'''

    As all of the msuic came from your computer in the first place it should still be there.  Is it not?
    EVERYTHING on your ipod should also be on your computer and should be included in your regular backup copy of your computer.
    Make sure that everything is on your computer.  You can transfer itunes purchases from the ipod.  Without syncing:  File>Transfer Purchases.
    When everything is on your computer, then it can be synced back to the ipod after updating.

  • How to use the canvas element?

    hi guys,can anyone help on how to use the mx:canvas on the flex mobile project cause they only allow spark components to be used?just want to have a signaturepad using the canvas element..please guys..:(

    Hi All,
    I have  been  able  to  get  the  value  of  a container  element by  using  the  macro  'swc_get_element'   .I  have  used  it  in  the  method  of  my  task   and  saved  the  value  in  a  z-table. For  this  I  have  set  the  'Export' property of that  particular container elemnt .Now  my  problem  is  I  want  a  second  container  element  to  be  stored in  the  database , I  have  set  its  'Export'  property ,  but  inspite  of  that  it  is  not  visible  in  the  task  container.  As  a  result  I  am  not  able  to  access  it  from  inside  my  method  and  unable  to  save  it  in  the  z-table.  So  please  give  me  some  solution.
    Thanks  &  Regards ,
    Samrat Dutta.

  • Using a canvas for item renderer

    I have an array collection of objects. The class has a
    function getDisplayObject which returns a canvas with all of the
    components I need in it. I'd like to use that canvas directly as a
    custom renderer for a combo box. How can I set the returned canvas
    as the item renderer? I've made custom renderers, but not with a
    canvas itself. I think I need to call getDisplayObject inside of
    the item renderer for each object, but am not sure how. Thanks.
    (Below is what I've tried, but this only adds the first one out of
    an array of 5... hmm...)

    Hi Usernnnnnn,
    I know an applciation that's using such kind of tree.
    It's published in the Oracle magazine, may 2006. And is named: Build a menu framework. You can dowload the application:
    http://oracle.com/technology/oramag/oracle/06-may/o36apex.zip
    The menu looks like you have described.
    Leo

  • How to use stack canvas in tab canvas in oracle forms

    hi all,
    how to use stack canvas in tab canvas in oracle forms. please if any one help out in this.

    Hi
    u can simply create a button in ur tab canvas in this button pls write the following as an example...
    SHOW_VIEW('STACKED_CANVAS');
    GO_ITEM ('SAL'); -- Pls note this item should be navigable and visible in ur stacked canvas form
    HIDE_VIEW('TAB_CANVAS');In order to return back to ur tab_canvas pls create a button in this button pls write the following...
    HIDE_VIEW('STACKED_CANVAS');
    SHOW_VIEW('TAB_CANVAS');
    GO_BLOCK('EMP');
    GO_ITEM ('EMPNO'); -- Pls note this item should be navigable and visible in ur stacked canvas form
    Hope this helps...
    Regards,
    Abdetu...

  • Continuing from using a canvas in tab item

    I asked about inserting a canvas into a tab item and ws given an answer which helped sort the problem , howvere i have hit another problem , the code is
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    namespace WPFDynamicTab
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
            private List<TabItem> _tabItems;
            private TabItem _tabAdd;
            private Canvas canvas1;
            public MainWindow()
               try
                    InitializeComponent();
                    // initialize tabItem array
                    _tabItems = new List<TabItem>();
                    // add a tabItem with + in header
                    _tabAdd = new TabItem();
                     canvas1= new Canvas();
                    _tabAdd.Header = "+";
                    _tabAdd.MouseLeftButtonUp += _tabAdd_MouseLeftButtonUp;
                    _tabItems.Add(_tabAdd);
                    this.AddTabItem();   // add first tab
                    // bind tab control
                    tabDynamic.DataContext = _tabItems;
                    tabDynamic.SelectedIndex = 0;
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
            private TabItem AddTabItem()
                int count = _tabItems.Count;
                // create new tab item
                TabItem tab = new TabItem();
                tab.Header = string.Format("Tab {0}", count);
                tab.Name = string.Format("tab{0}", count);
                tab.HeaderTemplate = tabDynamic.FindResource("TabHeader") as DataTemplate;
                // add controls to tab item, this case I added just a canvas
                Canvas canvas = new Canvas();
                canvas.Name = "canvas";
                Canvas canvas1 = new Canvas();
                canvas1.Name = "canvas1";
                // defining the background color of "canvas"
                switch (count)
                    case 0:
                        canvas.Background = Brushes.Green;
                        break;
                    case 1:
                        canvas.Background = Brushes.Red;
                        break;
                    case 2:
                        canvas.Background = Brushes.Blue;
                        break;
                    case 3:
                        canvas.Background = Brushes.Yellow;
                        break;
                    case 4:
                        canvas.Background = Brushes.Brown;
                        break;
                    case 5:
                        canvas.Background = Brushes.Orange;
                        break;
                    case 6:
                        canvas.Background = Brushes.Olive;
                        break;
                    default:
                        break;
                // Canvas_Paint defines the background color of  "canvas1"
    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
            //    tab.Content = canvas;     // ORIGINAL (commented out) to populate tab.Content with canvas
                Canvas_Paint();
                tab.Content = canvas1;      //  NEW to populate tab.Content with canvas
    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                // insert tab item right before the last (+) tab item
                _tabItems.Insert(count - 1, tab);
                return tab;
            private void _tabAdd_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
                TabItem newTab = this.AddTabItem();
                // clear tab control binding
                tabDynamic.DataContext = null;
                // bind tab control
                tabDynamic.DataContext = _tabItems;
                tabDynamic.SelectedItem = newTab;
            private void Canvas_Paint()
                int count = _tabItems.Count;
                switch (count)
                    case 0:
                        canvas1.Background = Brushes.Green;
                        break;
                    case 1:
                        canvas1.Background = Brushes.Red;
                        break;
                    case 2:
                        canvas1.Background = Brushes.Blue;
                        break;
                    case 3:
                        canvas1.Background = Brushes.Yellow;
                        break;
                    case 4:
                        canvas1.Background = Brushes.Brown;
                        break;
                    case 5:
                        canvas1.Background = Brushes.Orange;
                        break;
                    case 6:
                        canvas1.Background = Brushes.Olive;
                        break;
                    default:
                        break;
            private void tabDynamic_SelectionChanged(object sender, SelectionChangedEventArgs e)
    and the xml is
    <Window x:Class="WPFDynamicTab.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Dynamic Tab" Height="300" Width="527" WindowStartupLocation="CenterScreen">
        <Grid>
            <TabControl Name="tabDynamic" ItemsSource="{Binding}" SelectionChanged="tabDynamic_SelectionChanged">
                <TabControl.Resources>
                    <DataTemplate x:Key="TabHeader" DataType="TabItem">
                        <DockPanel>
                            <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=TabItem }, Path=Header}" />
                        </DockPanel>
                    </DataTemplate>
                </TabControl.Resources>
            </TabControl>
        </Grid>
    </Window>
    The problem is when i use the Canvas "canvas" with the canvas pouplated within the method  all is ok  , however using "canvas1" where canvas1 is populated in Canvas_Paint 
    "canvas1" has null entries. How can I set the background colour in the tab using Canvas_Paint. Can the canvs be put in the XML? I hve simplified the problem from a much more complicated one in order to highlight the problem
    steve

    >>I asked about inserting a canvas into a tab item and ws given an answer which helped sort the problem , howvere i have hit another problem , the code is
    Please close your previous threads by marking helpful posts as answer before starting a new one. And please only ask one question per thread.
    >>How can I set the background colour in the tab using Canvas_Paint?
    You never set the Background of the canvas1 that you create in the AddTabItem() and use as the Content of the TabItem. Just remove this line from this method:
    Canvas canvas1 = new Canvas();
    ...and you will see the background:
    private TabItem AddTabItem()
    int count = _tabItems.Count;
    // create new tab item
    TabItem tab = new TabItem();
    tab.Header = string.Format("Tab {0}", count);
    tab.Name = string.Format("tab{0}", count);
    tab.HeaderTemplate = tabDynamic.FindResource("TabHeader") as DataTemplate;
    // add controls to tab item, this case I added just a canvas
    Canvas canvas = new Canvas();
    canvas.Name = "canvas";
    canvas1.Name = "canvas1";
    // defining the background color of "canvas"
    switch (count)
    case 0:
    canvas.Background = Brushes.Green;
    break;
    case 1:
    canvas.Background = Brushes.Red;
    break;
    case 2:
    canvas.Background = Brushes.Blue;
    break;
    case 3:
    canvas.Background = Brushes.Yellow;
    break;
    case 4:
    canvas.Background = Brushes.Brown;
    break;
    case 5:
    canvas.Background = Brushes.Orange;
    break;
    case 6:
    canvas.Background = Brushes.Olive;
    break;
    default:
    break;
    // Canvas_Paint defines the background color of "canvas1"
    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    //tab.Content = canvas; // ORIGINAL (commented out) to populate tab.Content with canvas
    Canvas_Paint();
    tab.Content = canvas1; // NEW to populate tab.Content with canvas
    // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    // insert tab item right before the last (+) tab item
    _tabItems.Insert(count - 1, tab);
    return tab;
    Another approach bay be to pass the Canvas element to the painted to the Canvas_Paint() method by reference instead of using a class-level field:
    Canvas_Paint(ref canvas1);
    tab.Content = canvas1;
    private void Canvas_Paint(ref Canvas canvas1)
    int count = _tabItems.Count;
    switch (count)
    case 0:
    canvas1.Background = Brushes.Green;
    break;
    case 1:
    canvas1.Background = Brushes.Red;
    break;
    case 2:
    canvas1.Background = Brushes.Blue;
    break;
    case 3:
    canvas1.Background = Brushes.Yellow;
    break;
    case 4:
    canvas1.Background = Brushes.Brown;
    break;
    case 5:
    canvas1.Background = Brushes.Orange;
    break;
    case 6:
    canvas1.Background = Brushes.Olive;
    break;
    default:
    break;
    Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

  • How to use stacked canvas

    hi,
    i use oracle forms 10g ,win xp pack2 ...
    i want to elimine empty records in my forms using stacked canvas !!
    thnx
    show this image :
    http://nsa30.casimages.com/img/2012/12/30/121230071422805901.png
    Edited by: 979155 on 31 déc. 2012 10:01

    You have to define the number of records that you want to display - it is not dynamic so I doubt it could be done. You might be able to do something with visual attributes to make it more appealing to the eye, but you would still have empty cells displaying if there wasn't data for those records.

  • Dreamweaver Freezes when I use the query mobile swatch panel

    Every time I open and use the jquery mobile swatch panel, dreamweaver freezes and stops working. I have to force it to close. This problem started when I upgraded to CC 2 days ago... never with CS6.
    Any help or suggestions would be great.
    Thanks.

    Ok, I don't have a crash report and all, but I have reported my issue in reports to Adobe.
    Adobe CS5 Mac OS 10.6.7 iMac (Intel) 2010
    Happened several times since I use this effect quite a bit.
    I have a block of area text with a placed .psd photo which has possibly a clipping path (or not) and a separate stroke box for a border, grouped together and then a drop shadow applied. Then select both group and text block and apply text warp. Then select just the photo group and try to nudge it by using the arrow keys on my Apple factory shipped keyboard.
    Usually hit the arrow key 3 to 4 times before I realize that I get the spinning wheel of death and finally crash.
    Can anyone duplicate this?

  • Does ADF supports using HTML5 canvas tag?

    Hi
    My use case is to render the PDF using canvas tag introduced in HTML5 and java script. but I could not find any ADF faces component with Canvas behavior so I thought of using html canvas tag in a jsff page directly
    I am new to JDeveloper so please let me know is there a way to use HTML5 tags directly on .jsff page?
    Thanks,
    Suresh K

    I'm not aware of y component in adf that supports canvas. You can try to include yout html in f:verbatim tags and see what you get.
    Timo

Maybe you are looking for

  • Report On Receipt Of materials for a material Group

    Dear All,            I have a requirement. I want the value of goods receipt for a particular material group for a particular period. MB51 does not provide input for material group.           I have seen other standard reports related to purchase , b

  • Issues with Exporting files using Lightroom 5

    I bought Lightroom 5 for Mac a couple of months ago and have been using it without any issues, then out of the blue I ran into export problems. Sometimes the exported images wouldn’t have the sharpness adjustments, sometimes it wouldn’t have the nois

  • How to manage Folder names in different languages

    In our project we are implementing IMAP protocol and using Exchange server. When an account created in Exchange, many default folders are created. We need some of them for example Outbox,Sent Items,Drafts... But these folder names are language depend

  • How do I see a reply to my question

    can not find the answers to any questions,only questions, where are the answers?How do I bring them up to read? This question was solved. View Solution.

  • 10dB boost for LFE an Audigy Platinum (hard- or software)?

    ; I read that the Audigy Platinums LFE channel?has 0dB less volume then the rest, and is therefore not working correctly on non creative sound systems. So how can i give?my LFE signal?a 0dB boost? Any simple hard oder software solutions?