<?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>Tidbits from my daily-life &#187; java</title>
	<atom:link href="http://blog.morgan.hk/category/computer-stuff/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.morgan.hk</link>
	<description>Bits and things of interest</description>
	<lastBuildDate>Wed, 02 Nov 2011 06:32:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Getting the correct time in JVM 1.5 and 1.6</title>
		<link>http://blog.morgan.hk/2007/11/09/getting-the-correct-time-in-jvm-15-and-16/</link>
		<comments>http://blog.morgan.hk/2007/11/09/getting-the-correct-time-in-jvm-15-and-16/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 13:52:13 +0000</pubDate>
		<dc:creator>morgan</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.morgan.hk/2007/11/09/getting-the-correct-time-in-jvm-15-and-16/</guid>
		<description><![CDATA[Maybe some of you out there are also using Sun&#8217;s JVM on your linux box but did not yet realise that the timezone settings in &#8230;]]></description>
			<content:encoded><![CDATA[<p>Maybe some of you out there are also using Sun&#8217;s JVM on your linux box but did not yet realise that the timezone settings in Java would not match the ones you use in you Gnome settings or system settings. The reason for that is that the JVM looks at a file /etc/localtime to find these timezone settings and apparently wants it to be a Symlink and not a file per se, so let&#8217;s fix it~</p>
<ol>
<li>backup your /etc/localtime<br />
<code>sudo cp /etc/localtime /etc/localtime.bak</code></li>
<li>now let&#8217;s link to the correct file after making a backup of it. In my case &#8220;Asia/Hong_Kong&#8221;, look for other regions in /usr/share/zoneinfo/<br />
<code>sudo cp /usr/share/zoneinfo/Asia/Hong_Kong /usr/share/zoneinfo/Asia/Hong_Kong.bak<br />
sudo ln -s -f /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime</code></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.morgan.hk/2007/11/09/getting-the-correct-time-in-jvm-15-and-16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display problems with Beryl (or Compiz) and Java</title>
		<link>http://blog.morgan.hk/2007/04/29/display-problems-with-beryl-or-compiz-and-java/</link>
		<comments>http://blog.morgan.hk/2007/04/29/display-problems-with-beryl-or-compiz-and-java/#comments</comments>
		<pubDate>Sat, 28 Apr 2007 18:11:27 +0000</pubDate>
		<dc:creator>morgan</dc:creator>
				<category><![CDATA[Computer Stuff]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Random Stuff]]></category>

		<guid isPermaLink="false">http://www.morgan.hk/blog/2007/04/29/display-problems-with-beryl-or-compiz-and-java/</guid>
		<description><![CDATA[Please refer to the following link 
you will find it useful
copy of this is when you click on &#8220;more&#8221;from http://wiki.beryl-project.org/wiki/Java on 29/04/2007 @02:10 GMT+8
Java
From Beryl &#8230;]]></description>
			<content:encoded><![CDATA[<p>Please refer to the following <a href="http://wiki.beryl-project.org/wiki/Java">link</a> <img src='http://blog.morgan.hk/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
you will find it useful<br />
copy of this is when you click on &#8220;more&#8221;<span id="more-142"></span>from http://wiki.beryl-project.org/wiki/Java on 29/04/2007 @02:10 GMT+8</p>
<h1 class="firstHeading">Java</h1>
<h3 id="siteSub">From Beryl Wiki</h3>
<p id="jump-to-nav">Jump to: <a href="http://wiki.beryl-project.org/wiki/Java#column-one">navigation</a>, <a href="http://wiki.beryl-project.org/wiki/Java#searchInput">search</a></p>
<p><!-- start content -->Java SE 6 gui applications such as Netbeans and possibly other AWT and Swing applications do not display correctly when using Beryl. Some people have stated that setting AWT_TOOLKIT=MToolkit (causing the Motif toolkit to be used instead of the X toolkit) fixes the display problems for Java SE 5. (<a href="http://wiki.beryl-project.org/wiki/Java#Fixing_Java_5">See bottom of page</a>)</p>
<p>Note: Switching to Metacity Window Manager then back to Beryl Window Manager seems to fix the problem for both Java 5 &amp; 6. Dialogs have strange behavior though, like not resizing correctly.</p>
<table id="toc" class="toc" summary="Contents">
<tr>
<td>
<p id="toctitle">&nbsp;</p>
<h2>Contents</h2>
<p><span class="toctoggle">[<a href="javascript:toggleToc()" class="internal" id="togglelink">hide</a>]</span></p>
<ul>
<li class="toclevel-1"><a href="http://wiki.beryl-project.org/wiki/Java#Fixing_Java_6"><span class="tocnumber">1</span> <span class="toctext">Fixing Java 6</span></a></li>
<li class="toclevel-1"><a href="http://wiki.beryl-project.org/wiki/Java#Fixing_Java_5"><span class="tocnumber">2</span> <span class="toctext">Fixing Java 5</span></a></li>
<li class="toclevel-1"><a href="http://wiki.beryl-project.org/wiki/Java#Fixing_Java_6_by_auto_scriting"><span class="tocnumber">3</span> <span class="toctext">Fixing Java 6 by auto scriting</span></a></li>
<li class="toclevel-1"><a href="http://wiki.beryl-project.org/wiki/Java#Alternative_Fix"><span class="tocnumber">4</span> <span class="toctext">Alternative Fix</span></a></li>
</ul>
</td>
</tr>
</table>
<p><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script></p>
<p class="editsection" style="float: right; margin-left: 5px">[<a href="http://wiki.beryl-project.org/index.php?title=Java&amp;action=edit&amp;section=1" title="Edit section: Fixing Java 6">edit</a>]</p>
<p><a title="Fixing_Java_6" name="Fixing_Java_6"></a></p>
<h2>Fixing Java 6</h2>
<p>The Motif toolkit seems to be missing for the latest Java SE 6 JDK on Linux so this is not a valid option. The following steps are needed to get Java SE 6 working with Beryl. This was based on information found at <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6509038" class="external free" title="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6509038" rel="nofollow">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6509038</a></p>
<p>Prepare some directories</p>
<pre>mkdir -p /tmp/java/src
mkdir -p /tmp/java/rt</pre>
<p>Extract the Java SE 6 runtime classes</p>
<pre>cp /usr/java/jdk1.6.0/jre/lib/rt.jar /usr/java/jdk1.6.0/jre/lib/rt.jar.orig
cp /usr/java/jdk1.6.0/jre/lib/rt.jar /tmp/java/rt/rt.zip
cd /tmp/java/rt
unzip rt.zip</pre>
<p>Get the source code (check for a later version at the <a href="http://download.java.net/jdk6/" class="external text" title="http://download.java.net/jdk6/" rel="nofollow">JDK download page</a>)</p>
<pre>cd ../src
wget <a href="http://www.java.net/download/jdk6/6u2/promoted/b01/jdk-6u2-ea-src-b01-jrl-29_mar_2007.jar" class="external free" title="http://www.java.net/download/jdk6/6u2/promoted/b01/jdk-6u2-ea-src-b01-jrl-29_mar_2007.jar" rel="nofollow">http://www.java.net/download/jdk6/6u2/promoted/b01/jdk-6u2-ea-src-b01-jrl-29_mar_2007.jar</a></pre>
<p>Extract the source code. Switch back to Metacity (Gnome Window Manager) if you are already using Beryl. Run the following (choosing /tmp/java/src to extract to):</p>
<pre>java -jar jdk-6u1-ea-src-b03-jrl-19_jan_2007.jar</pre>
<p>To patch j2se/src/solaris/classes/sun/awt/X11/XWM.java and j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java</p>
<pre>touch patch
nano patch</pre>
<p>Copy the following text code into the new file:</p>
<pre>diff -ur src.orig/j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java src/j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java
--- src.orig/j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	2007-02-24 08:21:07.000000000 -0500
+++ src/j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	2007-02-24 08:23:40.000000000 -0500
@@ -692,7 +692,7 @@
                 // ConfigureNotify, only the one from X with zero
                 // coordinates.  This is the workaround to get real
                 // location, 6261336
-                // Do the same for non-reparenting WMs (Compiz, Looking Glass)
+                // Do the same for non-reparenting WMs (Compiz, Looking Glass, Beryl)
                 switch (XWM.getWMID()) {
                   case XWM.CDE_WM:
                   case XWM.MOTIF_WM:
@@ -700,6 +700,7 @@
                   case XWM.SAWFISH_WM:
                   case XWM.COMPIZ_WM:
                   case XWM.LG3D_WM:
+                  case XWM.BERYL_WM:
                   {
                       Point xlocation = queryXLocation();
                       if (log.isLoggable(Level.FINE)) log.log(Level.FINE, "New X location: {0}", new Object[]{xlocation});
diff -ur src.orig/j2se/src/solaris/classes/sun/awt/X11/XWM.java src/j2se/src/solaris/classes/sun/awt/X11/XWM.java
--- src.orig/j2se/src/solaris/classes/sun/awt/X11/XWM.java	2007-02-24 08:21:07.000000000 -0500
+++ src/j2se/src/solaris/classes/sun/awt/X11/XWM.java	2007-02-24 08:22:58.000000000 -0500
@@ -79,7 +79,8 @@
         ICE_WM = 10,
         METACITY_WM = 11,
         COMPIZ_WM = 12,
-        LG3D_WM = 13;
+        LG3D_WM = 13,
+        BERYL_WM = 14;
     public String toString() {
         switch  (WMID) {
           case NO_WM:
@@ -106,6 +107,8 @@
               return "Compiz";
           case LG3D_WM:
               return "LookingGlass";
+          case BERYL_WM:
+              return "Beryl";
           case UNDETERMINED_WM:
           default:
               return "Undetermined WM";
@@ -534,6 +537,10 @@
         return isNetWMName("LG3D");
     }

+    static boolean isBeryl() {
+        return isNetWMName("beryl");
+    }
+
     /*
      * Is Metacity running?
      */
@@ -546,7 +553,7 @@
     }

     static boolean isNonReparentingWM() {
-        return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM);
+        return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM || XWM.getWMID() == XWM.BERYL_WM);
     }

     /*
@@ -738,6 +745,8 @@
                 awt_wmgr = XWM.COMPIZ_WM;
             } else if (isLookingGlass()) {
                 awt_wmgr = LG3D_WM;
+            } else if (isBeryl()) {
+                awt_wmgr = BERYL_WM;
             } else if (doIsIceWM &amp;&amp; isIceWM()) {
                 awt_wmgr = XWM.ICE_WM;
             }
@@ -1387,6 +1396,7 @@
           case XWM.ENLIGHTEN_WM:
               return readInsetsArray(window, XA_E_FRAME_SIZE, insets);
           case XWM.COMPIZ_WM:
+          case XWM.BERYL_WM:
               return readInsetsArray(window, XA_FRAME_EXTENTS, insets);
           default:
               return false;</pre>
<p>Use <em>Ctrl + X</em>, <em>Y</em>, <em>Enter</em> to exit saving changes. Go ahead and make it executable.</p>
<pre>chmod +x patch</pre>
<p>Now apply the patch file</p>
<pre>patch -p1 &lt; patch</pre>
<p>Remove the classes we are going to replace</p>
<pre>cd ../rt
rm sun/awt/X11/XDecoratedPeer*
rm sun/awt/X11/XWM.*
rm sun/awt/X11/XWM$*</pre>
<p>Copy the modified source files in (so we don&#8217;t have to mess with destinations or classpath)</p>
<pre>cp ../src/j2se/src/solaris/classes/sun/awt/X11/XWM.java sun/awt/X11
cp ../src/j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java sun/awt/X11</pre>
<p>Compile the modified classes</p>
<pre>javac -d . sun/awt/X11/*.java</pre>
<p>Update the changed files</p>
<pre>zip -f rt.zip sun/awt/X11/*</pre>
<p>Replace the old rt.jar</p>
<pre>cp rt.zip /usr/java/jdk1.6.0/jre/lib/rt.jar</pre>
<p class="editsection" style="float: right; margin-left: 5px">[<a href="http://wiki.beryl-project.org/index.php?title=Java&amp;action=edit&amp;section=2" title="Edit section: Fixing Java 5">edit</a>]</p>
<p><a title="Fixing_Java_5" name="Fixing_Java_5"></a></p>
<h2>Fixing Java 5</h2>
<p>Open up <em>~/.bashrc</em> or <em>/etc/bashrc</em> for editing</p>
<pre>nano ~/.bashrc</pre>
<p>Insert as the first line</p>
<pre>export AWT_TOOLKIT=MToolkit</pre>
<p>Restart window manager and all terminal windows. Known to work for Ubuntu 6.10, Java 5. <a href="http://ubuntuforums.org/showthread.php?p=2165224" class="external text" title="http://ubuntuforums.org/showthread.php?p=2165224" rel="nofollow">See for more information.</a></p>
<p class="editsection" style="float: right; margin-left: 5px">[<a href="http://wiki.beryl-project.org/index.php?title=Java&amp;action=edit&amp;section=3" title="Edit section: Fixing Java 6 by auto scriting">edit</a>]</p>
<p><a title="Fixing_Java_6_by_auto_scriting" name="Fixing_Java_6_by_auto_scriting"></a></p>
<h2>Fixing Java 6 by auto scriting</h2>
<p>Create new file:</p>
<pre>  <em>vim beryl.jdk6.fix.sh</em></pre>
<p>Copy the following text code into the new file:</p>
<table style="border: 1px solid #aaaaaa; padding: 5px; background: #f9f9f9 none repeat scroll 0% 50%; width: 400px; margin-top: 5px; margin-bottom: 5px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<tr>
<td><font style="font-weight: bold">CODES:</font></p>
<pre>#!/bin/bash
# testing pass in archlinux 0.8 by SCys
# Write for beryl fix jdk 6!

checkAll()
{
	[ ! -x "`which zip`" ] &amp;&amp; echo "no zip!" &amp;&amp; exit 0
	[ ! -x "`which unzip`" ] &amp;&amp; echo "no unzip!" &amp;&amp; exit 0
	[ ! -x "`which wget`" ] &amp;&amp; echo "no wget!" &amp;&amp; exit 0
	[ ! -x "`which awk`" ] &amp;&amp; echo "no awk!" &amp;&amp; exit 0
}
checkAll
setJdkPath()
{
	if [ "$CLASSPATH" ]
	then
		LIB_PATH=`echo ${CLASSPATH} | awk -F : '{print $3}'`
	elif [ "$1" ]
	then
		LIB_PATH=$1
	elif [ -x $LIB_PATH/rt.jar ]
	then
		echo "JRE LIB PATH not set up!please set like \"this beryl.jdk.fix.sh /opt/java/jre/lib\" "
		exit 0
	fi
	echo $LIB_PATH
}
#
#--MAIN---
#
#1: Set var
setJdkPath $1
#2: Prepare some directories
mkdir -p /tmp/java
mkdir -p /tmp/java/src
mkdir -p /tmp/java/rt
#3: Extract the Java SE 6 runtime classes
if [ ! -x /tmp/java/rt/rt.zip ]
then
	cp $LIB_PATH/rt.jar $LIB_PATH/rt.jar.orig
	cp $LIB_PATH/rt.jar /tmp/java/rt/rt.zip
fi
cd /tmp/java/rt
echo "Please waiting for unzip all files"
unzip rt.zip &gt; /dev/null
echo "Unzip ok."
#4: Get the source code
cd ../src
wget http://www.java.net/download/jdk6/6u2/promoted/b01/jdk-6u2-ea-src-b01-jrl-29_mar_2007.jar
java -jar jdk-6u2-ea-src-b01-jrl-29_mar_2007.jar
#5: To patch:
#	j2se/src/solaris/classes/sun/awt/X11/XWM.java
#	j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java
echo 'diff -ur src.orig/j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java src/j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java
--- src.orig/j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	2007-02-24 08:21:07.000000000 -0500
+++ src/j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	2007-02-24 08:23:40.000000000 -0500
@@ -692,7 +692,7 @@
                 // ConfigureNotify, only the one from X with zero
                 // coordinates.  This is the workaround to get real
                 // location, 6261336
-                // Do the same for non-reparenting WMs (Compiz, Looking Glass)
+                // Do the same for non-reparenting WMs (Compiz, Looking Glass, Beryl)
                 switch (XWM.getWMID()) {
                   case XWM.CDE_WM:
                   case XWM.MOTIF_WM:
@@ -700,6 +700,7 @@
                   case XWM.SAWFISH_WM:
                   case XWM.COMPIZ_WM:
                   case XWM.LG3D_WM:
+                  case XWM.BERYL_WM:
                   {
                       Point xlocation = queryXLocation();
                       if (log.isLoggable(Level.FINE)) log.log(Level.FINE, "New X location: {0}", new Object[]{xlocation});
diff -ur src.orig/j2se/src/solaris/classes/sun/awt/X11/XWM.java src/j2se/src/solaris/classes/sun/awt/X11/XWM.java
--- src.orig/j2se/src/solaris/classes/sun/awt/X11/XWM.java	2007-02-24 08:21:07.000000000 -0500
+++ src/j2se/src/solaris/classes/sun/awt/X11/XWM.java	2007-02-24 08:22:58.000000000 -0500
@@ -79,7 +79,8 @@
         ICE_WM = 10,
         METACITY_WM = 11,
         COMPIZ_WM = 12,
-        LG3D_WM = 13;
+        LG3D_WM = 13,
+        BERYL_WM = 14;
     public String toString() {
         switch  (WMID) {
           case NO_WM:
@@ -106,6 +107,8 @@
               return "Compiz";
           case LG3D_WM:
               return "LookingGlass";
+          case BERYL_WM:
+              return "Beryl";
           case UNDETERMINED_WM:
           default:
               return "Undetermined WM";
@@ -534,6 +537,10 @@
         return isNetWMName("LG3D");
     }

+    static boolean isBeryl() {
+        return isNetWMName("beryl");
+    }
+
     /*
      * Is Metacity running?
      */
@@ -546,7 +553,7 @@
     }

     static boolean isNonReparentingWM() {
-        return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM);
+        return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM || XWM.getWMID() == XWM.BERYL_WM);
     }

     /*
@@ -738,6 +745,8 @@
                 awt_wmgr = XWM.COMPIZ_WM;
             } else if (isLookingGlass()) {
                 awt_wmgr = LG3D_WM;
+            } else if (isBeryl()) {
+                awt_wmgr = BERYL_WM;
             } else if (doIsIceWM &amp;&amp; isIceWM()) {
                 awt_wmgr = XWM.ICE_WM;
             }
@@ -1387,6 +1396,7 @@
           case XWM.ENLIGHTEN_WM:
               return readInsetsArray(window, XA_E_FRAME_SIZE, insets);
           case XWM.COMPIZ_WM:
+          case XWM.BERYL_WM:
               return readInsetsArray(window, XA_FRAME_EXTENTS, insets);
           default:
               return false;' &gt; patch
chmod +x patch
patch -p1 &lt; patch
#6: Replace classes
cd ../rt
rm sun/awt/X11/XDecoratedPeer*
rm sun/awt/X11/XWM.*
rm sun/awt/X11/XWM$*
cp ../src/j2se/src/solaris/classes/sun/awt/X11/XWM.java sun/awt/X11
cp ../src/j2se/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java sun/awt/X11
#7: Compile the modified classes
echo "Please waiting for complie."
javac -d . sun/awt/X11/*.java
echo "complie ok."
#8: Update the changed files
zip -f rt.zip sun/awt/X11/*
#9: Replace the old rt.jar
cp rt.zip $LIB_PATH/rt.jar
echo "All ok, start some java application to try. "</pre>
</td>
</tr>
</table>
<p>Make it executable:</p>
<pre>   <em>chmod +x beryl.jdk6.fix.sh</em></pre>
<p>Run it:</p>
<pre>   <em>sh beryl.jdk6.fix.sh</em></pre>
<p>There is a much easyer way to resolve that problem:</p>
<p>type the following in a console window:</p>
<p>sudo gedit /etc/environment</p>
<p>then add the following line at the bottom and save the file.</p>
<p>AWT_TOOLKIT=&#8221;MToolkit&#8221;</p>
<p>finally restart x (ctrl+alt+backspace)</p>
<p class="editsection" style="float: right; margin-left: 5px">[<a href="http://wiki.beryl-project.org/index.php?title=Java&amp;action=edit&amp;section=4" title="Edit section: Alternative Fix">edit</a>]</p>
<p><a title="Alternative_Fix" name="Alternative_Fix"></a></p>
<h2> Alternative Fix</h2>
<p>There is also a sure shot method posted to get Java applications to work if the above method does not work.</p>
<p>Refer to <a href="http://www.vikrammohan.com/blog/2006/12/31/how-to-make-java-swing-work-on-beryl-with-aiglx/" class="external free" title="http://www.vikrammohan.com/blog/2006/12/31/how-to-make-java-swing-work-on-beryl-with-aiglx/" rel="nofollow">http://www.vikrammohan.com/blog/2006/12/31/how-to-make-java-swing-work-on-beryl-with-aiglx/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.morgan.hk/2007/04/29/display-problems-with-beryl-or-compiz-and-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing mercury messenger on Ubuntu linux</title>
		<link>http://blog.morgan.hk/2007/04/29/installing-mercury-messenger-on-ubuntu-linux/</link>
		<comments>http://blog.morgan.hk/2007/04/29/installing-mercury-messenger-on-ubuntu-linux/#comments</comments>
		<pubDate>Sat, 28 Apr 2007 16:35:44 +0000</pubDate>
		<dc:creator>morgan</dc:creator>
				<category><![CDATA[Computer Stuff]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Random Stuff]]></category>

		<guid isPermaLink="false">http://www.morgan.hk/blog/2007/04/29/installing-mercury-messenger-on-ubuntu-linux/</guid>
		<description><![CDATA[adapted from of this site.
In this post we are trying to install mercury messenger. Mercury is a MSN compatible messenging client which is in my &#8230;]]></description>
			<content:encoded><![CDATA[<p>adapted from of <a href="http://alexit.wordpress.com/2007/03/20/mercury-linstant-messenger-piu-completo/trackback/">this site</a>.</p>
<p>In this post we are trying to install <a href="http://www.mercury.to">mercury messenger</a>. Mercury is a MSN compatible messenging client which is in my opinion one of the best ones. It is written in java and thus runs on most computers.<br />
In this copy&#8217;n'paste we will use the repository made by <a href="http://3v1n0.tuxfamily.org/blog/">Trevino</a> who has quite a few useful things.</p>
<p>Here is what you have to copy and paste in a terminal window:</p>
<blockquote><p><code>sudo apt-get install sun-java5-bin<br />
sudo update-alternatives --config java</code><code><br />
sudo gedit /etc/apt/sources.list</code></p></blockquote>
<p>Paste this in the window that pop&#8217;s up:</p>
<blockquote><p><code># Treviño's Ubuntu edgy Repository (GPG key: 81836EBF - DD800CD9)<br />
# Further informations: http://3v1n0.tuxfamily.org<br />
deb http://download.tuxfamily.org/3v1deb edgy 3v1n0<br />
deb-src http://download.tuxfamily.org/3v1deb edgy 3v1n0</code></p></blockquote>
<p>Close that window after saving and in the terminal paste:</p>
<blockquote><p><code>wget http://download.tuxfamily.org/3v1deb/DD800CD9.gpg -O- | sudo apt-key add -<br />
</code><code>sudo apt-get update<br />
sudo apt-get install mercury-messenger</code></p></blockquote>
<p>If you are using beyril or compiz you might wanna disable them if Mercury does not want to be friendly with them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.morgan.hk/2007/04/29/installing-mercury-messenger-on-ubuntu-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>java assignement</title>
		<link>http://blog.morgan.hk/2006/03/23/java-assignement/</link>
		<comments>http://blog.morgan.hk/2006/03/23/java-assignement/#comments</comments>
		<pubDate>Thu, 23 Mar 2006 04:58:59 +0000</pubDate>
		<dc:creator>gaganou</dc:creator>
				<category><![CDATA[Computer Stuff]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Stirling University]]></category>

		<guid isPermaLink="false">http://www.gaganou.com/blog/2006/03/23/java-assignement/</guid>
		<description><![CDATA[<p>So annoying^^ Yesterday until 3am I did my 1st java assignement for the CSC932 course I am currently taking at Stirling University. Seriously, the application could be improved, but they require the application to be similar to the one they present to us in a compiled format.(JNLP) Was quite a pain as they required the controllers of the program to be scrambled around? Just have a look at the code =D(i know it could be optimised, but i wanted the code to be as close as possible to the way they teach us to code in lectures so as not to be penalised by my style of coding ^^)</p> <p>code of my app in the <a href="http://blog.siumai.com/index.php?2006/03/23/5-java-assignement" lang="en">full article</a></p>]]></description>
			<content:encoded><![CDATA[<p>So annoying^^ Yesterday until 3am I did my 1st java assignement for the CSC932 course I am currently taking at Stirling University. Seriously, the application could be improved, but they require the application to be similar to the one they present to us in a compiled format.(JNLP) Was quite a pain as they required the controllers of the program to be scrambled around? Just have a look at the code =D(i know it could be optimised, but i wanted the code to be as close as possible to the way they teach us to code in lectures so as not to be penalised by my style of coding ^^)</p>
<p>code of my app in the <a href="http://blog.siumai.com/index.php?2006/03/23/5-java-assignement">full article</a></p>
<p><span id="more-23"></span></p>
<p>So annoying^^ Yesterday until 3am I did my 1st java assignement for the CSC932 course I am currently taking at Stirling University. Seriously, the application could be improved, but they require the application to be similar to the one they present to us in a compiled format.(JNLP) Was quite a pain as they required the controllers of the program to be scrambled around? Just have a look at the code =D(i know it could be optimised, but i wanted the code to be as close as possible to the way they teach us to code in lectures so as not to be penalised by my style of coding ^^)</p>
<pre>import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.util.*; /** * CSC932 // Assignement 1 // Puzzle.java * * INFORMATIONS ABOUT THE CLASS * where cardinal positions are not used for deciding about coordinates, ?v? and ?h? will be used to define vertical and horizontal respectively * all measures not defined in the global variables will be proportional to those defined in the global variables * */ public class Puzzle extends JFrame implements ChangeListener { /** * These are the Global variables */ /** * You may play with these * (other settings might have to be adjusted in the ?main? function) */ //Variables relating to the squares of the Puzzle private int squareSize = 40; // Square size private int blockSize = 10; // Red Block size //Variables relating to the drawing area private int drawPanelSize = 300; //Size of the square drawing panel private int maxDrawingAreaX = drawPanelSize - squareSize; // Maximum drawing area for the squares on X (ie X coordinate of SE corner of allowed drawing region) private int maxDrawingAreaY = drawPanelSize - 50; // Maximum drawing area for the squares on Y (ie Y coordinate of SE corner of allowed drawing region while leaving space for text)) private int maxDrawingAreaTopLeftY = maxDrawingAreaY - squareSize; // Maximum Y value for the Top Left corner of the Square /** * You may NOT play with these as they define objects in the script */ //Random Variable private Random random; //Panel used to draw on private JPanel panel; //Sliders (h: horizontal|v: vertical) private JSlider slider1h;//Box1 private JSlider slider1v; private JSlider slider2h;//Box2 private JSlider slider2v; private JSlider slider3h;//Box3 private JSlider slider3v; private JSlider slider4h;//Box4 private JSlider slider4v; /** * The main method is the main action for the Puzzle program. * * @param args The launch arguments (though none are required). */ public static void main (String[] args) { // Determine the size of the screen and new window position Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int)dim.getWidth()/2 - 500/2; int y = (int)dim.getHeight()/2 - 400/2; //Create Frame Puzzle frame = new Puzzle(); frame.setSize(500,400); // size of window frame.setLocation(x, y); // location of the window frame.setTitle(?Children?s Sliding Squares Puzzle?); // title of the window frame.createGUI(); frame.setVisible(true); } // end of main /** * The createGUI method is called by the main method * to set up the graphical user interface. */ private void createGUI() { // New Random Class launched random = new Random(); // Set up main window characteristics setDefaultCloseOperation(EXIT_ON_CLOSE); Container window = getContentPane(); window.setLayout(new FlowLayout() ); // Create the adjustable slider //Scrambled for 1A** ? should be used as a reference for the slider values in stateChanged, so as to keep the correct x/y limits for the values slider1v = new JSlider(JSlider.VERTICAL, 0, maxDrawingAreaTopLeftY, random.nextInt(maxDrawingAreaTopLeftY));//Box1V slider1h = new JSlider(JSlider.HORIZONTAL, 0, maxDrawingAreaX, random.nextInt(maxDrawingAreaX));//Box2H slider2v = new JSlider(JSlider.VERTICAL, 0, maxDrawingAreaTopLeftY, random.nextInt(maxDrawingAreaTopLeftY));//Box2V slider2h = new JSlider(JSlider.HORIZONTAL, 0, maxDrawingAreaX, random.nextInt(maxDrawingAreaX));//Box4V slider3v = new JSlider(JSlider.VERTICAL, 0, maxDrawingAreaX, random.nextInt(maxDrawingAreaX));//Box3H slider3h = new JSlider(JSlider.HORIZONTAL, 0, maxDrawingAreaTopLeftY, random.nextInt(maxDrawingAreaTopLeftY));//Box1H slider4v = new JSlider(JSlider.VERTICAL, 0, maxDrawingAreaX, random.nextInt(maxDrawingAreaX));//Box4H slider4h = new JSlider(JSlider.HORIZONTAL, 0, maxDrawingAreaTopLeftY, random.nextInt(maxDrawingAreaTopLeftY));//Box3V // Add half of Vertical Sliders to the window window.add(slider1v);//Box1 window.add(slider2v);//Box2 // Create the panel for drawing on panel = new JPanel(); panel.setPreferredSize(new Dimension(drawPanelSize, drawPanelSize)); panel.setBackground(Color.white); window.add(panel); // Add remaining Vertical Sliders to the window window.add(slider3v);//Box3 window.add(slider4v);//Box4 // Add the Horizontal Sliders to the window window.add(slider1h);//Box1 window.add(slider2h);//Box2 window.add(slider3h);//Box3 window.add(slider4h);//Box4 // Add ChangeListener to the slider slider1h.addChangeListener(this); slider1v.addChangeListener(this); slider2h.addChangeListener(this); slider2v.addChangeListener(this); slider3h.addChangeListener(this); slider3v.addChangeListener(this); slider4h.addChangeListener(this); slider4v.addChangeListener(this); } // end of createGUI /** * The stateChanged method is called automatically * when the slider is adjusted. * * @param event This brings information about the slider * adjustment event. This information is * ignored in this application as we know which slider * must have been adjusted! */ public void stateChanged(ChangeEvent e) { Graphics paper = panel.getGraphics(); // First erase the drawing on the paper paper.setColor(Color.white); paper.fillRect(0, 0, drawPanelSize, drawPanelSize); //Scramble slider values and actions int sliderValue1v = slider1v.getValue(); int sliderValue1h = slider2h.getValue(); int sliderValue2v = slider2v.getValue(); int sliderValue2h = slider4v.getValue(); int sliderValue3v = slider3h.getValue(); int sliderValue3h = slider1h.getValue(); int sliderValue4v = slider4h.getValue(); int sliderValue4h = slider3v.getValue(); //Draw Squares drawSquares(paper, Color.cyan, sliderValue1h, sliderValue1v, ?NW?, squareSize, blockSize); drawSquares(paper, Color.black , sliderValue2h, sliderValue2v, ?NE?, squareSize, blockSize); drawSquares(paper, Color.pink , sliderValue3h, sliderValue3v, ?SW?, squareSize, blockSize); drawSquares(paper, Color.magenta , sliderValue4h, sliderValue4v, ?SE?, squareSize, blockSize); //Find if the squares are next to each other if ( (sliderValue1h == sliderValue2h + squareSize) &#038;&#038; (sliderValue3h == sliderValue4h + squareSize) &#038;&#038; (sliderValue1h == sliderValue3h) &#038;&#038; (sliderValue1v == sliderValue3v + squareSize) &#038;&#038; (sliderValue2v == sliderValue4v + squareSize) &#038;&#038; (sliderValue1v == sliderValue2v)){ drawSmiley(paper, sliderValue4h + (squareSize/4), sliderValue4v + (squareSize/4), squareSize*3/2); } //Draw Instructions paper.setColor(Color.blue); paper.drawString(?Use the sliders to move the four pieces??,20,maxDrawingAreaY+15); paper.drawString(?? but which are which?? Complete the red?,20,maxDrawingAreaY+30); paper.drawString(?square precisely? and get a surprise!? ,20,maxDrawingAreaY+45); } // end of stateChanged private void drawSquares(Graphics paper, Color c, int x, int y, String placementOfBlock, int size, int blockSize){ //Setting the position of the red blocks in the color squares int blockY=0; int blockX=0; if(placementOfBlock == ?center?){//Center of the square blockX = x + size/2 - blockSize/2; blockY = y + size/2 - blockSize/2; }else if(placementOfBlock == ?NW?){//North West Corner blockX = x; blockY = y; }else if(placementOfBlock == ?NN?){//North Centre blockX = x + size/2 - blockSize/2; blockY = y; }else if(placementOfBlock == ?NE?){//North East blockX = x + size - blockSize; blockY = y; }else if(placementOfBlock == ?EE?){//East Centre blockX = x + size - blockSize; blockY = y + size/2 - blockSize/2; }else if(placementOfBlock == ?SE?){//South East blockX = x + size - blockSize; blockY = y + size - blockSize; }else if(placementOfBlock == ?SS?){//South Centre blockX = x + size/2 - blockSize/2; blockY = y + size - blockSize; }else if(placementOfBlock == ?SW?){//South West blockX = x; blockY = y + size - blockSize; }else if(placementOfBlock == ?WW?){//West Centre blockX = x; blockY = y + size/2 - blockSize/2; } // draw Colored square paper.setColor(c); paper.fillRect(x, y, size, size); // draw Red block paper.setColor(Color.red); paper.fillRect(blockX, blockY, blockSize, blockSize); } // end of drawSquares private void drawSmiley(Graphics paper, int x, int y, int size){ //Draws a smiley //Background paper.setColor(Color.yellow); paper.fillOval(x,y,size,size); //Cicle around the background paper.setColor(Color.black); paper.drawOval(x,y,size,size); //Smile paper.drawOval(x+(size*3/10),y+(size*6/10),(size*4/10),(size*15/100)); paper.setColor(Color.yellow); paper.fillRect(x+(size*3/10),y+(size*6/10),(size*4/10),(size*15/100)/2); // Hiding the excess smile //Eyes paper.setColor(Color.black); paper.fillOval(x+(size*2/10),y+(size*3/10),(size*1/10),(size*1/10)); paper.fillOval(x+(size*7/10),y+(size*3/10),(size*1/10),(size*1/10)); } // end of drawSmiley } // end of Puzzle</pre>
<p><a href="http://www.gaganou.com/blog/original%20post%20from%20blog.nagrom.info%20on%2011/03/2006">original post from blog.nagrom.info on 11/03/2006</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.morgan.hk/2006/03/23/java-assignement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

