Animating A Car In Java

This program is only for beginners in Java. Most of you may have imagined it is very difficult of it takes a lot of time to grasp the essence of animation in Java. Well this program here dispels all those fears. It is a very basic (and dare I say an ugly) animation of a red car which moves from left to right.

COPY CODE BELOW START

// CARMOVE.JAVA// MOVING CAR
// Created by Karthik Sampath on 28/4/2010.
// Copyright 2010, Karthik. All rights reserved.
// The copyright to the computer program(s) herein
// is the property of Karthik Sampath, India. The
// program(s) may be used and/or copied only with the
// written permission of Karthik Sampath or in accordance
// with the terms and conditions stipulated in the
// agreement/contract under which the program(s) have
// been supplied. This copyright notice must not be
// removed.

// Published in www.MyTricksTime.com
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.*;
public class test extends JApplet {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.getContentPane().add(new test());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1024, 739);
frame.setVisible(true);
}
public void paint(Graphics g) {
try {
int j = 0;
while (j < 500) {
g.setColor(Color.white);
g.fillRect(0, 0, 5000, 5000);
g.setColor(Color.red);
g.fillRect(250 + j, 250, 100, 50);
g.setColor(Color.black);
g.fillOval(260 + j, 300, 20, 20);
g.fillOval(320 + j, 300, 20, 20);
j++;
Thread.sleep(2);
}
} catch (InterruptedException e) {
}
}
}

END

COPY CODE END 
Enjoy Guys! and don’t forget to post your comments. � MyTricksTime.com

How to select all friends at once to invite friends on Facebook


Facebook invites are useful to invite your friends to view your website or to like your new Facebook page, you will see friends invite almost everywhere in Facebook.  Facebook invites are useful but a sometimes a hard job if you have large number of friends like me,
 i have 2525 friends on Facebook and thus it was very

difficult for me to invite friends one by one.When i started learning JavaScript, i came to know that we can easily select all check boxes by making a small JavaScript command line. 

But before we start, make sure you are using Google Chrome or Firefox, they are good and major browsers, so using them makes sure that it will not create any problems. I will explain it in step by step procedures.

  1. Open Google Chrome 
  2. Now open any event etc. where you can invite your friends
  3. Now scroll down until all your friends appears in the box
  4. Press CTRL+SHIFT+J (for Chrome), CTRL+SHIFT+K (for FireFox) 
  5. A window will open in bottom or top of the browser
  6. Paste this line of JavaScript code in the console
    javascript:elms=document.getElementsByName(“checkableitems[]”);for (i=0;i<elms.length;i++){if (elms[i].type=”checkbox” )elms[i].click()};


    After pasting click enter, now wait for a minute and and when all friends are selected click on send, if you have large number of friends it may take about 1 – 2 minutes for successfully sending the invites . 


    Enjoy Guys! and don’t forget to post your comments. � MyTricksTime.com

    Best CSS3 Web button With Pseudo Classes

    Pseudo classes are bolted on to selectors to specify a state or relation to the selector. They take the form of selector:pseudo class { property: value; }, simply with a colon in between the selector and the pseudo class.


    Many CSS proposals are not supported by all browsers, but there are four pseudo classes that can be used safely when applied to links.

                                                                           DEMO 
    • Link – This is the for the default link.
    • Visited – This Is the state you give to links which have already been visited.
    • Hover – This is the state when the mouse is over the link.
    • Active – This is the state you give when the visitor clicks on the link
     Image shows three different styles for link, hover and active.
    The HTML for this button is simple, it’s just a link anchor tag with a class.

    <a href=”#” class=”web_button”>CSS Button</a>

    # Button Link State
    This is the default setting for the button, for this we are going to use gradient colours, box shadow and border-radius.

    .web_button{
    background: #0.4; /* Old browsers */
    background: -moz-linear-gradient(top, #b4df5b 0%, #b4df5b 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b4df5b), color-stop(100%,#b4df5b)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #b4df5b 0%,#b4df5b 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #b4df5b 0%,#b4df5b 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #b4df5b 0%,#b4df5b 100%); /* IE10+ */
    background: linear-gradient(top, #b4df5b 0%,#b4df5b 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b4df5b', endColorstr='#b4df5b',GradientType=0 ); /* IE6-9 */
    width:125px;
    padding:20px;
    display:inline-block;
    color:#fff;
    text-decoration:none;
    font-weight:bold;
    text-align: center;
    border:1px solid #8dc025;
    border-radius: 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    -o-border-radius: 5px;
    -webkit-box-shadow: 0px 2px 3px 2px rgba(50, 50, 50, 0.4);
    -moz-box-shadow: 0px 2px 3px 2px rgba(50, 50, 50, 0.4);
    box-shadow: 0px 2px 3px 2px rgba(50, 50, 50, 0.4);
    }


    # Button Hover State 
    On the hover of the button we are going to change the background colour of the button.

    .web_button:hover{
    text-decoration:none;
    background: #8dc025; /* Old browsers */
    background: -moz-linear-gradient(top, #8dc025 0%, #8dc025 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#8dc025), color-stop(100%,#8dc025)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #8dc025 0%,#8dc025 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #8dc025 0%,#8dc025 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #8dc025 0%,#8dc025 100%); /* IE10+ */
    background: linear-gradient(top, #8dc025 0%,#8dc025 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8dc025', endColorstr='#8dc025',GradientType=0 ); /* IE6-9 */
    }


    # Button Active State 
    For the active state we are changing the box shadow to be inverted by using the inset on the box-shadow property. 

    .web_button:active{
    -webkit-box-shadow: inset 0px 1px 3px 2px rgba(0, 0, 0, 0.4);
    -moz-box-shadow: inset 0px 1px 3px 2px rgba(0, 0, 0, 0.4);
    box-shadow: inset 0px 1px 3px 2px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    }


    Original Article >>

    Enjoy Guys! and don’t forget to post your comments. � MyTricksTime.com

    How To Add a Sitemap to Your Blog


    A Sitemap is a beautiful and special effect for the blog. It is a   easy way for navigating the labels of your blog with a “New” feature. It shows the new posts and shows the “New” at the end of the post. 

    Now your are going to see how to create a beautiful Sitemap in an easy way using JavaScript

    1. How to add a Sitemap to the blog?
    2. Go to Dashboard
    3. Click on Pages>>Create a New page.
    4. Name it or may not also.
    5. Copy the code shown below.
    6. </script><script src=”/feeds/posts/summary?alt=json-in-script&amp; max-results=500&amp;callback=loadtoc” type=”text/javascript”></script>
    7. Click on Html section of the page and paste the code in it.
    8. Preview the page and then save the page.

    U R Done…!!!


    Note:U can change the no. of the results in the script.

    Enjoy Guys! and don’t forget to post your comments. � MyTricksTime.com

    Simplest JavaScript to Open Popup Window from Plain Text

    You can use JavaScript to create popup windows. Popup Windows are different to simply opening a new browser window.

    However you can do the same (creating pop windows) using buttons. I�ve already described that here.

    Here is the simplest JavaScript for generating a pop up window:

    // Popup window code
    function newPopup(url) {
    popupWindow = window.open(
    url,'popUpWindow','height=500,width=500,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,
    location=no,directories=no,status=yes')
    }

    <a href="JavaScript:newPopup('http://www.google.com');">Open a popup window

    This will result in:

    // Popup window code
    function newPopup(url) {
    popupWindow = window.open( url,'popUpWindow','height=300,width=500,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
    }

    Where:
    – Red are width and height of the popup window.
    – Purple are the optional attributes (change to �no� to turn off those attributes).
    – Blue is the actual link to be opened in the popup.
    – Black (bold) is the text which is visible to user.

    Automatically center your popup

    Similarly if you want to automatically position your window in the center of the users� screen use the following code. The JavaScript code will detect the screen size (as each user could have a different screen size), then position the popup window in the center.

    var popupWindow = null;
    function centeredPopup(url,winName,w,h,scroll){
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings =
    'height=' h ',width=' w ',top=' TopPosition ',left=' LeftPosition ',scrollbars=' scroll ',resizable'
    popupWindow = window.open(url,winName,settings)
    }

    <a href="http://www.google.com" onclick="centeredPopup(this.href,'myWindow','500','300','yes');return false">Centered Popup

    This result in:

    var popupWindow = null;
    function centeredPopup(url,winName,w,h,scroll){
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings =
    'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
    popupWindow = window.open(url,winName,settings)
    }

    Centered Popup

    Where:
    – Red are width and height of the popup window respectively.
    – Purple is the attribute for the scrollbars in the popup. (Change to �no� to disable scrollbars)
    – Blue is the actual link to be opened in the popup.
    – Black (bold) is the text which is visible to user.

    Enjoy Guys! and don’t forget to post your comments. � MyTricksTime.com