Showing posts with label swings. Show all posts
Showing posts with label swings. Show all posts

Thursday, 3 January 2013

Zig Zag motion

On clicking the start button
Changed the ball's color to hgb

Using stop button






Using java swings ,I tried to make the zig zag motion  of a ball when it strikes the boundaries of the rectangle on clicking the "start" button It has a "stop" button and another button to change the ball's color to HGB.
The code is quite simple .First of all create a frame using JFrame as follow
JFrame a = new JFrame("Zig Zag");
After declaring its attributes ,create a class  say zigzag which inherits JPanel and another class say bounce which inherits JPanel and an interface ActionListener.Now declare an object of class bounce say bounce b;
After that declare the constructor zigzag() as follow
Before clicking the start button
b = new bounce();
JButton startButton = new JButton("Start");
JButton hgbButton = new JButton("Change color to HGB");
JButton stopButton = new JButton("Stop");
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
buttonPanel.add(startButton);
buttonPanel.add(hgbButton);
buttonPanel.add(stopButton);
 stopButton.setText("Stop now !");
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.add(buttonPanel);

this.add(b);
Now,for the start button set animation to true and for stop button set animation to false .To change the color to hgb use :
b.setBallColor(Color.getHSBColor(TOP_ALIGNMENT, TOP_ALIGNMENT, TOP_ALIGNMENT));
 Now,inside the class bounce define the radius,diameter ,velocity across Xaxis and Yaxis , paint()..

Monday, 10 December 2012

Calculator





Tried to make a calculator using swings  that performs addition,subtraction,multiplication.division,exits and clear the data depending on the user requirements.It also includes a JButton  Help me ! to obtain further information about the application and JButton about to get information about the developer.Futher in case of indeterminate expression an exception is thrown and a pop up window appears .The JButton clear resets the data and set the variables to false .


Simple ChatBot using C++

I tried to make a chat with a bot ..after being inspired by a samsung app -Palingo .
This is a C++ prohram which is  konsole based.
It takes an input from user and the response is random .It includes header files like iostream,cstdlib,string and ctime .
I made a string -response having the script .And an infinte while loop to proceed the script .
It is a simple c++ program ,more improved version will be provided soon ..........
Mail me to obtain its source code and if interested to make chatbot using swings .