Archive for the ‘Programming’ Category

How to deploy WAR/JAR File in JBOSS

Step to deploy WAR/JAR File in JBOSS

  • Paste your WAR/JAR File into jboss\server\default\deploy Folder
  • Go to jboss\bin and run the file run.bat.
  • After successful run.go to jboss\server\default folder and see three new folder log,tmp,work.
  • log – Log File is created here
  • tmp – All the Deployed WAR and JAR File extacted here.
  • work – all the code in a servlet form maintain here.

Popularity: 3% [?]

Difference between String and String Buffer

String
=====
String are immutable object.Its value cannot be changed(constant).String object are readonly.If you create one instance of string and change the value of string then it create new instance.

String Buffer
=========
String Buffer is mutable.Its Value can be Changed.If you create one instance and append the text without creating a new instance

Example:
======
String
=====
String str=”welcome”;
str + = “to fordevs”;

String Buffer
=========
StringBuffer strbuff=new StringBuffer(“welcome”);
strbuff.append(“to fordevs”);

Both code give same output but Second approach much faster than first one.

Popularity: 3% [?]

How to bring the cursor to the end of text in the textbox control – WPF C#

Normally if we focus a textbox control the cursor would be in the start of the textbox.But when there is text already in the textbox it would be annoying if the cursor is in start.It would be better if the cursor is at the end of content in texbox.

Thus to position the cursor at the end of the text content of a textBox control,we have to call the select method and specify the selection start position to the length of the text and a selection length to 0.

txtExample.focus();
txtExample.Select(txtExample.Text.Length, 0);

Ref : msdn

Popularity: 8% [?]

How to find 2nd highest value in a table ?

To Find the 2nd Maximum Of Mark in a Data Set

SELECT * FROM Student a WHERE 2=(SELECT count(DISTINCT Mark)
FROM Student b WHERE a.Mark<=b.Mark)

To Find the 2nd Minimum Of Mark in a Data Set

SELECT * FROM Student a WHERE 2=(SELECT count(DISTINCT Mark)
FROM Student b WHERE a.Mark>=b.Mark)

To Find nth Maximum and Minimum

SELECT * FROM Student a WHERE n=(SELECT count(DISTINCT Mark)
FROM Student b WHERE a.Mark<=b.Mark)
SELECT * FROM Student a WHERE n=(SELECT count(DISTINCT Mark)
FROM Student b WHERE a.Mark>=b.Mark)

replace n with the corresponding number

Popularity: 5% [?]

How to Text Wrap a Label in WPF?

WPF does not allow text wrapping for label control.Thus to wrap a label with a fixed width,we have to place the TextBlock control inside the label control and set its TextWrapping property to “Wrap”.

<Label Width=”50″>
<TextBlock TextWrapping=”Wrap”> I am label with width 50</TextBlock>
</Label>

Popularity: 12% [?]

How to set border color of a panel in c#

In c# for panel there no property to set border color directly.We can only set the border style using BorderStyle.

To set the border color of a panel,

Step 1 : Set BorderStyle property to None.

Step 2 : Draw a rectangle and set the pen color in paint event of the panel

private void panelpanelbordercolor1_Paint(object sender, PaintEventArgs e)
{
  e.Graphics.DrawRectangle(Pens.Red,
  e.ClipRectangle.Left,
  e.ClipRectangle.Top,
  e.ClipRectangle.Width - 1,
  e.ClipRectangle.Height -1);
  base.OnPaint(e);
}

Source Link

Popularity: 22% [?]

How to convert from .class file to .java file in Java

Step 1: Download Java – Decompiler from

http://download.cnet.com/windows/3055-2213_4-10046809.html?tag=pdl-redir

Step 2: Install the Java – Decompiler in your PC.

Step 3: Go to All Programs –> DJ Java Decomplier –> DJ Java Decomplier.

Step 4: Select File –> Open then Choose the Class File in File Dialog box.

djopendialogjpg

Step 5: Java File is created from class File.

javafilejpg

Popularity: 7% [?]

How To Call a Button Click From Another Button in c#

If there is a requirement for calling a button click event from another button in c#, there is a easy way to do.We just need to call the PerformClick Method of the button to be fired.

private void button1_Click(object sender, EventArgs e)
{
    button2.PerformClick();
}
 
private void button2_Click(object sender, EventArgs e)
{
    System.Windows.Forms.MessageBox.Show("I am called from button1");
}

Popularity: 11% [?]

Java 1.5 features

  • Generics: provides compile-time (static) type safety for collections and eliminates the need for most typecasts (type conversion).
  • Metadata: also called annotations; allows language constructs such as classes and methods to be tagged with additional data, which can then be processed by metadata-aware utilities.
  • Autoboxing/unboxing: automatic conversions between primitive types (such as int) and primitive wrapper classes (such as integer).
  • Enumerations: the enum keyword creates a typesafe, ordered list of values (such as day.monday, day.tuesday, etc.). Previously this could only be achieved by non-typesafe constant integers or manually constructed classes (typesafe enum pattern).
  • Swing: new skinnable look and feel, called synth.
  • Var args: the last parameter of a method can now be declared using a type name followed by three dots (e.g. Void drawtext(string… Lines)). In the calling code any number of parameters of that type can be used and they are then placed in an array to be passed to the method, or alternatively the calling code can pass an array of that type.
  • Enhanced for each loop: the for loop syntax is extended with special syntax for iterating over each member of either an array or any iterable, such as the standard collection classesfix the previously broken semantics of the java memory model, which defines how threads interact through memory.
  • Automatic stub generation for rmi objects.
  • Static imports concurrency utilities in package java.util.concurrent.
  • Scanner class for parsing data from various input streams and buffers.
  • Assertions
  • StringBuilder class (in java.lang package)

Popularity: 17% [?]

Make Textbox Number Only – WPF

Coding :

private void txt_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !ValidNumeric(e.Text);
base.OnPreviewTextInput(e);
}
 
bool ValidNumeric(string str)
{
bool ret = true;
 
int l = str.Length;
for (int i = 0; i &lt; l; i++)
{
char ch = str[i];
ret &= Char.IsDigit(ch);
}
 
return ret;
}

Thanks dedjo

Popularity: 8% [?]

Designed by: Business Web Hosting | Thanks to Buy Icons, travel tips and Used Cars