Wednesday, September 22, 2010
Centering a swing window on screen
In swing or AWT, if you initialize a frame or window by default its position start from the top left corner of screen. Some time it looks odd as we are intended to see the window/frame at center of screen.
To make a window centered, we all need to set the location of window to center with respect to screen size.
There are following steps to make a window centered.
1. Get the screen size
2. Set the window/frame location by calculating it with screen size and frame size.
See the following example.
centerOnScreen Method provide the functionality to make a window centered.
To make a window centered, we all need to set the location of window to center with respect to screen size.
There are following steps to make a window centered.
1. Get the screen size
2. Set the window/frame location by calculating it with screen size and frame size.
See the following example.
centerOnScreen Method provide the functionality to make a window centered.
import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.Window; import javax.swing.JFrame; import javax.swing.JLabel; /** * * @author ujjwal soni
*
*/ public class CenteredFrameExample { JFrame frame; JLabel label; public CenteredFrameExample() { frame = new JFrame("Centered JFrame."); label = new JLabel(); frame.setSize(250, 150); frame.setPreferredSize(new Dimension(250, 150)); frame.getContentPane().add(BorderLayout.CENTER, label); centerOnScreen(frame); frame.setVisible(true); frame.pack(); } public static void main(String args[]) { CenteredFrameExample centeredFrame = new CenteredFrameExample(); String text = ""; centeredFrame.label.setText(text); } /** * Centers a window on screen. * * @param w The window to center. */ public void centerOnScreen(Window w) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); w.setLocation(screenSize.width / 2 - (w.getWidth() / 2), screenSize.height / 2 - (w.getHeight() / 2)); } }This is the centered frame...
Thats all for now....
Cheers!!!
Ujjwal Soni
Sunday, September 19, 2010
The Divine Algorithm
We can create worlds out of CAD.. Even the GOD does so.. I wonder if there is SOMEBODY who has a VERY DYNAMIC SOFTWARE with perfect blends, textures and curves.. & we r all programmed by him involoving matrix multiplications, complex calculations & a lot more things which only HE understands..
The part of HIS program which we understand, we call it SCIENCE..
& the one which is beyond the scope of SCIENCE, it is called RELIGION..
MAN=(UNDERSTOOD PROGRAM)?GOD:MAN;
The part of HIS program which we understand, we call it SCIENCE..
& the one which is beyond the scope of SCIENCE, it is called RELIGION..
MAN=(UNDERSTOOD PROGRAM)?GOD:MAN;
Tuesday, September 14, 2010
10 Best JQuery Plugin for web design & development
Hi,
Here are some more JQuery plugins which i’ve recently collected & compiled for you. Hope you’ll like it & use in you web design & devlopment works.
Details: http://www.viewsboard.com/index.php/dbo ard/viewthread/8/83
Cheers,
Ujjwal Soni
Here are some more JQuery plugins which i’ve recently collected & compiled for you. Hope you’ll like it & use in you web design & devlopment works.
Details: http://www.viewsboard.com/index.php/dbo
Cheers,
Ujjwal Soni
Monday, September 13, 2010
Rebroadcast WIFI as your own network, FROM YOUR LAPTOP
Hi,
This is an amazing software that allows you to rebroadcast WIFI as your own network from your laptop.
Check it out.
http://www.connectify.me/
Its very easy to setup and run. I tried this running on windows 7 and it all run well. :)
Cheers!!!
Ujjwal Soni
This is an amazing software that allows you to rebroadcast WIFI as your own network from your laptop.
Check it out.
http://www.connectify.me/
Its very easy to setup and run. I tried this running on windows 7 and it all run well. :)
Cheers!!!
Ujjwal Soni
Android-Notifier-Desktop
Hi,
I found really a great tool useful for phones based on Andriod. If you don't want to deal with your phone while you're at your computer, free app Android Notifier will send all your phone's call, SMS, and battery notifications to your desktop. Check out below link for more details.
Android-Notifier-Desktop
Cheers!!!
Ujjwal Soni
I found really a great tool useful for phones based on Andriod. If you don't want to deal with your phone while you're at your computer, free app Android Notifier will send all your phone's call, SMS, and battery notifications to your desktop. Check out below link for more details.
Android-Notifier-Desktop
Cheers!!!
Ujjwal Soni
Create a Portable Version of Just About Any Program
Hi,
If you're a big fan of portable applicatons, but there isn't a portable version of your favorite app out there, free app Cameyo will create one for you.
Cameyo is a free download for Windows only.
I tried it and it works really great..
Cameyo [via Freeware Genius]
Cheers!!!
Ujjwal Soni
If you're a big fan of portable applicatons, but there isn't a portable version of your favorite app out there, free app Cameyo will create one for you.
Cameyo is a free download for Windows only.
I tried it and it works really great..
Cameyo [via Freeware Genius]
Cheers!!!
Ujjwal Soni
Subscribe to:
Posts (Atom)