Hi friends,
- FlowLayout
- BorderLayout
- GridLayout
- GridBagLayout
- Card Layout
- Null Layout or Absolute Positioning.
- BoxLayout
- GroupLayout
- OverlayLayout
- SpringLayout
- ScrollPaneLayout
- ViewPortLayout
Hi friends,
Hello Friends,
/*
* Program for setting single instance in JAVA
* Copyright 2009 @ yuvadeveloper
* Code By:- Prashant Chandrakar
*
*/
import java.net.ServerSocket;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import java.io.IOException;
import java.net.BindException;
class SingleInstance
{
public static ServerSocket serverSocket;
public static String errortype = "Access Error";
public static String error = "Application already running.....";
public static void main(String as[])
{
try
{
//creating object of server socket and bind to some port number
serverSocket = new ServerSocket(15486);
////do not put common port number like 80 etc.
////Because they are already used by system
JFrame jf = new JFrame();
jf.setVisible(true);
jf.setSize(200, 200);
}
catch (BindException exc)
{
JOptionPane.showMessageDialog(null, error, errortype, JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
catch (IOException exc)
{
JOptionPane.showMessageDialog(null, error, errortype, JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
}
}
Hi Everyone,
Hi,
/*
* Program for Converting Image Object to BufferedImage Object
* Copyright 2009 @ yuvadeveloper
* Code By:- Prashant Chandrakar
*
*/
import java.awt.*;
import java.awt.image.*;
class Convert
{
public static void main(String as[])
{
////opening image in Image Object
Image img = Toolkit.getDefaultToolkit().getImage("test.jpeg");
////taking dimension of image
int width = img.getWidth(null);
int height = img.getHeight(null);
////creating a bufferedImage object of same dimension as image
BufferedImage bimg = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
////taking graphics object from BufferedImage
Graphics2D gg = bimg.createGraphics();
////drawing Image objects image into graphics of buffered image object
gg.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null), null);
///disposing graphics.
gg.dispose();
}
}
/*
* Program for Highlighting a particular portion of image in any color
* Copyright 2009 @ yuvadeveloper
* Code By:- Prashant Chandrakar
*
*/
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
class HighlightImage
{
public static void main(String a[])
{
try
{
////pass image file path open for drawing
BufferedImage image = ImageIO.read(new File("1.jpg"));
////taking graphics from image
Graphics g = image.getGraphics();
////just change the transparency value for changing beta values of image
int transparency = 50;
/////drawing string on graphics of opened image
g.drawString("We are highlighting a selected portion of image", 10, 10);
Color color = new Color(255, 255, 0, 255 * transparency / 100);
g.setColor(color);
g.fillRect(30, 30, 100, 100);
////saving image by name output.jpg
ImageIO.write(image, "jpg", new File("output.jpg"));
}
catch (Exception e)
{
System.out.println(e);
}
}
}
Very much interested on playing with world best technologies like java and C#.Wants to fill the gap between technologies. | |
View Complete Profile | |
RankSheet Profile |