Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26
  1. #21
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    create an SSCCE so I can run your code. Please read the link above.

  2. #22
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Also, when adding a new component to a container, make sure you tell the container's layout manager to layout the new component by calling revalidate on it, and make sure that the new component paints itself by calling repaint:
    Java Code:
        if (e.getSource() == answer1)
        {
          fileNumber++;
          drawingPanel draw = new drawingPanel(files, fileNumber);
          panel.add(draw);
          panel.revalidate();
          draw.repaint();
        }

  3. #23
    cassysumandak is offline Member
    Join Date
    Mar 2009
    Posts
    38
    Rep Power
    0

    Default

    Dear Fubarable,
    After adding the code that you suggested, the drawing finally comes out on the drawing Panel when I click the button (This really put me in Cloud nine :-)).

    Java Code:
        if (e.getSource() == answer1)
        {
          panel.revalidate();
          draw.repaint();
        }
    However when I click the button again, the drawing seems static and not change (there are five record in the arrays).

  4. #24
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    If you want more help, then you are again advised to create an Short, Self Contained, Correct (Compilable), Example (SSCCE).

  5. #25
    cassysumandak is offline Member
    Join Date
    Mar 2009
    Posts
    38
    Rep Power
    0

    Default

    Dear Fubarable,
    Finally my program works....I put the remove () code which replace the previous drawing, so that the new drawing place on the panel. Before this, the drawing actually placed on the side of the existing drawing (like a flow layout).

    I am so thankful to all your help. May god bless you.

    Java Code:
    if (e.getSource() == answer1){
    	[COLOR="Blue"]panel.removeAll ();[/COLOR]
    	draw = new drawingPanel(files,fileNumber);	
    	panel.add(draw);
    [COLOR="Blue"]	panel.revalidate();
    	panel.repaint();	
    [/COLOR]	fileNumber++;
    }

  6. #26
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Cool. I'm glad that you've got it working. When I see a lot of removes and adds, I think that sometimes a CardLayout could simplify things. Just something to think about.

    Pete

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 1
    Last Post: 03-03-2009, 12:46 AM
  2. Controlling Page Scroll Position in Jsp....f there are fewer than 4 pages only that n
    By 82rathi.angara in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 07-05-2008, 02:11 PM
  3. Using SWT Button
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-08-2008, 09:05 AM
  4. Controlling method calls
    By bugger in forum New To Java
    Replies: 2
    Last Post: 01-04-2008, 01:14 PM
  5. controlling GC
    By ravian in forum Eclipse
    Replies: 2
    Last Post: 01-03-2008, 08:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •