Friday 22 March 2013

How To Create Look And Feel in java

package lookandfeel; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.plaf.metal.*; public class LookAndFeelDemo implements ActionListener { private static String labelPrefix = "Number of button clicks: "; private int numClicks = 0; final JLabel label = new JLabel(labelPrefix + "0 "); // Specify the look and feel to use by defining the LOOKANDFEEL constant // Valid values are: null (use the default), "Metal", "System", "Motif", // and "GTK" final static String LOOKANDFEEL = "Metal"; // If you choose the Metal L&F, you can also choose a theme. // Specify the theme to use by defining the THEME constant // Valid values are: "DefaultMetal", "Ocean", and "Test" final static String THEME = "Test"; public Component createComponents() { JButton button = new JButton("I'm a Swing button!"); button.setMnemonic(KeyEvent.VK_I); button.addActionListener(this); label.setLabelFor(button); /* * An easy way to put space between a top-level container * and its contents is to put the contents in a JPanel * that has an "empty" border. */ JPanel pane = new JPanel(new GridLayout(0, 1)); pane.add(button); pane.add(label); pane.setBorder(BorderFactory.createEmptyBorder( 30, //top 30, //left 10, //bottom 30) //right ); return pane; } public void actionPerformed(ActionEvent e) { numClicks++; label.setText(labelPrefix + numClicks); } private static void initLookAndFeel() { String lookAndFeel = null; if (LOOKANDFEEL != null) { if (LOOKANDFEEL.equals("Metal")) { lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName(); // an alternative way to set the Metal L&F is to replace the // previous line with: // lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel"; } else if (LOOKANDFEEL.equals("System")) { lookAndFeel = UIManager.getSystemLookAndFeelClassName(); } else if (LOOKANDFEEL.equals("Motif")) { lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; } else if (LOOKANDFEEL.equals("GTK")) { lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; } else { System.err.println("Unexpected value of LOOKANDFEEL specified: " + LOOKANDFEEL); lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName(); } try { UIManager.setLookAndFeel(lookAndFeel); // If L&F = "Metal", set the theme if (LOOKANDFEEL.equals("Metal")) { if (THEME.equals("DefaultMetal")) MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); else if (THEME.equals("Ocean")) MetalLookAndFeel.setCurrentTheme(new OceanTheme()); else MetalLookAndFeel.setCurrentTheme(new TestTheme()); UIManager.setLookAndFeel(new MetalLookAndFeel()); } } catch (ClassNotFoundException e) { System.err.println("Couldn't find class for specified look and feel:" + lookAndFeel); System.err.println("Did you include the L&F library in the class path?"); System.err.println("Using the default look and feel."); } catch (UnsupportedLookAndFeelException e) { System.err.println("Can't use the specified look and feel (" + lookAndFeel + ") on this platform."); System.err.println("Using the default look and feel."); } catch (Exception e) { System.err.println("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason."); System.err.println("Using the default look and feel."); e.printStackTrace(); } } } private static void createAndShowGUI() { //Set the look and feel. initLookAndFeel(); //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window. JFrame frame = new JFrame("SwingApplication"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); LookAndFeelDemo app = new LookAndFeelDemo(); Component contents = app.createComponents(); frame.getContentPane().add(contents, BorderLayout.CENTER); //Display the window. frame.pack(); frame.setVisible(true); } public static void main(String[] args) { //Schedule a job for the event dispatch thread: //creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); }

Monday 4 March 2013

C Language Basics

Doubly Linked List Program /*doubly linked List*/ #include #include #include struct node { int no; struct node *next; struct node *prev; }; /* delete at the given location*/ void deletenode(struct node **q,int num) { /*Deleting Node Strategy: First:Check IF it is not null if node found check wheather first element or last lement then delete node else make copy at temp of previous node move forward */ struct node *s,*temp; s=*q; while(s!=NULL) { if(s->no==num) { if(s==*q) { //Directly deal with original node and move to next (*q)=(*q)->next; //s->prev=NULL; break; } else { temp->next=s->next; s->next->prev=temp; break; } if(s->next==NULL) { free(s); s=temp; break; } } else { temp=s; s=s->next; } } } void append(struct node **q,int num) { struct node *s,*newnode; s=*q; if(*q==NULL) { printf("Inserting First eeLEMENT"); *q=(struct node*)malloc(sizeof(struct node*)); (*q)->no=num; (*q)->next=NULL; (*q)->prev=NULL; } else { while(s->next!=NULL) { s=s->next; } newnode=(struct node*)malloc(sizeof(struct node*)); newnode->no=num; newnode->next=NULL; s->next=newnode; } } void print(struct node *s) { printf("\n\tPrinting..."); while(s!=NULL) { printf("\t%d",s->no); s=s->next; } } void main() { struct node *s; s=NULL; clrscr(); append(&s,5); append(&s,67); append(&s,57); printf("\n\tBefore"); print(s); deletenode(&s,5); printf("\n\tAfter..."); print(s); getch(); }

Thursday 28 February 2013

HI This is how we can connect modem on the backtrack4r2

Step1) type in terminal 
 sudo start -network
sudeo stop -network //to stop the net connection

Step 2)
Now goto
start->internet->Wicd network manager
Connect from the available options.
To configure click on advanced tab of your connection.
type your wep/wap key


step3) Update the backtrack
sudo atp -get update

Second method most simple one
    COntrol panel -------------------->Network and internet------->
INternet and connection

Control Panel\Network and Internet\Network and Sharing Center
Then

Click on change adapter settings

click on your modem connection icon ->Sharing tab->click on 

check Allow other network users to connnect through this computer network connection.
1.  on combobox of Home network connection
select from list  on vmware network adapter vmnet8

It may be anything vmnet1 vmnet2

2.  click on check Allow other users to connect and control this network connection

click on ok you r all done

Tuesday 5 February 2013

Begining With vb.net


Module Module1
    Sub Main()
 ' Create List.
 Dim list As List(Of String) = New List(Of String)'list is a data type Of 'string means the list ois of type String
 list.Add("dot")
 list.Add("perls")
 list.Add("net")
 ' Sort List.
 list.Sort()'inbuilt sort method will sort elements
 ' Display sorted List contents.
 Console.WriteLine(String.Join(" ", list))
    End Sub
End Module
---------------------------------------------------------
Module Module1
    Sub Main()
 ' Create Dictionary.
 Dim dict As Dictionary(Of String, Integer) =
     New Dictionary(Of String, Integer)
 dict.Add("dot", 1)
 dict.Add("net", 2)
 dict.Add("perls", 3)
 ' Lookups.
 Console.WriteLine(dict("dot"))
 Console.WriteLine(dict("net"))
 Console.WriteLine(dict("perls"))
    End Sub
End Module
--------------------------------------------------------------------
'Stack implementaion in vb.net.
'he khup simple ahe
Module Module1
    Sub Main()'just like main() in the c language
 Dim stack As Stack(Of Integer) = New Stack(Of Integer)
 stack.Push(10)
 stack.Push(100)
 stack.Push(1000)

 ' Display stack elements.
 For Each value As Integer In stack 
'for each mean every element will be iterated for all stack elements .
'just like for in C,but with small diffrrence
     Console.WriteLine(value)
 Next
    End Sub
End Module
-----------------------------
'The StringBuilder class is used to append the strings
Imports System.Text

Module Module1
    Sub Main()
 ' Declare new StringBuilder Dim
 Dim builder As New StringBuilder

 ' Append a string to the StringBuilder
 builder.Append("Here is the list:")

 ' Append a line break
 builder.AppendLine()

 ' Append a string and then another line break
 builder.Append("1 dog").AppendLine()

 ' Get internal String value from StringBuilder
 Dim s As String = builder.ToString

 ' Write output
 Console.WriteLine(s)
 Console.ReadLine()
    End Sub
End Module
------------------------------------
'buider replace()
Imports System.Text

Module Module1
    Sub Main()
 Dim builder As New StringBuilder("Initialize the StringBuilder.")
 builder.Replace("the", "my")

 Console.WriteLine(builder.ToString)
 Console.ReadLine()
    End Sub
End Module
-----------------------------------------------------
'The Html file writen at runtime through this
Imports System.IO
Imports System.Web.UI
Imports System.IO
Imports System.Web.UI

Module Module1
    Dim _words As String() = {"dot", "net", "perls"}

    Function GetDivElements() As String
 Using sw As StringWriter = New StringWriter
     Using ht As HtmlTextWriter = New HtmlTextWriter(sw)
  For Each word As String In _words

      ' Create the div.
      ht.AddAttribute(HtmlTextWriterAttribute.Class, "c")
      ht.RenderBeginTag(HtmlTextWriterTag.Div)

      ' Create the a.
      ht.AddAttribute(HtmlTextWriterAttribute.Href, word)
      ht.RenderBeginTag(HtmlTextWriterTag.A)

      ' Create the img.
      ht.AddAttribute(HtmlTextWriterAttribute.Src, word + ".png")
      ht.AddAttribute(HtmlTextWriterAttribute.Width, "200")
      ht.AddAttribute(HtmlTextWriterAttribute.Height, "150")
      ht.RenderBeginTag(HtmlTextWriterTag.Img)

      ' End all the tags.
      ht.RenderEndTag()
      ht.RenderEndTag()
      ht.RenderEndTag()
  Next
     End Using
     Return sw.ToString()
 End Using
    End Function

    Sub Main()
 Console.WriteLine(GetDivElements())
    End Sub

End Module
'output

<div class="c">
 <a href="dot"><img src="dot.png" width="200" height="150" /></a>
</div><div class="c">
 <a href="net"><img src="net.png" width="200" height="150" /></a>
</div><div class="c">
 <a href="perls"><img src="perls.png" width="200" height="150" /></a>
</div>
----------------------------------------------------------
Module Module1
    Sub Main()
 ' Locals used in Do While loop.
 Dim i As Integer = 100
 Dim z As Integer = 0

 ' Loop.
 Do While i >= 0 And z <= 20
     Console.WriteLine("i = {0}, z = {1}", i, z)
     i = i - 10
     z = z + 3
 Loop
    End Sub
End Module
------------------------------------------------------
'sqauare root 
Module Module1
    REM This is Module1.

    ''' <summary>
    ''' This is an XML comment.
    ''' </summary>
    ''' <remarks>Called at program start.</remarks>
    Sub Main()
 REM Get square root of 225.
 Dim value As Double = Math.Sqrt(225)

 ' Print value. (Other comment syntax.)
 ' ... Sometimes it helps to indent comments.
 Console.WriteLine(value)
    End Sub
End Module
-----------------------
'date
Module Module1
    Sub Main()
 ' Write the today value.
 Console.WriteLine("Today: {0}", DateTime.Today)
 ' Subtract one day.
 Dim yesterday As DateTime = DateTime.Today.AddDays(-1)
 ' Write the yesterday value.
 Console.WriteLine("Yesterday: {0}", yesterday)
    End Sub
End Module
'
Module Module1
    Sub Main()
 ' Write first day of current year.
 Console.WriteLine("First day: {0}", FirstDayOfYear)
 ' Write first day of 1999.
 Dim y As New DateTime(1999, 6, 1)
 Console.WriteLine("First day of 1999: {0}", FirstDayOfYear(y))
    End Sub

    ''' <summary>
    ''' Get first day of the current year.
    ''' </summary>
    Private Function FirstDayOfYear() As DateTime
 Return FirstDayOfYear(DateTime.Today)
    End Function

    ''' <summary>
    ''' Get first day of the specified year.
    ''' </summary>
    Private Function FirstDayOfYear(ByVal y As DateTime) As DateTime
 Return New DateTime(y.Year, 1, 1)
    End Function
----------------------------
Windows Application in vb.net
Module Module1
    Sub Main()
 ' Write first day of current year.
 Console.WriteLine("First day: {0}", FirstDayOfYear)
 ' Write first day of 1999.
 Dim y As New DateTime(1999, 6, 1)
 Console.WriteLine("First day of 1999: {0}", FirstDayOfYear(y))
    End Sub

    ''' <summary>
    ''' Get first day of the current year.
    ''' </summary>
    Private Function FirstDayOfYear() As DateTime
 Return FirstDayOfYear(DateTime.Today)
    End Function

    ''' <summary>
    ''' Get first day of the specified year.
    ''' </summary>
    Private Function FirstDayOfYear(ByVal y As DateTime) As DateTime
 Return New DateTime(y.Year, 1, 1)
    End Function
====================================================
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles MyBase.Load
 '
 ' Fill in the data grid on form load.
 '
 DataGridView1.DataSource = GetDataTable()
    End Sub

    Private Function GetDataTable() As DataTable
 '
 ' This Function needs to build the data table.
 '
 Return New DataTable()
    End Function
End Class
========================================
'regexfor expression matching
Imports System.Text.RegularExpressions

Module Module1
    Sub Main()
 ' Input string.
 Dim input As String = "Dot Net Not Perls"
 ' Use Regex.Replace with string arguments.
 Dim output As String = Regex.Replace(input, "N.t", "NET")
 ' Print.
 Console.WriteLine(input)
 Console.WriteLine(output)
    End Sub
End Module

Begining With vb.net


Module Module1
    Sub Main()
	' Create List.
	Dim list As List(Of String) = New List(Of String)'list is a data type Of 'string means the list ois of type String
	list.Add("dot")
	list.Add("perls")
	list.Add("net")
	' Sort List.
	list.Sort()'inbuilt sort method will sort elements
	' Display sorted List contents.
	Console.WriteLine(String.Join(" ", list))
    End Sub
End Module
---------------------------------------------------------
Module Module1
    Sub Main()
	' Create Dictionary.
	Dim dict As Dictionary(Of String, Integer) =
	    New Dictionary(Of String, Integer)
	dict.Add("dot", 1)
	dict.Add("net", 2)
	dict.Add("perls", 3)
	' Lookups.
	Console.WriteLine(dict("dot"))
	Console.WriteLine(dict("net"))
	Console.WriteLine(dict("perls"))
    End Sub
End Module
--------------------------------------------------------------------
'Stack implementaion in vb.net.
'he khup simple ahe
Module Module1
    Sub Main()'just like main() in the c language
	Dim stack As Stack(Of Integer) = New Stack(Of Integer)
	stack.Push(10)
	stack.Push(100)
	stack.Push(1000)

	' Display stack elements.
	For Each value As Integer In stack 
'for each mean every element will be iterated for all stack elements .
'just like for in C,but with small diffrrence
	    Console.WriteLine(value)
	Next
    End Sub
End Module
-----------------------------
'The StringBuilder class is used to append the strings
Imports System.Text

Module Module1
    Sub Main()
	' Declare new StringBuilder Dim
	Dim builder As New StringBuilder

	' Append a string to the StringBuilder
	builder.Append("Here is the list:")

	' Append a line break
	builder.AppendLine()

	' Append a string and then another line break
	builder.Append("1 dog").AppendLine()

	' Get internal String value from StringBuilder
	Dim s As String = builder.ToString

	' Write output
	Console.WriteLine(s)
	Console.ReadLine()
    End Sub
End Module
------------------------------------
'buider replace()
Imports System.Text

Module Module1
    Sub Main()
	Dim builder As New StringBuilder("Initialize the StringBuilder.")
	builder.Replace("the", "my")

	Console.WriteLine(builder.ToString)
	Console.ReadLine()
    End Sub
End Module
-----------------------------------------------------
'The Html file writen at runtime through this
Imports System.IO
Imports System.Web.UI
Imports System.IO
Imports System.Web.UI

Module Module1
    Dim _words As String() = {"dot", "net", "perls"}

    Function GetDivElements() As String
	Using sw As StringWriter = New StringWriter
	    Using ht As HtmlTextWriter = New HtmlTextWriter(sw)
		For Each word As String In _words

		    ' Create the div.
		    ht.AddAttribute(HtmlTextWriterAttribute.Class, "c")
		    ht.RenderBeginTag(HtmlTextWriterTag.Div)

		    ' Create the a.
		    ht.AddAttribute(HtmlTextWriterAttribute.Href, word)
		    ht.RenderBeginTag(HtmlTextWriterTag.A)

		    ' Create the img.
		    ht.AddAttribute(HtmlTextWriterAttribute.Src, word + ".png")
		    ht.AddAttribute(HtmlTextWriterAttribute.Width, "200")
		    ht.AddAttribute(HtmlTextWriterAttribute.Height, "150")
		    ht.RenderBeginTag(HtmlTextWriterTag.Img)

		    ' End all the tags.
		    ht.RenderEndTag()
		    ht.RenderEndTag()
		    ht.RenderEndTag()
		Next
	    End Using
	    Return sw.ToString()
	End Using
    End Function

    Sub Main()
	Console.WriteLine(GetDivElements())
    End Sub

End Module
'output

<div class="c">
	<a href="dot"><img src="dot.png" width="200" height="150" /></a>
</div><div class="c">
	<a href="net"><img src="net.png" width="200" height="150" /></a>
</div><div class="c">
	<a href="perls"><img src="perls.png" width="200" height="150" /></a>
</div>
----------------------------------------------------------
Module Module1
    Sub Main()
	' Locals used in Do While loop.
	Dim i As Integer = 100
	Dim z As Integer = 0

	' Loop.
	Do While i >= 0 And z <= 20
	    Console.WriteLine("i = {0}, z = {1}", i, z)
	    i = i - 10
	    z = z + 3
	Loop
    End Sub
End Module
------------------------------------------------------
'sqauare root 
Module Module1
    REM This is Module1.

    ''' <summary>
    ''' This is an XML comment.
    ''' </summary>
    ''' <remarks>Called at program start.</remarks>
    Sub Main()
	REM Get square root of 225.
	Dim value As Double = Math.Sqrt(225)

	' Print value. (Other comment syntax.)
	' ... Sometimes it helps to indent comments.
	Console.WriteLine(value)
    End Sub
End Module
-----------------------
'date
Module Module1
    Sub Main()
	' Write the today value.
	Console.WriteLine("Today: {0}", DateTime.Today)
	' Subtract one day.
	Dim yesterday As DateTime = DateTime.Today.AddDays(-1)
	' Write the yesterday value.
	Console.WriteLine("Yesterday: {0}", yesterday)
    End Sub
End Module
'
Module Module1
    Sub Main()
	' Write first day of current year.
	Console.WriteLine("First day: {0}", FirstDayOfYear)
	' Write first day of 1999.
	Dim y As New DateTime(1999, 6, 1)
	Console.WriteLine("First day of 1999: {0}", FirstDayOfYear(y))
    End Sub

    ''' <summary>
    ''' Get first day of the current year.
    ''' </summary>
    Private Function FirstDayOfYear() As DateTime
	Return FirstDayOfYear(DateTime.Today)
    End Function

    ''' <summary>
    ''' Get first day of the specified year.
    ''' </summary>
    Private Function FirstDayOfYear(ByVal y As DateTime) As DateTime
	Return New DateTime(y.Year, 1, 1)
    End Function
----------------------------
Windows Application in vb.net
Module Module1
    Sub Main()
	' Write first day of current year.
	Console.WriteLine("First day: {0}", FirstDayOfYear)
	' Write first day of 1999.
	Dim y As New DateTime(1999, 6, 1)
	Console.WriteLine("First day of 1999: {0}", FirstDayOfYear(y))
    End Sub

    ''' <summary>
    ''' Get first day of the current year.
    ''' </summary>
    Private Function FirstDayOfYear() As DateTime
	Return FirstDayOfYear(DateTime.Today)
    End Function

    ''' <summary>
    ''' Get first day of the specified year.
    ''' </summary>
    Private Function FirstDayOfYear(ByVal y As DateTime) As DateTime
	Return New DateTime(y.Year, 1, 1)
    End Function
====================================================
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, _
			   ByVal e As System.EventArgs) Handles MyBase.Load
	'
	' Fill in the data grid on form load.
	'
	DataGridView1.DataSource = GetDataTable()
    End Sub

    Private Function GetDataTable() As DataTable
	'
	' This Function needs to build the data table.
	'
	Return New DataTable()
    End Function
End Class

Saturday 10 November 2012

Duty Of Every INDiAn


Use
Avoid
  • Saving Cream - Godrej, Emani,MAnkind

  • Saving Cream - Palmolive, Old Spice, Gillete,AXE

  • Blade - Supermax, Topaz, Lazer, Ashoka

  • Seven o Clock, 365, Gillette
      
  • Talcum Powder - Santoor, Gokul, Cinthol, Wipro baby power, Boroplus

  • Talcom Powder - Ponds, Old spice, Johnson baby powder, shower to shower.

  • Milk Powder - Indiana, Amul, Amulya

  • Milk Powder - Anikspray, Milkana, Everyday milk, Milkmaid
         Tropicana,Minute maid
  • Shampoo - Lakme, Nirma, Velvet

  • Shampoo - Halo, All clear, Nyle, Sunsilk, Head and shoulders, Pantene

  • Mobile Connections - BSNL, Airtel
Pen-Camlin,Flair
  • Mobile Connections - Hutch
truely indiaN companies-http://en.wikipedia.org/wiki/Dabur
patanjali 
Every Indian product you buy makes a big difference. It saves India. Let us take a frim decision to day.
We are not Multinational.
Multinationals call it Globalisation of Indian economy. For Indians like you and me, it is Recolonisation of India.
Please remember: Political freedom is useless without economic Independence!
Russia, S.Korea, Mexico.... The list is very long!!
So give up at least one item to for the sake of our Country.
Pl. forward this site to your friends to create awareness.
"LITTLE DROPS MAKE A GREAT OCEAN."
SAVE OUR INDIAN ECONOMY NOW ITS IN YOUR HAND
PLEASE THINK OVER



Automotive





Conglomerates





§  Godrej


§  ITC







§  RPG Group

§  JSW Group




§  Videocon
Construction

§  HCC
Consumer goods
§   

§  Nirma

Energy and natural resources





§  NTPC

§  ONGC



Healthcare and pharmaceutical


§  Cipla

§  Dabur


Heavy industry


§  BHEL


§  SAIL



§  Hindalco
Information technology
§  HCL

§  Infosys



§  Wipro
Media

Retail

Telecommunications
§  Airtel

§  BSNL




Other

§  DLF