I need help with my remove method on a BST!

Guys I need some help here, I have to create a remove method for a BST and below is my code:
public boolean remove(OrderedMap map, K keyOfelementToRemove) {
          boolean result = false;
          if (root == null)
               result = false;
          else {
               MapNode curr = root;
               MapNode prev = root;
               while (curr.key.equals(keyOfelementToRemove) == false) {
                    prev = curr;
                    if (keyOfelementToRemove.compareTo(curr.key) < 0)
                         curr = curr.left;
                    else if (keyOfelementToRemove.compareTo(curr.key) > 0)
                         curr = curr.right;
                    if (curr == null)
                         break;
               if (curr == null)
                    return result;
               else if (curr == root && curr.left == null)
                    root = root.right;
               else if (curr.left == null) {
                    if (curr.right == null)
                         curr = null;
                    else if (curr == prev.left)
                         prev = curr.right;
                    else if (curr == prev.right){
                         prev = curr.right;
               else if (curr.left != null) {
                    MapNode temp = curr.left;
                    while (temp.right != null)
                         temp = temp.right;
                    K change = temp.key;
                    temp = null;
                    curr.key = change;
          size--;
          return result;
     }the algorithm that my instructor provides is:
private boolean remove( BinaryTreeNode t, Comparable elementToRemove )
Set result to false
Traverse the tree t until elementToRemove is found. Use curr and prev to find the element
leaving curr referring the node you want to remove. It may be the case that curr is null indicating
that elementToRemove was not found. Now there are four cases to consider :
Case 1: Not found
return result (false)
Case 2: The root is to be removed, but it has no left child.
root = root's right subtree (assuming root refers the the root node in your BST)
Case 3: The node is further down tree with no left child. Now must adjust one of the parent's links
if curr is on the left side of prev,
move parent's left link down to down to curr's right child
else
curr is on the right side of prev, so move parent's right down to down to curr's right child
Case 4: curr has a left child.
We can no longer ignore the left subtree. So find the maximum in the left subtree and
move that object to the node referenced by curr . Then eliminate the maximum in the
left subtree, which is now being reference from the original node to remove.
however for case 3 and 4 it doesn't work, can someone please tell me why? I don't know where I made a mistake and I tried finding it but I still dont know

I am sorry about the double post. I'll try not to do this again. My problem here seems to be that prev and curr aren't updating the BST outside this method, which means that it only changes locally but not permanently. I will post the code of the other headings:
public class OrderedMap<K extends Comparable<K>, V> {
     private class MapNode {
          // Links to other BSTs
          private MapNode left;
          private MapNode right;
          ArrayList<V> temp1 = new ArrayList<V>();
          // The references to the key/value pair of the mapping
          private K key;
          @SuppressWarnings("unused")
          private V value;
          public MapNode(K theKey, V theValue) {
               key = theKey;
               value = theValue;
               left = null;
               right = null;
     } // end class MapNode
     private MapNode root;
     private int size;
     public OrderedMap() { // Create an empty tree
          root = null;
          size = 0;
     public int size() {
          return size;
     }

Similar Messages

  • Need help with a remove method..

    Hello. I'm getting started on a project here to implement a recursive remove method that will remove any number from a list. I was given a test that the method must pass, but I'm having some trouble getting started. This is my second interaction with the idea of recursion and it's a bit difficult for me.
    Here is the test I'm writing the method for:
    public void testRemove() {
              int element=0;
              boolean inList = false;
              for (int i = -10; i < 11; i++)list.insert(i);
              int numElements = list.length();
              list.remove(element);
              for (int e : list) {
                   if ( e == element ) inList = true;
              assertTrue(!inList && (list.length()==(numElements-1)));
              element = -10;
              inList = false;
              list.remove(element);
              for (int e : list) {
                   if ( e == element ) inList = true;
              assertTrue(!inList && (list.length()==(numElements-2)));
              element = 10;
              inList = false;
              list.remove(element);
              for (int e : list) {
                   if ( e == element ) inList = true;
              assertTrue(!inList && (list.length()==(numElements-3)));
              //does remove work when element's value greater than value of last item in list
              element = 20;
              inList = false;
              list.remove(element);
              for (int e : list) {
                   if ( e == element ) inList = true;
              assertTrue(!inList && (list.length()==(numElements-3)));
              //does remove work when element's value less than value of first item in list
              element = -20;
              inList = false;
              list.remove(element);
              for (int e : list) {
                   if ( e == element ) inList = true;
              assertTrue(!inList && (list.length()==(numElements-3)));
              System.out.printf("%s\n", "testRemove " + list.toString());
         }Now, clearly I need to test whether or not the number being removed is in the list (too low/too high), but I'm stuck trying to implement this.
    If anyone can give me any ideas or direction it would be greatly appreciated.

    Thanks for the quick reply, from what I had gathered and what you posted I'm starting to see where I need to go from here. I had gotten as far as if list is null return null, and the cod that you posted makes sense, but implementing it into the source code I already have will be troubling for me. The code as you presented it I have no trouble understanding, for example:
    if (list.data == data) return list.next;
    list.next=remove(list.next, data);Is clear to me, however I don't know how to implement that into my code. This is the code for the insert method:
         private Node<ElementType> insertp(Node<ElementType> list, ElementType element) {
              if ( (list == null) || ( element.compareTo(list.getElement() ) < 0 ) ) {
                   // test for insert at head or before current node
                   Node<ElementType> newNode = new Node<ElementType>(element, null);
                   newNode.setNext(list);
                   return newNode;
              else if (list.getNext() == null) { // list with one element
                   Node<ElementType> newNode = new Node<ElementType>(element, null);
                   list.setNext(newNode);         // element goes at end
              else if ( element.compareTo(list.getNext().getElement()) < 0 ) { // insert after list
                   Node<ElementType> newNode = new Node<ElementType>(element, list.getNext());
                   //newNode.setNext(list.getNext());
                   list.setNext(newNode);
              else {
                   insertp(list.getNext(), element); // find insertion point
              return list;
         }I'm still struggling to understand all of the code there. the element.compareTo() and everything. If you (or some one else) can explain to me what is going on with those methods, I may be able to implement it myself. Also, this may be of some use, these are the methods I have available to me:
    public class Node<E> {
      // Instance variables:
      private E element;
      private Node<E> next;
      /** Creates a node with null references to its element and next node. */
      public Node() {
        this(null, null);
      /** Creates a node with the given element and next node. */
      public Node(E e, Node<E> n) {
        element = e;
        next = n;
      // Accessor methods:
      public E getElement() {
        return element;
      public Node<E> getNext() {
        return next;
      // Modifier methods:
      public void setElement(E newElem) {
        element = newElem;
      public void setNext(Node<E> newNext) {
        next = newNext;
      public String toString() {
           return element.toString();
    }

  • Need Help with a getText method

    Gday all,
    I need help with a getText method, i need to extract text from a JTextField. Although this text then needs to converted to a double so that i can multiply a number that i have already specified. As you may of guessed that the text i need to extract already will be in a double format.e.g 0.1 or 0.0000004 etc
    Thanks for your help
    ps heres what i have already done its not very good though
    ToBeConverted.getText();
    ( need help here)
    double amount = (and here)
    total = (amount*.621371192);
    Converted.setText("= " + total);

    Double.parseDouble( textField.getText() );

  • I need help with this recursion method

         public boolean findTheExit(int row, int col) {
              char[][] array = this.getArray();
              boolean escaped = false;
              System.out.println("row" + " " + row + " " + "col" + " " + col);
              System.out.println(array[row][col]);
              System.out.println("escaped" + " " + escaped);
              if (possible(row, col)){
                   System.out.println("possible:" + " " + possible(row,col));
                   array[row][col] = '.';
              if (checkBorder(row, col)){
                   System.out.println("check border:" + " " + checkBorder(row,col));
                   escaped = true;
              else {
                    System.out.println();
                    escaped = findTheExit(row+1, col);
                    if (escaped == false)
                    escaped = findTheExit(row, col+1);
                    else if (escaped == false)
                    escaped = findTheExit(row-1, col);
                    else if (escaped == false)
                    escaped = findTheExit(row, col-1);
              if (escaped == true)
                   array[row][col] = 'O';
              return escaped;
         }I am having difficulties with this recursion method. What I wanted here is that when :
    if escaped = findTheExit(row+1, col);  I am having trouble with the following statement:
    A base case has been reached, escaped(false) is returned to RP1. The algorithm backtracks to the call where row = 2 and col = 1 and assigns false to escaped.
    How do I fix this code?
    I know what's wrong with my code now, even though that if
    if (possible(row, col))
    [/code[
    returns false then it will go to if (escaped == false)
                   escaped = findTheExit(row, col+1);
    how do I do this?

    Okay I think I got the problem here because I already consult with the instructor, he said that by my code now I am not updating my current array if I change one of the values in a specific row and column into '.' . How do I change this so that I can get an update array. He said to me to erase char[][] array = getArray and replace it with the array instance variable in my class. But I don't have an array instance variable in my class. Below is my full code:
    public class ObstacleCourse implements ObstacleCourseInterface {
         private String file = "";
         public ObstacleCourse(String filename) {
              file = filename;
         public boolean findTheExit(int row, int col) {
              boolean escaped = false;
              //System.out.println("row" + " " + row + " " + "col" + " " + col);
              //System.out.println(array[row][col]);
              //System.out.println("escaped" + " " + escaped);
              if (possible(row, col)){
                   //System.out.println("possible:" + " " + possible(row,col) + "\n");
                   array[row][col] = '.';
                   if (checkBorder(row, col)){
                   escaped = true;
                   else {
                    escaped = findTheExit(row+1, col);
                    if (escaped == false)
                    escaped = findTheExit(row, col+1);
                    else if (escaped == false)
                    escaped = findTheExit(row-1, col);
                    else if (escaped == false)
                    escaped = findTheExit(row, col-1);
              if (escaped == true)
                   array[row][col] = 'O';
              return escaped;
         public char[][] getArray() {
              char[][] result = null;
              try {
                   Scanner s = new Scanner(new File(file));
                   int row = 0;
                   int col = 0;
                   row = s.nextInt();
                   col = s.nextInt();
                   String x = "";
                   result = new char[row][col];
                   s.nextLine();
                   for (int i = 0; i < result.length; i++) {
                        x = s.nextLine();
                        for (int j = 0; j < result.length; j++) {
                             result[i][j] = x.charAt(j);
              } catch (Exception e) {
              return result;
         public int getStartColumn() {
              char[][] result = this.getArray();
              int columns = -1;
              for (int i = 0; i < result.length; i++) {
                   for (int j = 0; j < result[i].length; j++) {
                        if (result[i][j] == 'S')
                             columns = j;
              return columns;
         public int getStartRow() {
              char[][] result = this.getArray();
              int row = -1;
              for (int i = 0; i < result.length; i++) {
                   for (int j = 0; j < result[i].length; j++) {
                        if (result[i][j] == 'S')
                             row = i;
              return row;
         public boolean possible(int row, int col) {
              boolean result = false;
              char[][] array = this.getArray();
              if (array[row][col] != '+' && array[row][col] != '.')
                   result = true;
              return result;
         public String toString() {
              String result = "";
              try {
                   Scanner s = new Scanner(new File(file));
                   s.nextLine();
                   while (s.hasNextLine())
                        result += s.nextLine() + "\n";
              } catch (Exception e) {
              return result;
         public boolean checkBorder(int row, int col) {
              char[][] array = this.getArray();
              boolean result = false;
              int checkRow = 0;
              int checkColumns = 0;
              try {
                   Scanner s = new Scanner(new File(file));
                   checkRow = s.nextInt();
                   checkColumns = s.nextInt();
              } catch (Exception e) {
              if ((row + 1 == checkRow || col + 1 == checkColumns) && array[row][col] != '+')
                   result = true;
              return result;
    I thought that my problem would be not to read the file using the try and catch everytime in the method. How do I do this?? Do I have to create an array instance variable in my class?

  • Need Help with new Classes / methods

    Hi, I need to create a class called Proposition. It include a Proposition object with 3 variables
    Name, Description, Value
    This is the constructor I wrote:
    private String name;
    private String description;
    private boolean value;
    public Proposition(){
              name = "name";
              description = "description";
              value = false;
    }Now I need a method that give values to the 3 variables in the proposition object:
         public Proposition setProp(String line){
              StringTokenizer ST1 = new StringTokenizer(line, ".");
              String ValidLine = ST1.nextToken()+".";
              StringTokenizer ST2 = new StringTokenizer(ValidLine, "=");
              name = CutSpace(ST2.nextToken());
              description = (ST2.nextToken()).trim();
              value = false;
              return name;
              return description;
              return value;
         }An example of String line is: v = we are in Vancouver.
    When I run the program, I got error message with the 3 return statements saying found String/Boolean while Proposition is needed. I'm not quite sure how to write the return statements. Can any1 help?
    Thx!

    Your setProp() method should not be returning anything. After all it is setting not getting. So just declare it as
    public void setProp(String line){and remove the return statements.

  • NEED HELP WITH USING STATIC METHOD - PLEASE RESPOND ASAP!

    I am trying to set a value on a class using a static method. I have defined a servlet attribute (let's call it myAttribute) on my webserver. I have a serlvet (let's call it myServlet) that has an init() method. I have modified this init() method to retrieve the attribute value (myAttribute). I need to make this attribute value accessible in another class (let's call it myOtherClass), so my question revolves around not knowing how to set this attribute value on my other class using a static method (let's call it setMyStuff()). I want to be able to make a call to the static method setMyStuff() with the value of my servlet attribute. I dont know enough about static member variables and methods. I need to know what to do in my init() method. I need to know what else I need to do in myServlet and also what all I need in the other class as well. I feel like a lot of my problems revolve around not knowing the proper syntax as well.
    Please reply soon!!! Thanks in advance.

    class a
    private static String aa = "";
    public static setVar (String var)
    aa = var;
    class b
    public void init()
    a.aa = "try";
    public static void main(String b[])
    b myB = new b ();
    b.init();
    hope this help;
    bye _drag                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Need help with project (calling methods) please!!

    Hi there i have a project for uni requiring me to create a java program that creates a random No. and lets the user have three guesses to find the No. When the users guesses correct he gets a message telling him hes won and if he doesnt get it correct he gets a message telling him the correct No then terminates.
    The code has to call an outside method called[b] Public Static Boolean CheckGuess
    I have tried to create this and got it to compile with no errors (eventually) but i keep getting a message saying i have whenever i type any number in. I think the problem is the way i am calling the method i havnt got much experience this is all pretty new to me any help would be really appreciated. Thanks.
    import javax.swing.*;
    import java.util.*;
    public class Coursework1{
         public static void main(String args[]){
              int randomnumber,usersguessint,checkguess,guessvalid,attempts;
              String usersguess,output;
              boolean match;
              //create random number generator
              Random numGenerator = new Random();
              //generate a random number between 1 & 10 inclusive
              randomnumber = Math.abs(numGenerator.nextInt(9))+1;
              //initialize variable attempts
              for ( attempts = 0; attempts < 3; attempts++ ) {
                   //ask user for his first guess
                   usersguess=JOptionPane.showInputDialog("Please enter your guess between 1 & 10");
                   //convert users guess to integer
                   usersguessint = Integer.parseInt(usersguess);
                        //validate input
                        while (usersguessint<1||usersguessint>10){
                        usersguess=JOptionPane.showInputDialog("You entered an incorrect number \nPlease enter a numberbetween 1 & 10");
                         //convert users guess to integer
                        usersguessint = Integer.parseInt(usersguess);
                        } //end while loop
                             //call boolean method
                             if (match=true){
                             //display text area in JoptionPane
                             output="You won";
                             JOptionPane.showMessageDialog(null,output,"You Won",JOptionPane.INFORMATION_MESSAGE);
                             break;}
                             else{
                             output="Try again";     
                             JOptionPane.showInputDialog("Try again");
                                  }     //end if
                   } //end for
              }//end main
                             //user defined method
                             public static boolean checkGuess(int usersguessint,int randomnumber){
                             boolean match = false;
                             if (usersguessint == randomnumber){
                             match = true;
                             return match;
                             }//end method
         }//endclass

    Thank you very much that worked a treat the program is working better now. I have just realised that my for loopcontaining my counter may be in the wrong place as the program is running though both messages 3 times e.g
    "Please enter your guess between 1 & 10"
    "Try again"
    "Please enter your guess between 1 & 10"
    "Try again"
    "Please enter your guess between 1 & 10"
    "Try again"
    "Please enter your guess between 1 & 10"
    "Try again"
    I want my program to run like
    "Please enter your guess between 1 & 10"
    "Try again"
    "Try again"
    "Try again"
    Do u think if i placed my for stament (counter) in between the two messages it would eliminate this problem.

  • Need help with background removed in elements 10

    I have been watching and learning from tutorials online and have found one of the easiest to use for removing a background I have elements 10 and when I click on New under file it shows I
    should be able to open the image from clipboard window but it is not high lighted to do so. What am I doing wrong???

    Open your image
    Go to Select menu>all
    Go to Edit menu>copy to put image on the clipboard
    Go to File menu>New>Image from clipboard
    Is this what you are after?

  • Need help with my exit method

    hey to all my java Pals =)
    i am working on an application right now
    and my exit method behaves strangly
    when you go to File|Exit
    it will say
    "this will exit are you sure
    if the user says yes it will exit the program but if he says no it wont
    but when you close it from the X up the Corner of the screen
    it will say
    "this will exit are you sure
    but regardless of what user chose Yes|NO it will exit
    what am i doing wrong thanks
    my code
    //File | Exit action performed
      public void jMenuFileExit_actionPerformed(ActionEvent e) {
        int forExit;
    forExit = JOptionPane.showConfirmDialog(null,"This will Exit..........!!!!"+"\n"+"Are you Sure?","Exit?",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE);
        System.out.println(forExit);
        if(forExit==0){
          System.exit(0);
    //and for overriding the (X) on corner
    protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
         if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          jMenuFileExit_actionPerformed(null);
      }sorry for my spelling its 12 at night and i didnt spell check
    Thanks in advance

    here is the code
    public Frame1() {
        addWindowListener(new java.awt.event.WindowAdapter(){
           public void windowClosing(java.awt.event.WindowEvent evt){
              jMenuFileExit_actionPerformed(null);
         });and the exit
    public void jMenuFileExit_actionPerformed(ActionEvent e) {
        int forExit;
        forExit = JOptionPane.showConfirmDialog(null,"This will Exit..........!!!!"+"\n"+"Are you Sure?","Exit?",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE);
        System.out.println(forExit);
        if(forExit==0){
          System.exit(0);
      }

  • Need help with Sound Methods

    Hi, I am new to java and need help with sound methods.
    q: create a new method that will halve the volume of the positive values and double the volume of the negative values.
    Message was edited by:
    Apaula30

    duplicate message #2

  • I need to need help with changing my app store to canada to us but i have 49cents balance can you remove it please

    I need to need help with changing my app store to canada to us but i have 49cents balance can you remove it please

    Contact iTunes Support - http://apple.com/emea/support/itunes/contact.html - and ask them to clear your balance.

  • I need Help with a website I've created

    I need help with a website I've created (www.jonathanhazelwood.com/lighthouse) I created the folowing site with dreamweaver at my current resolution 1366 by 768. Looks great on my screen resolution but if it is viewed on other resolutions the menu moves and some of the text above and below. How can I keep all content centered and working like it does on 1366 by 768 on all resolutions. The htm to my site is below I started off with a blank template through dreamweaver CS5.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>The Lighthouse Church</title>
    <style type="text/css">
    <!--
    body {
        font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
        background: #42413C;
        margin: 0;
        padding: 0;
        color: #000;
        background-color: #000;
    /* ~~ Element/tag selectors ~~ */
    ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
        padding: 0;
        margin: 0;
    h1, h2, h3, h4, h5, h6, p {
        margin-top: 0;     /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
        padding-right: 15px;
        padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
    a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
        border: none;
    /* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
    a:link {
        color: #42413C;
        text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
    a:visited {
        color: #6E6C64;
        text-decoration: underline;
    a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
        text-decoration: none;
    /* ~~ this fixed width container surrounds all other elements ~~ */
    .container {
        width: 960px;
        background: #FFF;
        margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout */
    /* ~~ This is the layout information. ~~
    1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.
    .content {
        padding: 10px 0;
    /* ~~ miscellaneous float/clear classes ~~ */
    .fltrt {  /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
        float: right;
        margin-left: 8px;
    .fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */
        float: left;
        margin-right: 8px;
    .clearfloat { /* this class can be placed on a <br /> or empty div as the final element following the last floated div (within the #container) if the overflow:hidden on the .container is removed */
        clear:both;
        height:0;
        font-size: 1px;
        line-height: 0px;
    #apDiv1 {
        position:absolute;
        width:352px;
        height:2992px;
        z-index:1;
        top: 171px;
        left: 507px;
    #apDiv2 {
        position:absolute;
        width:961px;
        height:1399px;
        z-index:1;
        left: 187px;
        top: 1px;
    #apDiv3 {
        position:absolute;
        width:961px;
        height:1001px;
        z-index:1;
        top: -2px;
    #apDiv4 {
        position:absolute;
        width:963px;
        height:58px;
        z-index:1;
        left: 0px;
        top: 101px;
    #apDiv5 {
        position:absolute;
        width:961px;
        height:1505px;
        z-index:1;
        top: -5px;
    #apDiv6 {
        position:absolute;
        width:962px;
        height:150px;
        z-index:1;
        left: 0px;
        top: -1px;
    #apDiv7 {
        position:absolute;
        width:361px;
        height:25px;
        z-index:2;
        left: 35px;
        top: 1308px;
    #apDiv8 {
        position:absolute;
        width:320px;
        height:24px;
        z-index:2;
        left: 200px;
        top: 1479px;
    #apDiv9 {
        position:absolute;
        width:962px;
        height:63px;
        z-index:3;
        left: -10px;
        top: -1292px;
    #apDiv10 {
        position:absolute;
        width:270px;
        height:27px;
        z-index:2;
        left: 200px;
        top: 1478px;
    #apDiv11 {
        position:absolute;
        width:961px;
        height:44px;
        z-index:3;
        left: 195px;
        top: 183px;
    -->
    </style>
    <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    #apDiv12 {
        position:absolute;
        width:295px;
        height:23px;
        z-index:4;
        left: 198px;
        top: 1px;
    #apDiv13 {
        position:absolute;
        width:135px;
        height:22px;
        z-index:5;
        left: 1001px;
        top: 3px;
    #apDiv14 {
        position:absolute;
        width:309px;
        height:992px;
        z-index:1;
        left: 33px;
        top: 479px;
    #apDiv15 {
        position:absolute;
        width:327px;
        height:999px;
        z-index:1;
        left: 324px;
    #apDiv16 {
        position:absolute;
        width:262px;
        height:1000px;
        z-index:2;
        left: 674px;
        top: 477px;
    #apDiv17 {
        position:absolute;
        width:85px;
        height:34px;
        z-index:1;
        left: -379px;
        top: 1001px;
    #apDiv18 {
        position:absolute;
        width:200px;
        height:115px;
        z-index:6;
    #apDiv19 {
        position:absolute;
        width:168px;
        height:31px;
        z-index:3;
        left: 448px;
        top: 1451px;
    #apDiv20 {
        position:absolute;
        width:94px;
        height:33px;
        z-index:3;
        left: 384px;
        top: 1477px;
    body {
        background-color: #000;
        margin-left: 0px;
        margin-right: 0px;
    #apDiv21 {
        position:absolute;
        width:920px;
        height:200px;
        z-index:4;
        left: 19px;
        top: 233px;
    </style>
    </head>
    <body>
    <div class="container">
      <div class="content">
        <div id="apDiv5">
          <div id="apDiv16">
            <div id="apDiv17">
              <map name="Map2" id="Map2">
                <area shape="rect" coords="4,2,77,28" href="http://www.myspace.com/lighthousechurch1" />
              </map>
              <img src="paypal-donate-button.png" width="83" height="33" border="0" usemap="#Map" />
              <map name="Map" id="Map">
                <area shape="rect" coords="2,2,80,30" href="https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=HgApKd0bxyPQv1ixwBW3HgWXaLxPIiT Po9gSsRELLQp72IZ2-_8uvSmCLRO&dispatch=5885d80a13c0db1f8e263663d3faee8d9384d85353843a619606 282818e091d0" />
              </map>
            </div>
          </div>
          <div id="apDiv21">
            <blockquote>
              <blockquote>
                <blockquote>
                  <blockquote>
                    <blockquote>
                      <blockquote>
                        <p><img src="faithexplosion.png" width="314" height="225" /></p>
                      </blockquote>
                    </blockquote>
                  </blockquote>
                </blockquote>
              </blockquote>
            </blockquote>
          </div>
          <div id="apDiv14">
            <div id="apDiv15">
              <div>
                <div>
                  <p> Special Message from Perry Stone </p>
                  <h2> Was Jesus Born on December 25?</h2>
                  <p> 12/20/2010 </p>
                  <p><img alt="iStock_000003631829XSmall" src="http://www.voe.org/images/iStock_000003631829XSmall.jpg" width="300" height="234" /></p>
                  <p>Last   year, in response to the growing number of Christians who celebrate   Hanukkah but hate Christmas, I wrote an article for this website titled   &ldquo;Hanukkah or Christmas?&rdquo; I explained why I think Jesus was either   conceived or birthed on December 25.</p>
                </div>
              </div>
              <div>
                <div><a href="http://www.voe.org/Prophecy-Update/what-happened-to-global-warming.html"> READ MORE</a>
                  <p> Prophecy Update </p>
                  <h2> What Happened to Global Warming?</h2>
                  <p> 12/17/2010 </p>
                  <p> </p>
                </div>
              </div>
              <div>
                <div></div>
              </div>
              <div>
                <div></div>
              </div>
            </div>
            <div>
              <p><font size="2">Special Word</font></p>
              <p><font size="2">January 7th, 2011</font></p>
              <p> <font size="2">Dear Viewers:</font></p>
              <p><font size="2">We have now entered into one of the most trying times; but also one of the most glorious            times in church history.  Many things are coming upon the world and also upon the church and we (the church) must be totally            prepared to take up our cross daily and venture out into the lost and</font></p>
              <p>  <a href="http://sermon.lighthousechurchinc.org/2011/01/07/special-word-1711-evangelist-barbara-lync h.aspx" target="_parent">Click Here for More</a></p>
            </div>
            <p> </p>
            <div></div>
            <div>
            <!--//              weAddFlash("lhi09hdr.swf",800, 100,"true","true","high","showall","true","#ffffff");              //--></div>
            <div></div>
            <p> </p>
          </div>
          <img src="lighthousegraphic2.jpg" width="960" height="1509" />
          <div id="apDiv20"><img src="myspacebutton.jpg" width="89" height="30" border="0" usemap="#Map3" />
            <map name="Map3" id="Map3">
            <area shape="rect" coords="3,2,87,28" href="http://www.myspace.com/lighthousechurch1" />
          </map>
      </div>
        </div>
      <p> </p>
      </div>
    <!-- end .container --></div>
    <div id="apDiv10"><font size="1"><font color="#FFFFFF">Copyright 2011 The Lighthouse Church Inc.</font></font></div>
    <div id="apDiv11">
      <ul id="MenuBar1" class="MenuBarHorizontal">
        <li><a href="#">Home</a>    </li>
        <li><a href="#" class="MenuBarItemSubmenu">Our Pastor</a>
          <ul>
            <li><a href="#">Fresh Word</a></li>
            <li><a href="#">Itinerary</a></li>
            <li><a href="#">Prophetic Word</a></li>
            <li><a href="#">Sermons</a></li>
            <li><a href="#">Special Words</a></li>
            <li><a href="#">Word of Month</a></li>
          </ul>
        </li>
        <li><a href="#">Men Ministry</a></li>
        <li><a href="#" class="MenuBarItemSubmenu">Ministers</a>
          <ul>
            <li><a href="#">Chris Gore</a></li>
    </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Our Church</a>
          <ul>
            <li><a href="#">Contact Us</a></li>
            <li><a href="#">Donate</a></li>
            <li><a href="#">Events</a></li>
            <li><a href="#">Our Store</a></li>
            <li><a href="#">Prayer Request</a></li>
            <li><a href="#">Salvation</a></li>
            <li><a href="#">Subscribe</a></li>
            <li><a href="#">Vision</a></li>
            <li><a href="#">We Believe</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Resources</a>
          <ul>
            <li><a href="#">Prepare for Disaster</a></li>
            <li><a href="#">How to Fast</a></li>
            <li><a href="#">Heaven &amp; Hell</a></li>
            <li><a href="#">Warfare Prayers</a></li>
            <li><a href="#">Wisdom Words</a></li>
          </ul>
        </li>
        <li><a href="#" class="MenuBarItemSubmenu">Prophetic</a>
          <ul>
            <li><a href="#">Article Archive</a></li>
            <li><a href="#">Audio Prophecies</a></li>
            <li><a href="#">Color for Year</a></li>
            <li><a href="#">Major Articles</a></li>
            <li><a href="#">Prophecy Archive</a></li>
            <li><a href="#">Prophetic Articles</a></li>
            <li><a href="#">Word for Year</a></li>
          </ul>
        </li>
      </ul>
    </div>
    <div id="apDiv12"><font size="1"><font color="#FFFFFF">6 South Railroad Ave Wyoming,DE 19934</font></font></div>
    <div id="apDiv13"><font size="1"><font color="#FFFFFF">Phone:(302) 697-1472</font></font></div>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    </body>
    </html>

    Look at all the apdiv's you have.  Those are absolutely positioned layers.  I'm assuming by your post that you are very new to Dreamweaver and HTML and CSS.  I would highly recommend not using absolutely positioned layers until you have a better grasp on HTML and CSS.
    Looking at your code I would suggest that you consider using one of Dreamweaver's built in, or downloadable templates as a starting point and work from there. 
    http://www.adobe.com/devnet/dreamweaver/articles/dreamweaver_custom_templates.html

  • [Need help with a swf file]

    Hello,
    I need help with a flash demo that I am creating. I have a
    main swf file that contains links to other sub swfs that I have
    created. What I really want this to do is... when I click on one of
    the link on the browser, the other swf have to load in the window.
    I tried to code it with .loadMovie,.... but for some weird reason,
    it is not showing up.
    Can anyone help me on this?
    Thanks

    you might have a security violation and you do have a
    load-target issue. remove that "_parent": there's no 2nd parameter
    in the loadMovie() method.
    if you want to replace the main swf with that url, loading
    into _root is fine. otherwise, you want to use a different
    target.

  • Need Help With D&D Program

    Hi, I'm not sure if I'm allowed to post questions on this forum but I can't find anywhere to talk to helpful people about programming.
    I'm making a dnd interface for JComponents. So far I've made a simple program that has a Component that can be lifted from a container and braught to the glass pane then later moved to anywhere on the screen and dropped into the container below it. Here's where my problems come:
    1) Rite now my 'Movable Component' is a JPanel which is just colored in. I want to either take a Graphic2d from a JComponent/Component and draw it on the JPanel or change the JPanel to the component I want to paint and disable the component.
    The problem with getting the Graphics2d is that if the component isn't on the screen it doesn't make a graphic object. I tried messing with the ui delicate and overriding parental methods for paintComponent, repaint, and that repaintChildren(forget name) but I haven't had luck getting a good graphics object. I was thinking of, at the beginning of running the program, putting 1 of each component onto the screen for a second then removing it but I'd rather not. I'd also like to change the graphics dynamicly if someone stretches the component there dropping and what not.
    The problem with disabling is that it changes some of the visual features of Components. I want to be able to update the Component myself to change how it looks and I don't want disabling to gray out components.
    I mainly just dont want the components to do any of there normal fuctions. This is for a page builder, by the way.
    Another problem I'm having is that mouseMotionListener is allowing me to select 2 components that are on top of one another when there edges are near each other. I don't know if theres a fix to this other than changing the Java Class.
    My next problem is a drop layout manager, but I'm doing pretty good with that rite now. It'll problem just move components out of the way of the falling component.
    One last thing I need help with is that I don't want the object that's being carried to go across the menu bar and certain areas. When I'm having the object being carried I have it braught up to the glass pane which allows it to move anywhere. Does anyone have any idea how I could prevent the component from being over the menu bars and other objects? I might have to make 1 panel is the movable area that can then be broken down into the 'component bank', 'building page' and whatever else I'm gonna need.
    This is all just test code to get together for when I make the real program but I need to make sure it'll be possible without a lot of hacking of code.
    Sorry for the length. Thanks for any help you can give.

    The trick to making viewable components that have no behaviour, is to render them onto an image of some sort (eg a BufferedImage). You can then display the Image on a JLabel that can be dragged around the desktop.
    Here is a piece of code that does the component rendering for you. This particular example uses a fixed component size, but you can modify that as you choose of course...public class JComponentImage
         private static GraphicsConfiguration gConfig;
         private static Dimension compSize = new Dimension(80, 22);
         private static Image image = null;
         public static Image getImage(Class objectClass)
              if (gConfig == null)
                   GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
                   GraphicsDevice gDevice = gEnv.getDefaultScreenDevice();
                   gConfig = gDevice.getDefaultConfiguration();
              image = gConfig.createCompatibleImage(compSize.width, compSize.height);
              JComponent jc = (JComponent) ObjectFactory.instantiate(objectClass);
              jc.setSize(compSize);
              Graphics g = image.getGraphics();
              g.setColor(Color.LIGHT_GRAY);
              g.fillRect(0, 0, compSize.width, compSize.height);
              g.setColor(Color.BLACK);
              jc.paint(g);
              return image;
    }And here is the class that makes the dragable JLabel using the class above...public class Dragable extends JLabel
         private static DragSource dragSource = DragSource.getDefaultDragSource();
         private static DragGestureListener dgl = new DragMoveGestureListener();
         private static TransferHandler th = new ObjectTransferHandler();
         private Class compClass;
         private Image image;
         Dragable(Class compClass)
              this.compClass = compClass;
              image = JComponentImage.getImage(compClass);
              setIcon(new ImageIcon(image));
              setTransferHandler(th);
              dragSource.createDefaultDragGestureRecognizer(this,
                                                          DnDConstants.ACTION_COPY,
                                                          dgl);
         public Class getCompClass()
              return compClass;
    }Oh and here is ObjectFactory which simply instantiates Objects of a given class and sets their text to their classname (very crudely)...public class ObjectFactory
         public static Object instantiate(Class objectClass)
              Object o = null;
              try
                   o = objectClass.newInstance();
              catch (Exception e)
                   System.out.println("ObjectFactory#instantiate: " + e);
              String name = objectClass.getName();
              int lastDot = name.lastIndexOf('.');
              name = name.substring(lastDot + 1);
              if (o instanceof JLabel)
                   ((JLabel)o).setText(name);
              if (o instanceof JButton)
                   ((JButton)o).setText(name);
              if (o instanceof JTextComponent)
                   ((JTextComponent)o).setText(name);
              return o;
    }Two more classes required by this codepublic class ObjectTransferHandler extends TransferHandler {
         private static DataFlavor df;
          * Constructor for ObjectTransferHandler.
         public ObjectTransferHandler() {
              super();
              try {
                   df = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
              } catch (ClassNotFoundException e) {
                   Debug.trace(e.toString());
         public Transferable createTransferable(JComponent jC) {
              Transferable t = null;
              try {
                   t = new ObjectTransferable(((Dragable) jC).getCompClass());
              } catch (Exception e) {
                   Debug.trace(e.toString());
              return t;
         public int getSourceActions(JComponent c) {
              return DnDConstants.ACTION_MOVE;
         public boolean canImport(JComponent comp, DataFlavor[] flavors) {
              if (!(comp instanceof Dragable) && flavors[0].equals(df))
                   return true;
              return false;
         public boolean importData(JComponent comp, Transferable t) {
              JComponent c = null;
              try {
                   c = (JComponent) t.getTransferData(df);
              } catch (Exception e) {
                   Debug.trace(e.toString());
              comp.add(c);
              comp.validate();
              return true;
    public class ObjectTransferable implements Transferable {
         private static DataFlavor df = null;
         private Class objectClass;
         ObjectTransferable(Class objectClass) {
              try {
                   df = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
              } catch (ClassNotFoundException e) {
                   System.out.println("ObjectTransferable: " + e);
              this.objectClass = objectClass;
          * @see java.awt.datatransfer.Transferable#getTransferDataFlavors()
         public DataFlavor[] getTransferDataFlavors() {
              return new DataFlavor[] { df };
          * @see java.awt.datatransfer.Transferable#isDataFlavorSupported(DataFlavor)
         public boolean isDataFlavorSupported(DataFlavor testDF) {
              return testDF.equals(df);
          * @see java.awt.datatransfer.Transferable#getTransferData(DataFlavor)
         public Object getTransferData(DataFlavor arg0)
              throws UnsupportedFlavorException, IOException {
              return ObjectFactory.instantiate(objectClass);
    }And of course the test class:public class DragAndDropTest extends JFrame
         JPanel leftPanel = new JPanel();
         JPanel rightPanel = new JPanel();
         Container contentPane = getContentPane();
         Dragable dragableJLabel;
         Dragable dragableJButton;
         Dragable dragableJTextField;
         Dragable dragableJTextArea;
          * Constructor DragAndDropTest.
          * @param title
         public DragAndDropTest(String title)
              super(title);
              dragableJLabel = new Dragable(JLabel.class);
              dragableJButton = new Dragable(JButton.class);
              dragableJTextField = new Dragable(JTextField.class);
              dragableJTextArea = new Dragable(JTextArea.class);
              leftPanel.setBorder(new EtchedBorder());
              BoxLayout boxLay = new BoxLayout(leftPanel, BoxLayout.Y_AXIS);
              leftPanel.setLayout(boxLay);
              leftPanel.add(dragableJLabel);
              leftPanel.add(dragableJButton);
              leftPanel.add(dragableJTextField);
              leftPanel.add(dragableJTextArea);
              rightPanel.setPreferredSize(new Dimension(500,500));
              rightPanel.setBorder(new EtchedBorder());
              rightPanel.setTransferHandler(new ObjectTransferHandler());
              contentPane.setLayout(new BorderLayout());
              contentPane.add(leftPanel, "West");
              contentPane.add(rightPanel, "Center");
         public static void main(String[] args)
              JFrame frame = new DragAndDropTest("Drag and Drop Test");
              frame.pack();
              frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
              frame.setVisible(true);
    }I wrote this code some time ago, so it won't be perfect but hopefully will give you some good ideas.
    Regards,
    Tim

  • I need help with shooting in my flash game for University

    Hi there
    Ive tried to make my tank in my game shoot, all the code that is there works but when i push space to shoot which is my shooting key it does not shoot I really need help with this and I would appriciate anyone that could help
    listed below should be the correct code
    //checking if the space bar is pressed and shooting is allowed
    if(evt.keyCode == 32 && shootAllow){
        //making it so the user can't shoot for a bit
        shootAllow = false;
        //declaring a variable to be a new Bullet
        var newBullet:Bullet = new Bullet();
        //changing the bullet's coordinates
        newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
        newBullet.x = tank_mc.x;
        //then we add the bullet to stage
        addChild(newBullet);
    listed below is my entire code
    import flash.display.MovieClip;
        //declare varibles to create mines
    //how much time before allowed to shoot again
    var cTime:int = 0;
    //the time it has to reach in order to be allowed to shoot (in frames)
    var cLimit:int = 12;
    //whether or not the user is allowed to shoot
    var shootAllow:Boolean = true;
    var minesInGame:uint;
    var mineMaker:Timer;
    var cursor:MovieClip;
    var index:int=0;
    var tankMine_mc:MovieClip;
    var antiTankmine_mc:MovieClip;
    var maxHP:int = 100;
    var currentHP:int = maxHP;
    var percentHP:Number = currentHP / maxHP;
    function initialiseMine():void
        minesInGame = 15;
        //create a timer fires every second
        mineMaker = new Timer(6000, minesInGame);
        //tell timer to listen for Timer event
        mineMaker.addEventListener(TimerEvent.TIMER, createMine);
        //start the timer
        mineMaker.start();
    function createMine(event:TimerEvent):void
    //var tankMine_mc:MovieClip;
    //create a new instance of tankMine
    tankMine_mc = new Mine();
    //set the x and y axis
    tankMine_mc.y = 513;
    tankMine_mc.x = 1080;
    // adds mines to stage
    addChild(tankMine_mc);
    tankMine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
    function moveHorizontal(evt:Event):void{
        evt.target.x -= Math.random()*5;
        if (evt.target.x >= stage.stageWidth)
            evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
            removeChild(DisplayObject(evt.target));
    initialiseMine();
        //declare varibles to create mines
    var atmInGame:uint;
    var atmMaker:Timer;
    function initialiseAtm():void
        atmInGame = 15;
        //create a timer fires every second
        atmMaker = new Timer(8000, minesInGame);
        //tell timer to listen for Timer event
        atmMaker.addEventListener(TimerEvent.TIMER, createAtm);
        //start the timer
        atmMaker.start();
    function createAtm(event:TimerEvent):void
    //var antiTankmine_mc
    //create a new instance of tankMine
    antiTankmine_mc = new Atm();
    //set the x and y axis
    antiTankmine_mc.y = 473;
    antiTankmine_mc.x = 1080;
    // adds mines to stage
    addChild(antiTankmine_mc);
    antiTankmine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
    function moveHorizontal_2(evt:Event):void{
        evt.target.x -= Math.random()*10;
        if (evt.target.x >= stage.stageWidth)
            evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
            removeChild(DisplayObject(evt.target));
    initialiseAtm();
    function moveForward():void{
        bg_mc.x -=10;
    function moveBackward():void{
        bg_mc.x +=10;
    var tank_mc:Tank;
    // create a new Tank and put it into the variable
    // tank_mc
    tank_mc= new Tank;
    // set the location ( x and y) of tank_mc
    tank_mc.x=0;
    tank_mc.y=375;
    // show the tank_mc on the stage.
    addChild(tank_mc);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, onMovementKeys);
    //creates the movement
    function onMovementKeys(evt:KeyboardEvent):void
        //makes the tank move by 10 pixels right
        if (evt.keyCode==Keyboard.D)
        tank_mc.x+=5;
    //makes the tank move by 10 pixels left
    if (evt.keyCode==Keyboard.A)
    tank_mc.x-=5
    //checking if the space bar is pressed and shooting is allowed
    if(evt.keyCode == 32 && shootAllow){
        //making it so the user can't shoot for a bit
        shootAllow = false;
        //declaring a variable to be a new Bullet
        var newBullet:Bullet = new Bullet();
        //changing the bullet's coordinates
        newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
        newBullet.x = tank_mc.x;
        //then we add the bullet to stage
        addChild(newBullet);
    if (tank_mc.hitTestObject(antiTankmine_mc))
            //tank_mc.gotoAndPlay("hit");
            currentHP -= 10;
            // remove anti tank mine
            removeChild(antiTankmine_mc);
    if (tank_mc.hitTestObject(tankMine_mc))
            //tank_mc.gotoAndPlay("hit");
            currentHP -= 10;
            // remove anti tank mine
            removeChild(tankMine_mc);
        //var maxHP:int = 100;
    //var currentHP:int = maxHP;
    //var percentHP:Number = currentHP / maxHP;
        //Incrementing the cTime
    //checking if cTime has reached the limit yet
    if(cTime < cLimit){
        cTime ++;
    } else {
        //if it has, then allow the user to shoot
        shootAllow = true;
        //and reset cTime
        cTime = 0;
    function updateHealthBar():void
        percentHP = currentHP / maxHP;
        healthBar.barColor.scaleX = percentHP;
        if(currentHP <= 0)
            currentHP = 0;
            trace("Game Over");
        updateHealthBar();

    USe the trace function to analyze what happens and what fails to happen in the code you showed.  trace the conditional values to see if they are set up to allow a shot when you press the key

Maybe you are looking for

  • Migrating welogic 6.1 to 8.1 international character display problem

    Hi,           I am migrating application from weblogic 6.1 to weblogic 8.1 sp1 , my problem is character like french, spanish and german are not displaying properly. i have tried following:           1.<%@ page contentType="text/html; charset=UTF8" p

  • IDOC status 62 -  IDOC passed to application

    Hello Experts, Am posting a inbound sales order custom/extended IDOC into the system from WE19, but, when I saw it in WE02/05, its showing status 62 - IDOC passed to application, i checked ST22 run time error. there is no error and also checked trigg

  • Images appear "on load?"

    I want my "thank you" page to open blank, and then have certain elements slowly fade in from 0 to 100%, over a few seconds, w/ no mouse event...I want the page to open looking blank, and then have the elements slowly appear, ideally several elements

  • Adobe premiere elements 12 - starsze wersje pakietu adoba

    NIe wiem czy dobrze się wbiłem z pytaniem, ale tu jest tak zagmatwanie ustawiona pomoc, ze nie nie ogarnąłem. Po instalacji Adobe Premiere Elements 12, działał kilka dni, potem wysyłał błąd 13 i nie chciał się włączać. i musiałem go przeinstalować  p

  • Finding Table relation in SAP

    hi!! I'm new to SAP. I only have SAP tables and i don't have access to the frontend.. I wanna know the tables relation i.e how to join two tables.. Suppose, if i want to know all the relations VNVK has, where should i start? i can only view the prima