Skip to main content


Showing posts from January, 2012

File and Folder Selectors in JAVA

There are basically three methods or mechanisms in java which can be used to select files or folders. These are as follow: 1) JFileChooser  : JFileChooser provides a simple mechanism for the user to choose a file or folder. Here is the hierarchy of JFileChoose class. java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JFileChooser   Example :    final JFrame frame = new JFrame(); JFileChooser chooser = new JFileChooser();   //If you want any folder or files to be selected by default use this //JFileChooser chooser = new JFileChooser("C:\\Users\\sshankar\\Desktop\\ftp"); //To select only folders use this //chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);  //Code to select files of a particular extensions ExampleFileFilter filter = new ExampleFileFilter(); filter.addExtension("jpg"); filter.addExtension("gif"); filter.setDescription("JP

Relative vs Absolute positioning in CSS

An important concept to understand first is that every single element on a web page is a block. Literally a rectangle of pixels. This is easy to understand when when you set the element to display: block; or if that element is by default display: block; This means you can set a width and a height and that element will respect that. But elements that are display: inline, like a span by default, are also rectangles, they just flow onto the page different, lining up horizontally as they can. Now that you are picturing every single page element as a block of pixels, we can talk about how positioning is used to get the blocks of pixels exactly where you want them to go. We're going to leave off any discussion of the box model, but that factors into this as well... There is four type of positioning in CSS Static   This is the default for every single page element. Different elements don't have different default values for positioning, they all start out as static.

How Regular Expression works in PHP?

Regular Expression, commonly known as RegEx is considered to be one of the most complex concepts. However, this is not really true. Unless you have worked with regular expressions before, when you look at a regular expression containing a sequence of special characters like /, $, ^, \, ?, *, etc., in combination with alphanumeric characters, you might think it a mess. RegEx is a kind of language and if you have learnt its symbols and understood their meaning, you would find it as the most useful tool in hand to solve many complex problems related to text searches and validations. Basic Syntax of Regular Expressions First of all, let's take a look at two special symbols: '^' and '$' . What they do is indicate the start and the end of a string, respectively, like this: " ^The ": matches any string that starts with "The"; " of despair$ ": matches a string that ends in the substring "of despair"