awt swings

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 ...









Related Tutorials/Questions & Answers:
Swings/awt - Swing AWT
Swings/awt  Hi, how to write action listeners to the Buttons in RichTextEditor tool bar.. thanks in advance...it's Urgent... i am very much new to Swings
AWT-swings tutorial - Swing AWT
AWT-swings tutorial  hello sir, i am learnings swings and applets.. i want some tutorials and some examples related to swings.. thank you sir..waiting for your answer.  Hi friend, I am sending you a link
Advertisements
awt swings - Swing AWT
awt swings  hello sir, My requirement is to insert captured image from cam onto a frame and from that place i hve to save it in the database(MySql).its urgent sir.it is a part of my project..if code is available
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
Java Swings-awt - Swing AWT
Java Swings-awt  Hi, Thanks for posting the Answer... I need to design a tool Bar which looks like a Formating toolbar in MS-Office Winword(Standard & Formating) tool Bar. Please help me... Thanks in Advance
SWINGS - Swing AWT
more information,Examples and Tutorials on Swing,AWT visit to : http://www.roseindia.net/java/example/java/awt/ http://www.roseindia.net/java/example/java
java swings - Swing AWT
java swings  I am doing a project for my company. I need a to show the performance of the employees by using bar bharts. Please give me how can we write the code for bar charts using java swings.  Hi friend, I am
SWINGS
SWINGS  WHAT ARE THE DIFFERENCES BETWEEN AWT AND SWINGS
Java Swings problem - Swing AWT
Java Swings problem  Sir, I am facing a problem in JSplitPane. I want the divider in the splitpane to be customized. I have a splitpane with Horizontal orientation and here, there lies the divider between left component and right
Swings JTable numberic sorting - Swing AWT
Swings JTable numberic sorting  Hi , i am using jdk1.6 for my project and jdk1.6 is providing by default sorting of text column in JTable or suggestion for sorting of numberic column in JTable of Swings...Swings JTable numberic
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
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
Display data from xml file to Swings - Swing AWT
Display data from xml file to Swings  Hi, We are Preparing a stand alone application. Where the Swings is the front end. There will be only... clicking the buttons in swings it has to display 20 record in one shot in table
plz help me to write a snake game using swings - Swing AWT
plz help me to write a snake game using swings  write snake game program using swings
swings - Swing AWT
swings - Swing AWT
java-swings - Swing AWT
SWINGS - Swing AWT
swings - Swing AWT
java swings - Swing AWT
Java swings - Swing AWT
swings - Swing AWT
virtual onscreen keyboard project using java and swings - Swing AWT
virtual onscreen keyboard project using java and swings  Im doing virtual on screen keyboard as my project. i didnt get the method to performthe backspace and space operation using swings in java.can please help me  Hi
AWT
AWT  How to set size of button in awt
awt
JDBC in awt applet  how to display data using JDBC in awt/applet
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  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 - Java Interview Questions
awt  what is the difference between awt and swings  Hi friend, These are basically the main differences between awt and swing. 1.swing components sits on the top of AWT components and do the wiork. 2.AWT
virtual onscreen keyboard project using java and swings - Swing AWT
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 & SWING
AWT & SWING  What is diffennce between AWT & SWING
AWT programmes - Swing AWT
AWT programmes  I need few programs for menus in AWT. how to open a filed dialog window, and how to save a image in the save window when we press... has all AWT programms which must open,save and make changes to a particular
Swings JTable
Swings JTable  add values to JTable with four coloums,two of them are comboboxes
awt in java
awt in java  using awt in java gui programming how to false the maximization property of a frame
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
swing/awt - Swing AWT
swing/awt  How to create richtexteditor using swings...?I'm very much new to swings....It's urgent.....Thank u...   hello read this book you get idea; JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second
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
difference between applet and swings
1) AWT stands for Abstract windows toolkit whereas le Swing is also called as JFC?s (Java Foundation classes). 2) AWT components use native methods Swing components use the methods that are written in Java. Therefore AWT is heavy weight
Java AWT
Java AWT  What interface is extended by AWT event listeners
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 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 - Swing AWT
awt  dear sir my proble is , i have applet code which is stock market chart this code made using "AWT" . in this chart one textbox when user.../java/awt/ Thanks
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
Java AWT
Java AWT  What is meant by controls and what are different types of controls in AWT
swings
","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; for(i = 0
swings
swings

Ads