<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andr&#233; L. S. &#187; Quick tips</title>
	<atom:link href="http://www.andrels.com/wp-en_US/index.php/category/quick-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andrels.com/wp-en_US</link>
	<description>Softwares Development, Technology and Games</description>
	<lastBuildDate>Wed, 08 Feb 2012 12:39:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A easy way to compile many objects in Oracle database</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2012/01/a-easy-way-to-compile-many-objects-in-oracle-database/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2012/01/a-easy-way-to-compile-many-objects-in-oracle-database/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 22:42:47 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[PLSql]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=233</guid>
		<description><![CDATA[When compiles an object that is referenced by many others, they stay invalidated until Oracle compile they again and sometimes<a href="http://www.andrels.com/wp-en_US/index.php/2012/01/a-easy-way-to-compile-many-objects-in-oracle-database/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>When compiles an object that is referenced by many others, they stay invalidated until Oracle compile they again and sometimes it fails.</p>
<p>So, here&#8217;s a tip to compile several invalid packages, procedures and/or functions and fix this.</p>
<p>There is a command to compile all invalid objects under an user, the command is:</p>
<p>&lt;pre class=&#8221;brush:sql&#8221;&gt;exec dbms_ultility.compile_schema(&amp;lt;USER&amp;gt;);&lt;/pre&gt;</p>
<p>Replace  &amp;lt;USER&amp;gt; for &lt;i&gt;user&lt;/i&gt;, or for user name where invalid objects are.</p>
<p>This command is slow and not compiles objects invalidated by coding error. To find which are invalid you need runs the query below:</p>
<p>&lt;pre class=&#8221;brush:sql&#8221;&gt;<br />
select object_name<br />
from all_objects<br />
where status = &#8216;INVALID&#8217;<br />
&lt;/pre&gt;</p>
<p>Invalid objects will be listed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2012/01/a-easy-way-to-compile-many-objects-in-oracle-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why to use File.separator and File.pathSeparator</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/08/why-to-use-file-separator-and-file-pathseparator/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/08/why-to-use-file-separator-and-file-pathseparator/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 16:17:49 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[programing]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=190</guid>
		<description><![CDATA[Java programmers knows about methods quoted in title, but many doesn&#8217;t care with them. These methods are useful for programmer<a href="http://www.andrels.com/wp-en_US/index.php/2011/08/why-to-use-file-separator-and-file-pathseparator/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Java programmers knows about methods quoted in title, but many doesn&#8217;t care with them.</p>
<p>These methods are useful for programmer that do not knows wich characters represents file separator and path separator at OS that supports your application.</p>
<p>Linux/Unix, the methods <b><a href="http://download.oracle.com/javase/1,5.0/docs/api/java/io/File.html#separator">File.separator</a></b> and <b><a href="http://download.oracle.com/javase/1,5.0/docs/api/java/io/File.html#pathSeparator">File.pathSeparator</a></b> returns &#8220;/&#8221; and &#8220;.&#8221;, while in Windows, these methods returns &#8220;\&#8221; (or &#8220;\\&#8221; &#8211; escape) and &#8220;;&#8221;.</p>
<p>In recent case, the code below threw exception FileNotFoundException running over Linux, but not running over Windows:</p>
<pre class="brush:java">
String appPath = ctx.getRealPath();
String filePath = appPath + "\\" + "WEB-INF/classes/my/application/packages/";

File file = new File(filePath, "report.pdf");
OutputStream out = new FileOutputStream(file);
...
</pre>
<p>Worked in both systems after to replace &#8220;\\&#8221; by File.separator in line 2:</p>
<pre class="brush:java">
String appPath = ctx.getRealPath();
String filePath = appPath + File.separator + "WEB-INF/classes/my/application/packages/";

File file = new File(filePath, "report.pdf");
OutputStream out = new FileOutputStream(file);
...
</pre>
<p>Utilization of these methods, besides a good practice, is very usefull when same version of an application is running over differents operacional systems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/08/why-to-use-file-separator-and-file-pathseparator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing WordPress error &#8220;Allowed memory size of&#8230;&#8221;</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/07/fixing-wordpress-error-allowed-memory-size-of/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/07/fixing-wordpress-error-allowed-memory-size-of/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 02:06:11 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Softwares]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fatal]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=174</guid>
		<description><![CDATA[I&#8217;ve just updated my WordPress to version 3.2, when update has been finished a page with error code 500 was<a href="http://www.andrels.com/wp-en_US/index.php/2011/07/fixing-wordpress-error-allowed-memory-size-of/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just updated my WordPress to version 3.2, when update has been finished a page with error code 500 was displayed. In log file had many entry of <strong>Fatal error: Allowed memory size of 33554432 bytes exhausted</strong></p>
<p>To know if it your problem too, edit file <strong>error_log</strong> in <strong>wp-admin</strong> directory and and take a look at last rows.</p>
<p>The following process fixed this for me, but your host server should allow sizing PHP memory at runtime.</p>
<p>Open and edit file <strong>wp-settings.php</strong> at root of WordPress directory and put the row bellow after &#8220;&lt;?php&#8221;:</p>
<pre class="brush:php">define('WP_MEMORY_LIMIT', '64M');</pre>
<p>Here I&#8217;ve set up to 64MB to PHP, but how to know amount of MB to set up?</p>
<p>In error message, the long number means amount of bytes allocated to PHP: &#8220;Fatal error: Allowed memory size of <span style="text-decoration: underline;">33554432</span>&#8230;&#8221;. This number represents 32MB (do this calculation to converts byte in megabytes 33554432 / (1024^2) = 32).</p>
<p>Just set a number greater than the result in line above.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/07/fixing-wordpress-error-allowed-memory-size-of/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing .apk packages at Android SDK emulator</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2011/02/installing-apk-packages-at-android-sdk-emulator/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2011/02/installing-apk-packages-at-android-sdk-emulator/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 23:40:10 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[apk]]></category>
		<category><![CDATA[emulator]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=162</guid>
		<description><![CDATA[Sometimes our applications depends of third-part applications for tests or to access resources of emulator that aren&#8217;t available by default.<a href="http://www.andrels.com/wp-en_US/index.php/2011/02/installing-apk-packages-at-android-sdk-emulator/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Sometimes our applications depends of third-part applications for tests or to access resources of emulator that aren&#8217;t available by default.</p>
<p>In directories of SDK, commonly in<em> platform-tools</em>, there is an executable called <strong>adb</strong>, with it we&#8217;ll to install third-part applications.</p>
<p>You will need an application (.apk). Browse internet or copy from your Android smartphone using applications like <a href="https://market.android.com/details?id=com.IQBS.android.appSaver&amp;feature=search_result">AppSaver</a>.</p>
<p>- Run the emulator, you can use SDK Manager or Eclipse plugins.</p>
<p>- Using DOS Command (Windows) or terminal (Linux), open directory <em>platform-tools</em> and run commando line below:</p>
<pre class="brush: bash">$ adb install &lt;.apk path&gt;</pre>
<p>This message will be displayed</p>
<pre class="brush: bash">$ adb install Application.apk
125 KB/s (1091937 bytes in 8.474s)
        pkg: /data/local/tmp/Application.apk
Success</pre>
<p>Now, the third-part application is available at emulator menu, like have installed in your smartphone.</p>
<p>Agora o aplicativo estará disponível no menu do emulador. <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2011/02/installing-apk-packages-at-android-sdk-emulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up internet access through proxy server</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2010/03/setting-up-internet-access-through-proxy-server/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2010/03/setting-up-internet-access-through-proxy-server/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 01:54:22 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=116</guid>
		<description><![CDATA[Today I had a trouble in my workplace when a client application, running through a terminal (DOS prompt), not reach<a href="http://www.andrels.com/wp-en_US/index.php/2010/03/setting-up-internet-access-through-proxy-server/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Today I had a trouble in my workplace when a client application, running through a terminal (DOS prompt), not reach the server hosted in the internet, this is because the company where I work use proxy.</p>
<p>After some tries I found two solutions to solve my access problem: first was pass as <em>Java</em> parameters the proxy&#8217;s configurations.</p>
<pre class="brush:shell">$ java -Dhttp.proxyHost=serv -Dhttp.proxyPort=port -Dhttp.proxyUser=user -Dhttp.proxyPassword=pass  ClassJava
</pre>
<p><strong>-Dhttp.proxyHost</strong> = IP or host name of server proxy<br />
<strong>-Dhttp.proxyPort</strong> = Proxy port<br />
<strong>-Dhttp.proxyUser</strong> = User<br />
<strong>-Dhttp.proxyPassword</strong> = Password</p>
<p>This way the class <em>ClassJava</em> will have access to internet through proxy server.</p>
<p>Another way, was insert the settings in own class:</p>
<pre class="brush:java">public static void main(String[] args){
...
System.getProperties().put("proxySet", "true");
System.getProperties().put("http.proxyHost", "serv");
System.getProperties().put("http.proxyPort", "port");
System.getProperties().put("http.proxyUser", "user");
System.getProperties().put("http.proxyPassword", "password");
...
}
</pre>
<p><strong>proxySet</strong> = Connect, or not, through proxy server<br />
<strong>http.proxyHost</strong> = IP or host name of server proxy<br />
<strong>http.proxyPortt</strong> = Proxy port<br />
<strong>http.proxyUse</strong> = User<br />
<strong>http.proxyPassword</strong> = Password</p>
<p>Using this resource you can set your application to access the internet through proxy server.</p>
<p>I hope help you.  Bye! <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2010/03/setting-up-internet-access-through-proxy-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amarok&#8217;s playlist stop after play one music</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2010/03/amaroks-playlist-stop-after-play-one-musica/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2010/03/amaroks-playlist-stop-after-play-one-musica/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 02:42:58 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Softwares]]></category>
		<category><![CDATA[amarok]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[playlist]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=112</guid>
		<description><![CDATA[Recently I had a problem like others Amarok&#8217;s 2.1.1 users: It play only one music and stop. To resolve this:<a href="http://www.andrels.com/wp-en_US/index.php/2010/03/amaroks-playlist-stop-after-play-one-musica/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Recently I had a problem like others Amarok&#8217;s 2.1.1 users: It play only one music and stop.</p>
<p>To resolve this: Close Amarok, delete the file<strong> ~/.kde/share/apps/amarok/current.xspf</strong> and then restart Amarok.</p>
<p>Least worked to me and I hope that works for you too! <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Until next!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2010/03/amaroks-playlist-stop-after-play-one-musica/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving files in BLOB table column of a data base</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2010/02/saving-files-in-blob-table-column-of-a-data-base/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2010/02/saving-files-in-blob-table-column-of-a-data-base/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 00:46:06 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=102</guid>
		<description><![CDATA[To insert a file, is it in any format, you need call the method setBinaryStream, implemented by PreparedStatement. PreparedStatemente.setBinaryStream(int index,<a href="http://www.andrels.com/wp-en_US/index.php/2010/02/saving-files-in-blob-table-column-of-a-data-base/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>To insert a file, is it in any format, you need call the method <i>setBinaryStream</i>, implemented by PreparedStatement.</p>
<pre class="brush:java">
PreparedStatemente.setBinaryStream(int index, Inputstream is, int length);
</pre>
<p>In sample, we set a table called <i>FILE</i>that contains <b>BLOB</b> column called <i>BIN</i>.</p>
<pre class="brush:java">
//Normal connection, as any JDBC connection
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@&lt;IP&gt;:&lt;PORT&gt;:&lt;SID&gt;","&lt;USER&gt;","&lt;PASSWORD&gt;");

//Reading the file and retrieving an InputStream
File file= new File("&lt;COMPLETE_FILE_PATH&gt;");
FileInputStream fis = new FileInputStream(file);

//Preparing statement
PreparedStatement ps = conn.prepareStatement("INSERT INTO FILE(bin) VALUES(?)");

//Passing InputStream and file length
ps.setBinaryStream(1, fis, (int)file.length());

ps.execute();

ps.close();
conn.close();
</pre>
<p>I used Oracle 8i to execute this sample. I haven&#8217;t a MySQL/PostgreSQL/MS SQL Server in my dispose, then you&#8217;ll responsible for testing in this data bases and send me the results, OK <img src='http://www.andrels.com/wp-en_US/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Thanks! Until next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2010/02/saving-files-in-blob-table-column-of-a-data-base/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to enable Telnet and TFTP Client on Windows 7</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/12/how-to-enable-telnet-and-tftp-client-on-windows-7/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/12/how-to-enable-telnet-and-tftp-client-on-windows-7/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 13:30:38 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Configurations]]></category>
		<category><![CDATA[Operational Systems]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[telnet]]></category>
		<category><![CDATA[tftp]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=96</guid>
		<description><![CDATA[Like in Windows Vista, Windows 7 don&#8217;t enable Telnet and TFTP Clients in installation. To enable them, open Control Panel<a href="http://www.andrels.com/wp-en_US/index.php/2009/12/how-to-enable-telnet-and-tftp-client-on-windows-7/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Like in Windows Vista, Windows 7 don&#8217;t enable Telnet and TFTP Clients in installation.</p>
<p>To enable them, open Control Panel &gt; Programs and Features &gt; click Turn Windows features on or off in left side &gt; enable Client Telnet  and  Client TFTP then click in OK.</p>
<p>I not tested in Windows Vista yet, but the process can be same.</p>
<p>See you soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/12/how-to-enable-telnet-and-tftp-client-on-windows-7/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The most used Unix commands for Windows</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/11/the-most-used-unix-commands-for-windows/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/11/the-most-used-unix-commands-for-windows/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 21:29:55 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Operational Systems]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=92</guid>
		<description><![CDATA[Have you thought about run commands like grep, chown, tail e su in Windows SO and can change command dir<a href="http://www.andrels.com/wp-en_US/index.php/2009/11/the-most-used-unix-commands-for-windows/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>Have you thought about run commands like <em>grep</em>, <em>chown</em>, <em>tail</em> e <em>su</em> in Windows SO and can change command <em>dir</em> by <em>ls</em>?</p>
<p>Looking in internet for an alternative <em>Win32</em> to command <em>tail</em>, I found UnixUtils. A compilation for Windows of most used commands in Linux/Unix.</p>
<p>You can download the ZIP file in SourceForge clicking <a title="UnixUtils" href="http://sourceforge.net/projects/unxutils/" target="_blank">here</a>.</p>
<p>Bye!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/11/the-most-used-unix-commands-for-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting maximum number of characters in JTextField</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/09/setting-maximum-number-of-characters-in-jtextfield/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/09/setting-maximum-number-of-characters-in-jtextfield/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 16:07:48 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[jtextfield]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=73</guid>
		<description><![CDATA[The default implementation of JTextField not allow set maximum number of characters. To enable this resource you need implements a<a href="http://www.andrels.com/wp-en_US/index.php/2009/09/setting-maximum-number-of-characters-in-jtextfield/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>The default implementation of <i>JTextField</i> not allow set maximum number of characters. To enable this resource you need implements a <i>Document</i>, overriding <i>insertString</i> method.</p>
<pre class="brush:java">
public class MaxLengthTextDocument extends PlainDocument {
	//Store maximum characters permitted
	private int maxChars;

	@Override
	public void insertString(int offs, String str, AttributeSet a)
			throws BadLocationException {
		if(str != null &#038;&#038; (getLength() + str.length() < maxChars)){
			super.insertString(offs, str, a);
		}
	}

	//getter e setter omitted
}
</pre>
<p>Here we defined one class called <i>MaxLengthTextDocument</i> that extends <i>PlainDocument</i>. In <i>insertString</i> attribute, we checked if quantity of characters minor than <i>maxChars</i> attribute, inserting in String if true.</p>
<p>After this, only insert our implementation in JTextField, this way:</p>
<pre class="brush:java">
	...
	MaxLengthTextDocument maxLength = new MaxLengthTextDocument();
	maxLength.setMaxChars(50);//50 is a maximum number of character 

	jTextField.setDocument(maxLength);
	...
</pre>
<p>And voilà!</p>
<p>See ya!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/09/setting-maximum-number-of-characters-in-jtextfield/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Inserting padding into a JLabel</title>
		<link>http://www.andrels.com/wp-en_US/index.php/2009/08/inserting-padding-into-a-jlabel/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.andrels.com/wp-en_US/index.php/2009/08/inserting-padding-into-a-jlabel/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 15:07:38 +0000</pubDate>
		<dc:creator>André</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.andrels.com/wp-en_US/?p=63</guid>
		<description><![CDATA[To insert padding into a JLabel we should use an EmptyBorder, where the attribute &#8216;width&#8217; will be our padding. Like<a href="http://www.andrels.com/wp-en_US/index.php/2009/08/inserting-padding-into-a-jlabel/" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>To insert padding into a JLabel we should use an EmptyBorder, where the attribute &#8216;width&#8217; will be our padding. Like this:</p>
<pre class="brush:java">...
JLabel jLabel = new JLabel("My JLabel");
//Border used as padding
Border paddingBorder = BorderFactory.createEmptyBorder(10,10,10,10);

jLabel.setBorder(BorderFactory.createCompoundBorder(border,paddingBorder));
...</pre>
<p>Here, the JLabel contains a padding with 10 pixels in top, right, bottom and left, respectively.</p>
<p><img class="aligncenter size-full wp-image-64" title="0" src="http://www.andrels.com/wp-en_US/wp-content/uploads/2009/08/0.jpg" alt="0" width="300" height="100" /></p>
<p>If you want to put border around the JLabel, you can use a CompoundBorder, setting Border and EmptyBorder (padding):</p>
<pre class="brush:java">...
JLabel jLabel = new JLabel("Meu JLabel");
//Border used as padding
Border paddingBorder = BorderFactory.createEmptyBorder(10,10,10,10);
//JLabel will be involved for this border
Border border = BorderFactory.createLineBorder(Color.BLUE);

jLabel.setBorder(BorderFactory.createCompoundBorder(border,paddingBorder));
...</pre>
<p><img src="http://www.andrels.com/wp-en_US/wp-content/uploads/2009/08/1.jpg" alt="1" title="1" width="300" height="100" class="aligncenter size-full wp-image-65" /></p>
<p>Download the source code of this sample <a href="http://www.andrels.com/wp-en_US/wp-content/plugins/download-monitor/download.php?id=1" title="Downloaded 275 times">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrels.com/wp-en_US/index.php/2009/08/inserting-padding-into-a-jlabel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

