Saturday, August 25, 2007

Aetas Now With Better Animation

Hey guys the previous few days i was to busy to do anything in java couldn't even get time to post.....But yeah i saw the awesome examples about which Romain posted on his blog the were seriously "Filthy Rich"!!!!!

I know  the animation effect in Aetas was no good, so now there is an alternative version of Aetas (Available here).

I request you guys to tell me any sort of changes that i should introduce in Aetas or any bug that i might mot have noticed..........

Here are the link again:

http://code.google.com/p/ateas

Link to the binaries here:
http://aetas.googlecode.com/files/Aetas-bin.zip

The source here:
http://aetas.googlecode.com/files/Aetas_1.0-src.zip

Thursday, July 26, 2007

Aetas-Simple Tool & Cool Gui

I am a regularly read Romain's blog and have learned a lot of stuff from there. The one thing the impressed me the most was his post that read "simple tools for simple tasks ..... with cool gui" .

I developed Aetas(download link at the end) keeping in mind Romain's post "simple tools with simple tasks ..... with cool gui". So i gave it eye candy looks. The main frame screen shot :

Here I have used a custom made picture as the background. The various labels that you see were written with different font loaded at runtime.The highlight areas around the clock change their respective positions when clicked on, i.e when you click on the highlighted area which is a little lighter,when clicked on, swaps the position with the other.....

Now since the main frame is too big soI thought of adding a widget frame so that it can be run continuously. The screen shots are available in my previous post and here.

This widget frame consists of two different types of fonts.One being used as the label and the other for the clock.The switch from the main frame to the widget frame can be made by pressing the minimize button in the main frame.The transition from the main frame to the widget frame includes two animations.the first animation wraps the main frame while the second moves the widget frame to the right corner of your screen.

It also includes a splash screen(Screen shots available in the previous post).

It includes usage of GradientPaint to make the labels look better.

For downloading Aetas' binaries and sources please follow:
http://code.google.com/p/aetas

Tuesday, July 10, 2007

Ready for Aetas?

Hey guys in my last post i talked about "AETAS"......its now ready and can be downloaded from Google Code site.It includes a widget frame too(who would like to see big frame on their screens all the time?). Everyone might be interested in the screen-shots,without further ado, here they are:

1) The splash screen(shouldn't have written author but anyways)
2)Main Window(press the minimize button to switch to the mini view):
3)Widget window(or the mini frame):

(press the maximize button in the mini frame to switch to the main view)

For a some fun,I added a little animation when the frame switches from Main view to the mini view.Check it out yourself.

Here is the link again:

http://code.google.com/p/aetas

Wednesday, July 4, 2007

To where I belong at-least used to

Hey there all its been a long time since i last posted! This time period included a lot of important events of my life like semester exams,my grand fathers death, reaching next level of development of applications in java,etc......

Well now off to something that i worked on lately,this is a simple and eye candy sort of application named "Aetas"(Latin word for time).I developed this for my cousin sis who is living in Central America so that whenever she has to chat with any one here in India she can refer to the utility.
Here is how it looks:



I hope you like it.The source will be available soon enough.

Saturday, April 21, 2007

Transparancy Secret Of Yahoo Widget Engine Revealed

Well recently I moved one of my yahoo widgets to a new location and guess what i noticed! It revealed the yahoo widget's transparency secret...It uses the same old method that we use in java,the robot method("The method that most of the people did not like")!! and thats the truth here are the sequence of images:

1) before I hit the start button
2)I hit the start button
3)Upon press the start button again(notice that the captured image of the menu bar on the upper left widget):
4)After refreshing:
Should I conclude that the robot method is not that bad after all!huh?

Sunday, April 15, 2007

Make The Swing Fly

Recently this thing struck my head that i can make my JFrame(Swing components)"Fly In" when the application is started and fly out when the quit button is hit and ended up with the following code.Use it and add a better entrance and exit effect to your applications!!!!!
I'll be adding it to NYouTube.

Enjoy!
:-)


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends JFrame {

JFrame f;
JButton jb;
Dimension t;
public Test(){
f=new JFrame("Flying window");
jb=new JButton("Quit");
//Get the screen size
t=Toolkit.getDefaultToolkit().getScreenSize();
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
//The Fly Out effect
for(int i=t.width/2;i>=0;i-=2)
{
f.setLocation(i,i);
f.repaint();

}
System.exit(0);
}
});

f.getContentPane().add(jb);
f.pack();
f.setSize(100,100);
f.setDefaultCloseOperation(3);
f.setVisible(true);
//The Fly In effect
for(int i=0;i<=t.width/2;i+=2)
{
f.setLocation(i,i);
f.repaint();

}

}
public static void main(String[] s)
{
new Test();
}

}

Wednesday, April 11, 2007

Here Is Some Bad News And Good News As Well

Well to begin with the bad news first:All my Applications at GSOC for NYoutube have been rejected...........This depressed me a lot!!!!!!!!

Well i cannot stay depressed there is always a next time so its time to move on......

Here is the good news!!!!!!!

Now i will be coding for NYoutube by myself and will try to make as user friendly and as attractive as possible i will keep giving updates here itself also i have these internal exams of my college on 26th of this month and external semester exams approaching on the 17th of next month....so the coding will be a bit slower but i will try to complete it as soon as possible....
;-)

Friday, March 30, 2007

Transparent Window In Java Back With A BANG

Here is another version of code for Transparent Window in Java seems to be better than any of the previous version and has a blur effect to emulate the Vista look.Here is the code:

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.awt.image.*;



public class TransparentBackground extends JComponent

implements ComponentListener, WindowFocusListener, Runnable {

private JFrame _frame;

private BufferedImage _background;

private long _lastUpdate = 0;

private boolean _refreshRequested = true;



private Robot _robot;

private Rectangle _screenRect;



private ConvolveOp _blurOp;

public TransparentBackground(JFrame frame) {

_frame = frame;



try {

_robot = new Robot();

} catch (AWTException e) {

e.printStackTrace();

return;

}



Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

_screenRect = new Rectangle(dim.width, dim.height);



float[] my_kernel = {

0.10f, 0.10f, 0.10f,

0.10f, 0.20f, 0.10f,

0.10f, 0.10f, 0.10f};

_blurOp = new ConvolveOp(new Kernel(3, 3, my_kernel));



updateBackground();

_frame.addComponentListener(this);

_frame.addWindowFocusListener(this);

new Thread(this).start();

}


protected void updateBackground() {

_background = _robot.createScreenCapture(_screenRect);

}



protected void refresh() {

if (_frame.isVisible() && this.isVisible()) {

repaint();

_refreshRequested = true;

_lastUpdate = System.currentTimeMillis();

}

}


protected void paintComponent(Graphics g) {

Graphics2D g2 = (Graphics2D) g;



Point pos = this.getLocationOnScreen();



BufferedImage buf = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);

buf.getGraphics().drawImage(_background, -pos.x, -pos.y, null);



Image img = _blurOp.filter(buf, null);

g2.drawImage(img, 0, 0, null);



g2.setColor(new Color(255, 255, 255, 192));

g2.fillRect(0, 0, getWidth(), getHeight());

}

public void componentHidden(ComponentEvent e) {
refresh();
}



public void componentMoved(ComponentEvent e) {

repaint();

}



public void componentResized(ComponentEvent e) {

repaint();

}



public void componentShown(ComponentEvent e) {

repaint();

}

public void windowGainedFocus(WindowEvent e) {

refresh();

}



public void windowLostFocus(WindowEvent e) {

refresh();

}

public void run() {

try {

while (true) {

Thread.sleep(100);

long now = System.currentTimeMillis();

if (_refreshRequested && ((now - _lastUpdate) > 1000)) {

if (_frame.isVisible()) {

Point location = _frame.getLocation();

_frame.setLocation(-_frame.getWidth(), -_frame.getHeight());

updateBackground();

_frame.setLocation(location);

refresh();

}

_lastUpdate = now;

_refreshRequested = false;

}

}

} catch (InterruptedException e) {

e.printStackTrace();

}

}



public static void main(String[] args) {

JFrame frame = new JFrame("Transparent Window");

TransparentBackground bg = new TransparentBackground(frame);



frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);



frame.getContentPane().add(bg);

frame.pack();

frame.setSize(200, 200);

frame.setLocation(500, 500);

frame.setVisible(true);

}

}


For Mac Users you need to simply write the following

import java.swing.*;
.......
public class TransparentBackground{

.......//code here
.......//code here
.......//code here
.......//code here
 frame.setBackground(new Color(0, 0, 0, 0));
}

Transparent window "in SkinL&f No Good"!!!

Eric Bruke's blog entry in one of his blog entry said that the skin look and feel is the best alternative to making a transparent window well here is what happens when you try to move the window from one location to another



Well i have improved upon the transparent Window in Swing Hacks wait for my next post to get the code

Monday, March 26, 2007

Using XML as database with Java

here is how you can use XML file as a database,you can get the driver here

here is how you can connect to the database:

try {
// Load the DB2 JDBC Type 2 Driver with DriverManager
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}



Here is an example of XML as database
Import the package:

import com.ibm.db2.jcc.DB2Xml;

getting connection:

connection = DriverManager.getConnection(url, user, pass);

the prepare statement:

PreparedStatement stmt = connection.prepareStatement(sql);


Result Set:

option 1:
ResultSet resultSet = stmt.executeQuery();
option 2:
InputStream inputStream = resultSet.getBinaryStream(1);

option 3:
DB2Xml db2xml = (DB2Xml) resultSet.getObject(1);


Selecting a XML value:

String sql = "SELECT PID, DESCRIPTION from XMLPRODUCT where PID = ?";
PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setString(1, "100-105-09");
ResultSet resultSet = stmt.executeQuery();
String xml = resultSet.getString("DESCRIPTION"); // or
InputStream inputStream = resultSet.getBinaryStream("DESCRIPTION"); // or
Reader reader = resultSet.getCharacterStream("DESCRIPTION"); // or
DB2Xml db2xml = (DB2Xml) resultSet.getObject("DESCRIPTION");

you can use other methods available in java

  • getString( )
  • getBinaryStream( )
  • getCharacterStrem( )
  • getObject( )
Inserting in XML file

String sql = "INSERT INTO xmlproduct VALUES(?, ?)";
PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setString(1, "100-105-09");
File binFile = new File("productBinIn.xml");
InputStream inBin = new FileInputStream(xmlFile);
stmt.setBinaryStream(2, inBin, (int) binFile.getLength());
stmt.execute();



all you need is the db2 drivers you can find it here

https://www14.software.ibm.com/webapp/iwm/web/preLogin.do?lang=en_US&source=swg-dm-db2jdbcdriver


Sunday, March 25, 2007

Transparent Window Looking Better

Thanks to Eric Bruke's blog entry i got to know the problems in the problem with the Transparent window so here are the tweaks remove the threading part from the program but that might affect the speed of processing of your computer so copy and use the following alternative code thraeding still involved but a few minor changes like i changed the refresh period and the quickRrefresh() that was put there as a comment, i removed the coments.The new improved code and replaces refresh() in "public void run()" with quickRefresh()
here is the improved code:

import java.awt.*;
import java.util.Date;
import javax.swing.*;
import java.awt.event.*;
public class BGTest1 {

public static void main(String[] args) {
JFrame frame = new JFrame("Transparent Window");
TransparentBackground bg = new TransparentBackground(frame);
bg.setLayout(new BorderLayout());

JButton button = new JButton("This is a button");
bg.add("North",button);
JLabel label = new JLabel("This is a label");
bg.add("South",label);
frame.getContentPane().add("Center",bg);
frame.pack();
frame.setSize(300,300);
frame.show();
}

}
class TransparentBackground extends JComponent
implements ComponentListener, WindowFocusListener,
Runnable {
private JFrame frame;
protected Image background;
private long lastupdate = 0;
public boolean refreshRequested = true;

public TransparentBackground(JFrame frame) {
this.frame = frame;

updateBackground();
frame.addComponentListener(this);
frame.addWindowFocusListener(this);
new Thread(this).start();
}

public void updateBackground() {
try {
Robot rbt = new Robot();
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dim = tk.getScreenSize();
background = rbt.createScreenCapture(
new Rectangle(0,0,(int)dim.getWidth(),(int)dim.getHeight()));
} catch (Exception ex) {
p(ex.toString());
ex.printStackTrace();
}
}

public void paintComponent(Graphics g) {
Point pos = this.getLocationOnScreen();
Point offset = new Point(-pos.x,-pos.y);
g.drawImage(background,offset.x,offset.y,null);
}


public void componentShown(ComponentEvent evt) { repaint(); }
public void componentResized(ComponentEvent evt) { repaint(); }
public void componentMoved(ComponentEvent evt) { repaint(); }
public void componentHidden(ComponentEvent evt) { }

public void windowGainedFocus(WindowEvent evt) { refresh(); }
public void windowLostFocus(WindowEvent evt) { refresh(); }

public void refresh() {
if(this.isVisible() && frame.isVisible()) {
repaint();
refreshRequested = true;
lastupdate = new Date().getTime();
}
}


private boolean recurse = false;
public void quickRefresh() {
p("quick refresh");
long now = new Date().getTime();
if(recurse ||
((now - lastupdate) < recurse =" true;" location =" frame.getLocation();" recurse =" false;" lastupdate =" now;" now =" new"> 5)) {
if(frame.isVisible()) {
Point location = frame.getLocation();
frame.hide();
updateBackground();
frame.show();
frame.setLocation(location);
quickRefresh();
}
lastupdate = now;
refreshRequested = false;
}
}
} catch (Exception ex) {
p(ex.toString());
ex.printStackTrace();
}
}


public static void p(String str) {
System.out.println(str);
}

}

Get The Best Java Books In One Place

I have complied together the best of the best java reference books and the related books available today.It is to help all the developers get the maximum with minimum efforts.Hope that you like my compilation....

Here is the link to the site:

http://astore.amazon.com/javcra-20

below is the preview.Enjoy!!!!! ;-)


Create A Transparent Window in Java

I recently read a post the read Another Thing Java Cannot Do In Java. And it read:
"you cannot create a popup window shaped like this:

Thought Bubble

Because Java does not support transparent windows"

Well here is a cool code to create "Transparent Window" in java.For more you can go in for this awesome book Swing Hacks by Joshua Marinnaci it is the best book with many more awesome tricks i have a copy and recommend to everyone(a must buy for those who are seriously interested in java)

import java.awt.*;
import java.util.Date;
import javax.swing.*;
import java.awt.event.*;
public class BGTest1 {

public static void main(String[] args) {
JFrame frame = new JFrame("Transparent Window");
TransparentBackground bg = new TransparentBackground(frame);
bg.setLayout(new BorderLayout());

JButton button = new JButton("This is a button");
bg.add("North",button);
JLabel label = new JLabel("This is a label");
bg.add("South",label);
frame.getContentPane().add("Center",bg);
frame.pack();
frame.setSize(300,300);
frame.show();
}

}
class TransparentBackground extends JComponent
implements ComponentListener, WindowFocusListener,
Runnable {
private JFrame frame;
protected Image background;
private long lastupdate = 0;
public boolean refreshRequested = true;

public TransparentBackground(JFrame frame) {
this.frame = frame;

updateBackground();
frame.addComponentListener(this);
frame.addWindowFocusListener(this);
new Thread(this).start();
}

public void updateBackground() {
try {
Robot rbt = new Robot();
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dim = tk.getScreenSize();
background = rbt.createScreenCapture(
new Rectangle(0,0,(int)dim.getWidth(),(int)dim.getHeight()));
} catch (Exception ex) {
p(ex.toString());
ex.printStackTrace();
}
}

public void paintComponent(Graphics g) {
Point pos = this.getLocationOnScreen();
Point offset = new Point(-pos.x,-pos.y);
g.drawImage(background,offset.x,offset.y,null);
}


public void componentShown(ComponentEvent evt) { repaint(); }
public void componentResized(ComponentEvent evt) { repaint(); }
public void componentMoved(ComponentEvent evt) { repaint(); }
public void componentHidden(ComponentEvent evt) { }

public void windowGainedFocus(WindowEvent evt) { refresh(); }
public void windowLostFocus(WindowEvent evt) { refresh(); }

public void refresh() {
if(this.isVisible() && frame.isVisible()) {
repaint();
refreshRequested = true;
lastupdate = new Date().getTime();
}
}

/*
private boolean recurse = false;
public void quickRefresh() {
p("quick refresh");
long now = new Date().getTime();
if(recurse ||
((now - lastupdate) < recurse =" true;" location =" frame.getLocation();" recurse =" false;" lastupdate =" now;" now =" new"> 1000)) {
if(frame.isVisible()) {
Point location = frame.getLocation();
frame.hide();
updateBackground();
frame.show();
frame.setLocation(location);
refresh();
}
lastupdate = now;
refreshRequested = false;
}
}
} catch (Exception ex) {
p(ex.toString());
ex.printStackTrace();
}
}


public static void p(String str) {
System.out.println(str);
}

}

here is the link to the book again

a must buy for those who are seriously interested in java

Saturday, March 24, 2007

Put Icon On Your Jar File

This new project named DJ Project enables the windows based users to replicate the typical Mac users' actions of treating their jar files as "executable program" placing icons on them similar to the Exe files in java.Well this project out here enables the users to customize thier choice of jar files and allows them to make them like as though they were exe files.This is a good shell modification but only meant for Windows and not any other OperatingSystem.

The above pic shows shows how the jar files will look after the shell modification done by DJ Project. You can Download it here

Nimbus Look And Feel Revealed

Jasper Potts has put together the components of the cool new and Nimbus Look and feel,this L&F looks promising is am sure is all set to change the historical appearance of the java apps.This will now be substituting the older metal look and feel(L&F) as the new more crazier and wackier
(Awesome Looking)cross platform L&F for java.A little preview of the Focused Components in Nimbus.For more you can go here


Thursday, March 22, 2007

Filthy Rich Clients Now available on Amazon.com


Finally my much awaited book Filthy Rich Client is about to roll out and i will register for pre-release soon......

The book is co-authored by my favorite Java developer Romain Guy........He is my inspiration!!!

I really can’t wait to get a final printed copy!

This made me jump out of my seat!

I received this mail with the senders name -"codesite-noreply"-confusing name no?!
Will this was the mail responsible for making me jump out of my chair!!!!!!

well here's what it read-"
Dear Ashish Lijhara,
The Application "NYou Tube-this what i propose" has been updated by Patrick W. Barnes. To see this new addition please go to"and then link to my fedora application request which left my mouth wide open

well here is the resopnse-"
Patrick W. Barnes
This sounds like a neat project, but YouTube requires proprietary technologies (Flash) that are not FOSS and cannot, by policy, be included in Fedora. We also do not include the Sun Java implementation, only the FOSS GCJ stack, which may not be suitable for your project. You should consider submitting this proposal to another organization."

Well this guy Patrick,said what i wanted to listen to in the first line itself"This sounds like a neat project"!!!!!!

Seriously i am happy!!!!!
Atleast now i expect that some other mentoring organization might just like it........I can finally see some ray of hope........

Wednesday, March 21, 2007

Proposal to GSOC 2007

I have taken my initial step towards being noticed in the Google summer of code yesterday.I had already registered but now i have posted my proposal for "NYou Tube" to around 6 organizations including the Google,Ubuntu,The Apache Project and Mozilla organization.Now i am waiting for them to review my proposal.

I posted my proposal yesterday and had included that i will put in one more feature which is the chat feature........Yeah you read it right!!!!!The chat feature but this is subjected to time constraint if i have time in plenty i will also put in google maps api or yahoo map api to use that will locate the position of your friends all over the world.
It will also include the Voip feature powered by for java.

the above features are subjected to time constraint.If not able to add these features i will add atleast the chat feature.All the above features will appear in the subsequent versions and this is a promise.

But if not selected in GSOC these features will surely reflect in the first version itself.........

Still hoping to get selected in GSOC.

My Proposal For GSOC

Well this is the first post ever in my life.

This being upon my longing for working under the open source environment putting into use the Google Api for youtube.I'll be using Java to develop it so guys nothing to bother about will run on any operating system in the world!!!!

I want to start this under the well known Google Sumer Of Code that is propelling the Developers to go open source.

The Application(software) i propose to build will be named "NYou Tube".This will allow the youtube users to access(all the videos,their quick lists,fav. videos,friends,uploads,etc)from the application itself making it an easier task to blog/share their video creation with the friends,family and the world!!!

I am posting the raw images of what it would look like the images are only a sort of a map of the final application.
this will be the window.The place where i propose to put player will embed a web browser and preferably firefox or the native browser the will embed the swf player from youtube and the page will be refreshed each time another video is selected.As i said this is just a map so nothing is clear of the final thing i have in mind but keep checking out my blog for the things to come .....wait i am not over yet !!!!!!




Here is an itunes style video selection that will roll down as a dilog box and the base(host/parent)
window will be blur disabled and after the thumbnails are loaded,the components will drop down which i will borrow from an application provided by Simon Morris shown here:


The above application has put java to awesome use!!!!I simply love it......

Well continuing with the dilog box(video selection dilog) here is the image of what it would look like:
I will use the best looking look and feels in the software.....will also add a feature to customize skins(later may not be in the first version but will be present in the subsequent versions)
Well,i hope you like my idea!
I simply hope i get selected at the Google Summer Of Code!!!!!But you need not worry selected or not i will develop this software and it will be open source....

Please pray for me that i get selected!!! ;-)