Skip to content

Commit

Permalink
File updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
urvesh254 committed Dec 13, 2020
1 parent 94594fa commit 7e77d56
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
assets/
*.class
*.jar
31 changes: 1 addition & 30 deletions BSTVisualization.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import java.awt.*;
import java.awt.event.*;

public class BSTVisualization extends JFrame implements ActionListener, KeyListener, Runnable {
public class BSTVisualization extends JFrame implements ActionListener, KeyListener{
// Tree Root Node.
private Node root;

private Node tempColor;
private Color color;
private Thread t;
private JButton btnAdd, btnDelete;
private JTextField tf;
private int X = 300, Y = 75;
Expand Down Expand Up @@ -38,10 +37,6 @@ private static class Node {
void setPoints(int x1, int y1, int x2, int y2) {
p = new Points(x1, y1, x2, y2);
}

void setColor(Color c){
data.setBackground(c);
}
}

//Points structure
Expand Down Expand Up @@ -199,16 +194,6 @@ public void actionPerformed(ActionEvent evt) {
}
}

@Override
public void run(){
tempColor.setColor(color);
try{
Thread.sleep(500);
}catch(Exception e){}
tempColor.setColor(Color.green);
tf.setEnabled(true);
}

@Override
public void keyTyped(KeyEvent evt) {
char c = evt.getKeyChar();
Expand Down Expand Up @@ -253,18 +238,6 @@ public void keyPressed(KeyEvent evt) {
public void keyReleased(KeyEvent evt) {
}

private void changeColor(Node newNode,Color color){
tempColor=newNode;
this.color=color;
try{
tf.setEnabled(false);
t = new Thread(this,"Color Change");
t.start();
}catch(Exception ex){
JOptionPane.showMessageDialog(null,"Error in Thread.");
}
}

//Add element in BST.
public void add(int info) {
Node newNode = new Node(info);
Expand Down Expand Up @@ -306,8 +279,6 @@ public void add(int info) {
}
}

changeColor(newNode,new Color(138,41,190));

// Set all traversal and height of BST
setInfo();

Expand Down

0 comments on commit 7e77d56

Please sign in to comment.