awt swings

Ads
 

awt swings

View Answers

December 17, 2008 at 7:03 AM

Hi friend,

This code will be captured your image. Please implement this code.


import javax.swing.*;
import javax.imageio.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;

public class Screenshot {


public Screenshot(){
JFrame frame = new JFrame("Screen Shot Frame.");
JButton button = new JButton("Capture Screen Shot");
button.addActionListener(new MyAction());
JPanel panel = new JPanel();
panel.add(button);
frame.add(panel, BorderLayout.CENTER);
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}

public class MyAction implements ActionListener{
public void actionPerformed(ActionEvent ae){
try{
String fileName = JOptionPane.showInputDialog(null, "Enter file name : ", "Roseindia.net",1);
if (!fileName.toLowerCase().endsWith(".gif")){
JOptionPane.showMessageDialog(null, "Error: file name must end with \".gif\".","Roseindia.net", 1);
}
else{
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(new Rectangle(
Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image, "gif", new File(fileName));
JOptionPane.showMessageDialog(null, "Screen captured successfully.", "Roseindia.net", 1);
}
}
catch(Exception e){}
}
}
public static void main(String[] args) throws Exception {
Screenshot ss = new Screenshot();
}
}

------------------------------------------

Thanks.

December 17, 2008 at 11:18 PM

thank you very much sir ...

Ads









Related Tutorials/Questions & Answers:
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
SWINGS
SWINGS  WHAT ARE THE DIFFERENCES BETWEEN AWT AND SWINGS
Advertisements
How to put the logo in login form using swings/awt?
How to put the logo in login form using swings/awt?  Hi, How to put the logo in login form using swings/awt? I write the login form is working but i want to put the logo in login form plz help   Here is an example
How to set the border in header and footer from login page using swings/awt
How to set the border in header and footer from login page using swings/awt  Hi, How to set the border in header and footer from login page using swings/awt
Java swings - Swing AWT
swings - Swing AWT
awt
Java AWT Applet example  how to display data using JDBC in awt/applet
awt
JDBC and AWT to display data  how to display data using JDBC in awt/applet
awt
JDBC in awt applet  how to display data using JDBC in awt/applet
awt
JDBC in awt  how to display data using JDBC in awt/applet
JSP & Swings
JSP & Swings  How to integrate jsp and swings
swings question
swings question  how to change the background color with the help of color values by using swings
awt in java
awt in java  using awt in java gui programming how to false the maximization property of a frame
swings for webnms
swings for webnms  if i am expanding node of jtree then i want to collapse previous expanding node of jtree in swings how is it possible
awt jdbc
awt jdbc  programm in java to accept the details of doctor (dno,dname,salary)user & insert it into the database(use prerparedstatement class&awt
Swings & JSP
Swings & JSP  Hai all, Can we use Swing components in a JSP?? Suppose if we enter details in a swing dialog box..and If we want the result in a JSP..is that possible??? Thank you
Java Swings
Java Swings  I am doing one project on java Swings, in this i have created one jframe where i defined some JButtons and Jcombobox's, here i need to insert one JTable with headers(IN CURRENT JFrame only).pls help me urgently
swings header
swings header   have a string1 it contains 3 parts,for example "123456 service hello" and string2 contains text "change request " like this. and the string3 should contain "123456 +(second string)+ hello" "second string can
AWT Tutorials
AWT Tutorials  How can i create multiple labels using AWT????   Java Applet Example multiple labels 1)AppletExample.java: import javax.swing.*; import java.applet.*; import java.awt.*; import
swings
swings
swings
java swings - JavaMail
java swings  Hi sir,i am doing a project on swings,i don't have any knowledge about the layoutmanagers,so my project is very very burden to me,so plz.../java/example/java/awt/borderlayout-example-in-java.shtml http://www.roseindia.net
AWT Image
AWT Image  I have loaded two images using toolkit in java.one is concentric rectangle and other is concentric circle.kindly someone send me the source code of interchanging the inner most rectangle with the inner most circle
Swings and JDBC
Swings and JDBC  Hi.. I am vinay.. I am developing a small application using swings and mysql. I am sending part of the code here.. The problem is i need to update the mysql fields with values which are gettin from dynamiclly
java awt calender
java awt calender  java awt code for calender to include beside a textfield
how to create frame in swings
how to create frame in swings  how to create frame in swings
Image Movement using Swings
Image Movement using Swings  How to move image using Swings
java code using swings
java code using swings  code that should be able to enter data of student details using all swings into the access database using jdbc connectivity
java awt package tutorial
Java AWT Package In Java, Abstract Window Toolkit(AWT) is a platform... programming language, the AWT is also platform-independent. A common set.... The implementation of the user interface elements provided by the AWT is done using
An application using swings and vector methods
An application using swings and vector methods   Hi, I want an application in Java swings which uses good selection of Vectors methods

Ads