mastan
awt swings
2 Answer(s)      4 years and 5 months ago
Posted in : Swing AWT

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 Pages:
SWINGS
SWINGS  WHAT ARE THE DIFFERENCES BETWEEN AWT AND SWINGS
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 - 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
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
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
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
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
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
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
difference between applet and swings
between swing and applets   Hello Friend, Differences: 1) AWT stands... Foundation classes). 2) AWT components use native methods Swing components use the methods that are written in Java. Therefore AWT is heavy weight component
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 - 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
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 - Swing AWT
java   Write Snake Game using Swings
Java Code - Swing AWT
Java Code  Write a Program using Swings to Display JFileChooser that Display the Naem of Selected File and Also opens that File
Java Code - Swing AWT
Java Code  How to Make an application by using Swings JMenuBar and other components for drawing various categories of Charts(Line,Bar etc
LinkButton - Swing AWT
want that link into swings(java) code not in html.... i know the html code but i want java(swings) code in that i forgot to write using swings.... if u know plz tell me how to write a link button using swings
Drawing Graphs - Swing AWT
Drawing Graphs  hi i am doing a small project in java swings . there is a database table having two columns A,B i want to plot a graph to that values in database the graph must be interactive graph
Java Program - Swing AWT
Java Program  A program to create a simple game using swings.  Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/java/swing/guessNumber.html Thanks
AWT
AWT  How to set size of button in awt
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
Java AWT Applet example  how to display data using JDBC in awt/applet
awt
JDBC in awt  how to display data using JDBC in awt/applet
Design a Toll bar - Swing AWT
Design a Toll bar  Hi,i am very new to Swings-awt..... Please any one send me the Logic to Create a Toolbar which is similar to --- winword(Standard/Formating Tool bar). it's very urgent. Thanks in Advance. Thanks
provide code - Swing AWT
provide code  Dear frnds please provide code for two player CHESS GAME.....using swings,awt concepts   Hi friend, import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; public
validation - Swing AWT
validate a registration form through swings..fields like user,password,email and how to link a pages with each other in swings using java...  Hi Friend.................. In Java Swings,you can give link from one page to another
game programming code - Swing AWT
game programming code  write a snake program using swings with step by step explanation?. please send me this source code to my mail id with step by step explanation

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.