Sunday, November 27, 2011

Java search bar - Click event and Enter key event (Netbeans)

Create a search bar in a java application using netbeans, configuring click event listener and ENTER key event listener in the jTextField.







Code for button click event listener and key listener in jTextField:

        jButton1.addActionListener(new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                jLabel1.setText("You searched for: "+jTextField1.getText());
            }
        });
        
        jTextField1.addKeyListener(new KeyAdapter()
        {       
            @Override
            public void keyPressed(KeyEvent e)
            {
                if(e.getKeyCode() == KeyEvent.VK_ENTER)
                    jLabel1.setText("You searched for: "+jTextField1.getText());
            }
        })



Saturday, November 26, 2011

Zymic - Free Web Hosting



Lots of people wounder how they can put thir website online without spending much money or no money at all. There are several way of doing that and Zymic is on of them. Zymic provides a free hosting service with the following caracteristics:

Free Web Hosting - General Features
- Disk Space 5000MB
- Data Transfer (Monthly) 50000MB
- Control Panel ZHCP
- Number Of Accounts Unlimited
- FTP Access Yes
- Advertisements No

Free Web Hosting - PHP And Databases
- PHP Ver 5.2.12
- MySQL Databases 3
- SQLBuddy Ver Custom

Free Web Hosting - Domain Names
- Sub-Domains Yes
- TLD Domain Yes

Free Web Hosting - Zymic Hosting Control Panel (ZHCP) Features
- File Manager Yes
- MySQL Management Yes
- Free Support Yes
- Account Settings Yes

I am using Zymic for a while and i'm really happy with their service.




Thumbs up to TweakUniverse for this video.

Monday, November 21, 2011

Java Core Tutorial for beginners

I found a nice Java core tutorial presentation that talks about the basic of Java to help you get started in Java Programming. So if you are a complete Java beginner this could be your way in.
You can check the tutorial here:






Or you can download it here:
Download Java Tutorial.

So a thumbs up for mister Vijay A Raj that made this tutorial.

Sunday, November 20, 2011

Create an installer to your Java Applications

A comum question that Java beginners ask themselves is "how do i create an installer to share my application?". The answer is easy!


Inserting an image in a Java GUI using NetBeans

This is a quick tip on Java about inserting an image on a JFrame using a JLabel in Netbeans IDE. Since NetBeans don't give a direct way to insert images this is the best way to do it. 
Keep programming and learning!



Monday, November 14, 2011

Order a vector in C

This tutorial presents two ways of order a vector using the programming language C.
We can use the typical way with two for cicles that can become really slow when the vector length is big (like 3555555) or a less commun way but a faster and smaller (in lines of code).

Typical way:

#include <stdio.h>


int main()
{
int v[5] ={2,5,3,2,4};
int v_temp;
int i,j;
for (i=0; i<5; i++)
{
for (j=0; j<5; j++)
{
if(v[i] <= v[j] && i!=j)
{
v_temp=v[j];
v[j]=v[i];
v[i]=v_temp;
}
}
}
for (i=0; i<5; i++)
{
printf("%d -> %d\n",i,v[i]);
}
return 0;
}


Other way:


#include <stdio.h>


int sort(const void *x, const void *y) {
  return (*(int*)x - *(int*)y);
}


int main()
{
int v[5] ={2,5,3,2,4};
int i;
qsort(v, 5, sizeof(int), sort); /*less lines of code and way faster ordering the vector qsort(name_of_vector,length_of_vector,sizeof(type_of_variable),name_of_function) in this case name_of_function is "sort"*/
for (i=0; i<5; i++)
{
printf("%d -> %d\n",i,v[i]);
}
return 0;
}


The result in both methods it's:

0 -> 2
1 -> 2
2 -> 3
3 -> 4
4 -> 5