Wednesday, November 2, 2011
How to Auto Generate Buttons in JAVA
Well this is something amazing You can create any number of Buttons using an Array
This kind of code you will need to use probably if you don't know how many buttons you need in your program. You can create many buttons as you want using lesser lines.
Here goes the codes........... Enjoy
starter_itemCounter =100; // This stores the element number in button array
JButton[] buttonArray = new JButton[starter_itemCounter]; // Create the array
int Bcounter=1; // Used to count button names. we store names for each button in dofferent array
/* Count the 'y position' place of the JButton and JLabel in GUI. This helps the button to fall one after another */
int place=25;
int starterCounter = 1; // Count button array items
while(Bcounter < starter_itemCounter && starterCounter < starter_itemCounter)
{
// Print JButton
/* Create a new button and add button name from button name array */
buttonArray[starterCounter] = new JButton(""+starter_name[Bcounter]);
buttonArray[starterCounter].setBounds(25, place, 300, 25);
panel.add(buttonArray[starterCounter]);
starterCounter++;
Bcounter++;
place += 46;
I used this code to create a hotel menu system which auto generate buttons according to the food names stored in the hotel Data Base. Customer only has to click a button to place an order
An image of the Hotel Menu System's GUI is shown at the top of this post
thank you :)
Friday, August 12, 2011
Create a Simple Calculator using JavaScripts and HTML
Hi readers today I'm going to tell you how to create a simple calculator.
I wrote this code using html, javascript and css. It require only a little knowledge about those languages. So hop you enjoy.
<html>
<!--Jayanga's Blog.................... (http://www.jayangavliyanage.blogspot.com)-->
<head>
<title>
My Simple Calculator
</title>
<script>
function Addition()
{
val =parseInt(form1.value1.value)+parseInt(form1.value2.value);
Display(val);
}
function Subscription()
{
val =parseInt(form1.value1.value)-parseInt(form1.value2.value);
Display(val);
}
function Multiplication()
{
val =parseInt(form1.value1.value)*parseInt(form1.value2.value);
Display(val);
}
function Divition()
{
val =parseInt(form1.value1.value)/parseInt(form1.value2.value);
Display(val);
}
function Display(val)
{
form1.answer.value="";
if(!form1.value1.value =="" && !form1.value2.value=="")
form1.answer.value = String(val);
}
function Empty()
{
if(form1.value1.value =="")
{
defaultVal = prompt("Enter both values","Enter Here");
form1.value1.value = defaultVal;
}
else if(form1.value2.value=="")
{
defaultVal = prompt("Enter both values","Enter Here");
form1.value2.value = defaultVal;
}
form1.value1.value.focus();
form1.value2.value.focus();
}
</script>
</head>
<body>
<form name="form1">
<table align="center" cellspacing="20" border="0" style=" background-color: GreenYellow; border-width: 3px; border-color:#000000;border-style: solid;">
<tr>
<th colspan="4"><u> My Simple Calculator</u></th>
</tr>
<tr >
<td colspan="2">value1:</td>
<td colspan="2">value2:</td>
</tr>
<tr >
<td colspan="2"><input type="textbox" name="value1" style="background-color:
GreenYellow;color:OrangeRed;border:3px double Green;"></td>
<td colspan="2"><input type="textbox" name="value2" style="background-color:
GreenYellow;color:OrangeRed;border:3px double Green;"></td>
</tr>
<tr>
<td><input type="button" value="Add" onclick="Addition()" onBlur="Empty()" style="background-color: OrangeRed;color:GreenYellow;border:3px double Orange;"></td>
<td><input type="button" value="Minus" onclick="Subscription()" onBlur="Empty()" style="background-color: OrangeRed;color:GreenYellow;border:3px double Orange;"></td>
<td><input type="button" value="Multiply" onclick="Multiplication()" onBlur="Empty()" style="background-color: OrangeRed;color:GreenYellow;border:3px double Orange;"></td>
<td><input type="button" value="Divide" onclick="Divition()" onBlur="Empty()" style="background-color: OrangeRed;color:GreenYellow;border:3px double Orange;"></td>
</tr>
<tr >
<td colspan="3">Answer:<input type="textbox" name="answer" style="background-color: GreenYellow;color:OrangeRed;border:3px double Green;"></td>
<td><input type="button" value="Reset" onclick="Reset()" onBlur="Empty()" style="background-color: OrangeRed;color:GreenYellow;border:3px double Orange;"></td>
</tr>
</table>
</form>
</body>
</html>
At the end if you code correctly you will get the above interface on your browser.
If you have any problem just leave a comment
If you have any problem just leave a comment
Good Luck
Monday, August 8, 2011
How to Get User Given String to an Array in "C" Language
#include <stdio.h>
int main()
{
char YourText[20];//save the user's string
fputs("Enter your text: ", stdout);
fflush(stdout);
fgets(YourText, sizeof YourText, stdin);
int i;
for(i=0; YourText[i] !='\0'; i++)
printf("%c",YourText[i]);
}//End main
/*
jayangaVliyanage
Jayanga's Blog.........................(http://jayangaliyanage.blogspot.com/)
*/
How to Access Blocked Sites with UltraSurf
Hi guys today I'm writing about a cool software. We all hate to be blocked our urls. But some servers do not grant access for cool sites like
Don't be upset here's something for u.........
"UltraSurf" helps to bypass DNS server blocking. So if your server block your 'url's just use this and have fun.
In some situations it will seems as illegal for some party. So
Please don't use this for any kind of violation.
If you don't have UltraSurf download it from here
here are the steps after that
- Extract the downloaded zip file
- Double click and run UltraSurf
Software interface is like this
- Go to "options" and click proxy settings.
- There enter your enter your HTTP proxy and port in Manual Proxy Settings. Press ok
Now you are ready to go
- Go to home tab and surf through web with no blocking.
Subscribe to:
Posts (Atom)