--start--
Sample code:
int i = textfield.getText().length();
textfield.setSelectionStart(0);
textfield.setSelectionEnd(i);
Put this in the action or wherever you want it. Replace textfield variable to the name of your textfield. I'm not sure but this might work for JTextArea and JTextPane too.
--end---
Thursday, July 15, 2010
Tuesday, June 15, 2010
How to redirect Back to previous page PHP
Put this in your code:
that is a javascript code.
As for me, I embedded it to my php file like this:
Note: I cannot add the script as it is because blogspot reads the script and the effect is redirecting you to your previous page. As an alternative I put it as image :)
Hope this helps. It worked 100% for me :)
that is a javascript code.
As for me, I embedded it to my php file like this:
if(!checkEverything()){ // a function that contains checking of fields.
SCRIPT HERE* //redirects Back to the previous page with values still in the form
}else{
displayAll(); // a function that displays all
}
Note: I cannot add the script as it is because blogspot reads the script and the effect is redirecting you to your previous page. As an alternative I put it as image :)
Hope this helps. It worked 100% for me :)
Friday, May 14, 2010
How to remove JTextArea line around rectangle (border)
code:
In NetBeans:
1. Click the text area
2. Go to Properties
3. Scroll to Other Properties
4. Go to border then select (No Border)
5. Put this in your constructor:
textarea.setBorder(null);
In NetBeans:
1. Click the text area
2. Go to Properties
3. Scroll to Other Properties
4. Go to border then select (No Border)
5. Put this in your constructor:
jScrollPane1.setBorder(null);
This is because NetBeans automatically creates scrollpane to your text area and its border is visible until you set it to null.
6. Run the file to see the result.
It worked for me just fine :)
Thursday, May 13, 2010
How to resize ImageIcon - Java
Please make reading a habit :)
This was my problem before. After days of searching, I combined the codes of my search items and came up with this:
-- start of function. I put it inside a function --
//gets the directory of the file
//this means that the file name is where the directory is plus the folder pictures plus the filename
//which is hold by the string named idnumber
idnumber = "CO00001";
dir_pic = System.getProperty("user.dir");
dir_pic = dir_pic+"\\Pictures\\"+idnumber+".jpg";
//you could simply put the path of the image in dir_pic variable
//We should have an image first.
//For me, I open the image from my directory
File file = new File(dir_pic);
image = ImageIO.read(file); //reads the image
//this sets the image to an Image Icon
ImageIcon icon = new ImageIcon(image);
ImageIcon icon = new ImageIcon(image);
//we start to scale here
//first get the image from ImageIcon
Image img = icon.getImage();
Image img = icon.getImage();
//then scale it; I scaled it to 120x120
//please check the documentation for parameter listing if u dont want SCALE_SMOOTH
Image newimg = img.getScaledInstance(120, 120,java.awt.Image.SCALE_SMOOTH);
newIcon = new ImageIcon(newimg); //we now have new icon - scaled by 120x120
//I made a JLabel named label and put the image there
label = new JLabel(new ImageIcon(newimg));
//then put the label to a square panel
picpanel.add(label);
label.setBounds(2, 2, 115, 105); //change the bounds according to your design
--- end of function ---
For questions, post a comment to this post... :)
Wednesday, March 24, 2010
Top Most Annoyance in Techie World
---
1. Most Annoying text editor - Microsoft Word 2007
Because it doesn't go with the proper numbering as i want it to! the previous version is better.
i put 1 then press tab space, it always changes into 4!!! darn!
2. Most Annoying Instant Messenger - Yahoo Messenger 9.0
3. Most Annoying eMail when it comes to attaching messages - Yahoo Mail
4. Most Annoying Cell phone - E touch
NEVER BUY ETOUCH PHONE. YOU'LL JUST GET STRESSED. (Image from http://images02.olx.com.ph/ui/2/31/60/39063160_1.jpg)
----
..And guess what, I have these all.. zzz...
----
..And guess what, I have these all.. zzz...
Friday, March 19, 2010
Joomla! BUGS! ERRORS!
It's so hard to install Joomla! I get so many errorsssss! It's pissing me off! At first I had "Error 1045" in my installation. Then I edited the sql code, changed all "TYPE = MyISAM" to ENGINE = MyISAM. After that I was able to install but when I went to the administrator area all I see is a blank page!
If it's this hard to user this CMS, someone kill Joomla community please!!!!
UPDATE:
I already know the bug. Joomla's database server has a conflict to my installed MySQL server. I now appreciate Joomla after really getting to know it. But the installation is really hard.
If it's this hard to user this CMS, someone kill Joomla community please!!!!
UPDATE:
I already know the bug. Joomla's database server has a conflict to my installed MySQL server. I now appreciate Joomla after really getting to know it. But the installation is really hard.
XAMPP phpMyAdmin Error 1045 Access denied for user
Description of error: This appears when you click the phpMyAdmin link from xampp home page. The error looks like this:
The using password: NO means that xampp configuration has no password to database server stored in it. The error could also be: Access denied for user 'root'@'localhost' (using password: YES). This error means xampp has a password for the database server but it is incorrect.
Solution:
1. Go to C:\xampp\phpmyadmin then open the config.inc or config.inc.php file
2. In line 20 you will see this: $cfg['Servers'][$i]['user'] = 'root';
Make sure that the 'root' there is the user to access your own database server. If not, change the 'root' to your own user name.
3. In line 21 you will see this: $cfg['Servers'][$i]['password'] = '';
This means that your database server doesn't have password save in it. If your database server has a password, type the password between the single quotes for example 'mysql'.
However, if there is a password stored like this: $cfg['Servers'][$i]['password'] = 'mysql'; then you have to change 'mysql' into the password your database server is using for example 'developer_password'
4. Clear your cookies then reload localhost
Hope this helps, I tried it and it worked.
The using password: NO means that xampp configuration has no password to database server stored in it. The error could also be: Access denied for user 'root'@'localhost' (using password: YES). This error means xampp has a password for the database server but it is incorrect.Solution:
1. Go to C:\xampp\phpmyadmin then open the config.inc or config.inc.php file
2. In line 20 you will see this: $cfg['Servers'][$i]['user'] = 'root';
Make sure that the 'root' there is the user to access your own database server. If not, change the 'root' to your own user name.
3. In line 21 you will see this: $cfg['Servers'][$i]['password'] = '';
This means that your database server doesn't have password save in it. If your database server has a password, type the password between the single quotes for example 'mysql'.
However, if there is a password stored like this: $cfg['Servers'][$i]['password'] = 'mysql'; then you have to change 'mysql' into the password your database server is using for example 'developer_password'
4. Clear your cookies then reload localhost
Hope this helps, I tried it and it worked.



