Tip Bank

DevX

Capture a Screenshot in Java

Use the following Java code to capture a screenshot: import java.awt.AWTException;import java.awt.Rectangle;import java.awt.Robot;import java.awt.image.BufferedImage;import java.io.File;import java.io.IOException;import javax.imageio.ImageIO;public class ScreenCapture { public static void main(String[] args) { try { Robot robot

DevX

Programatically Set or Change DataRow‘s RowState

The .NET Framework 2.0 adds a new feature: SetAdded, SetModified. You use this feature to set DataRow‘s RowState value programatically. This is applicable only when the current DataRow‘s RowState is

DevX

Create a JavaFX foreach Nested Loop

When you want to create a nested loop in JavaFX, use the foreach statement. Here’s an example that displays a circle model: import java.lang.*;import javafx.ui.*;import javafx.ui.canvas.*;Frame { centerOnScreen: true visible:

DevX

Serialize and Deserialize an Object Instance to XML

To serialize an object instance to XML, you need to use the XMLSerializer class’s Serialize method. The code snippet below demonstrates: XmlSerializer xmlSer = new XmlSerializer(objInstance.GetType());System.Text.StringBuilder sb = new System.Text.StringBuilder();System.IO.StringWriter

DevX

Build a Frame with a ScrollPane in JavaFX

What follows is a simple frame designed with the JavaFX scripting language. The frame also has a ScrollPane component. import javafx.ui.*;import javafx.ui.canvas.*;import javafx.ui.filter.*;import java.lang.System;Frame { centerOnScreen: true visible: true height:

DevX

Set the Computer’s Name Through .NET

You can set your computer’s name using the SetComputerName function, which is available in kernel32.dll: //Codeusing System.Runtime.InteropServices; [DllImport(“kernel32.dll”)] static extern bool SetComputerName(string lpComputerName); bool status = SetComputerName(“MyDen”);