How need to take screen shot of the screen using java.awt.Robot from javafx

1) I am displaying a Stage which is having an image and shapes in it and wanted to take the screen shot as and when i move the shape( which moves the stage ).
I am trying to java.awt.Robot, but i am getting headless exception. I used
@Override
public void start(final Stage primaryStage) {
// creating some images and shapes
Platform.runLater(new Runnable() {
@Override
public void run() {
// update();
public void update() {
if (stg.isShowing()) {
ScreenCapture.capture(stg.getX() + 2, stg.getY() + 2, (int) boundsOfCircle.getBoundsInParent().getWidth(), (int) boundsOfCircle.getBoundsInParent().getHeight());
magnifierImageView.setImage(new Image(SCREEN_SHOT_FILE));
public static void capture(final double x, final double y, final int width, final int height) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
System.out.println("x ="+x +" y = "+y +" width "+width +" height ="+height);
Robot robot = new Robot();
} catch (Exception e) {
System.out.println("exception arised while taking the screen shot ");
e.printStackTrace();
The above code throws headless exception.
2) The second issues is have a image & i am dividing the image into different rows and cols( images of same size ). This is i am doing using awt. and i wanted to load those different images into
javafx images . I am facing the issues when i try to load the images into javafx.

hi,
click on print screen button in your keyboard.
open a word document and do Ctrl V .
*Reward points if it helped

Similar Messages

  • How do I take a picture of the screen on my iPad Air?

    How can I take a picture of the screen on my iPad Air?

    Tap the On/Off button and at the same time tap the Home button. The resultant picture will be saved to your "Camera Roll".

  • How do I take a picture of the screen?

    How do I take a picture of the screen?

    You can also use spotlight (Cmd + Space) to search for and start an app called Grab (or look in the Applications folder...). With this program you can capture a selection of the screen, a window, the whole screen and more. See menuoption Capture for these options.

  • How do I take a picture of the screen while on face time

    I want to be able to take a picture of the person I'm face timing with.      While on face time

    I would imagine that you do the same thing that you do for any screen shot. Hold the sleep button down and then tap the home button. The screen should flash white and you will hear the shutter sound.
    Look for the photo in the camera roll.
    I just tried this without FaceTiming with anyone else but I was able to produce the screen shot of myself so I assume that it will work.
    Message was edited by: Demo

  • How to send a mail by ckicking the button using java

    hi,
    how to send a mail by clicking the button (like payroll silp in that contain one button if we click that it autometically go through the mail as a attachment) pls frd to me my gmail is [email protected]

    Hi,
    It seems we are doing the homework for you; to make you start with something; look at the sample code below and try to understand it first then put the right values
    to send an email with an attachement.
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.util.Date;
    import java.util.Properties;
    import javax.activation.DataHandler;
    import javax.activation.FileDataSource;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Multipart;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMultipart;
    import javax.swing.AbstractAction;
    import javax.swing.Action;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    public class Main {
          * @param args
         public static void main(String[] args) {
              // Create the frame
              String title = "Frame Title";
              JFrame frame = new JFrame(title);
              // Create a component to add to the frame
              JComponent comp = new JTextField();
              Action action = new AbstractAction("Button Label") {
                   // This method is called when the button is pressed
                   public void actionPerformed(ActionEvent evt) {
                        System.out.println("sending email with attachment");
                        sendEmail();
              // Create the button
              JButton button = new JButton(action);
              // Add the component to the frame's content pane;
              // by default, the content pane has a border layout
              frame.getContentPane().add(comp, BorderLayout.SOUTH);
              frame.getContentPane().add(button, BorderLayout.NORTH);
              // Show the frame
              int width = 300;
              int height = 300;
              frame.setSize(width, height);
              frame.setVisible(true);
         protected static void sendEmail() {
              String from = "me@localhost";
              String to = "me@localhost";
              String subject = "Important Message";
              String bodyText = "This is a important message with attachment";
              String filename = "c:\\tmp\\message.pdf";
              Properties properties = new Properties();
              properties.put("mail.stmp.host", "localhost");
              properties.put("mail.smtp.port", "25");
              Session session = Session.getDefaultInstance(properties, null);
              try {
                   MimeMessage message = new MimeMessage(session);
                   message.setFrom(new InternetAddress(from));
                   message.setRecipient(Message.RecipientType.TO, new InternetAddress(
                             to));
                   message.setSubject(subject);
                   message.setSentDate(new Date());
                   // Set the email message text.
                   MimeBodyPart messagePart = new MimeBodyPart();
                   messagePart.setText(bodyText);
                   // Set the email attachment file
                   MimeBodyPart attachmentPart = new MimeBodyPart();
                   FileDataSource fileDataSource = new FileDataSource(filename) {
                        @Override
                        public String getContentType() {
                             return "application/octet-stream";
                   attachmentPart.setDataHandler(new DataHandler(fileDataSource));
                   attachmentPart.setFileName(filename);
                   Multipart multipart = new MimeMultipart();
                   multipart.addBodyPart(messagePart);
                   multipart.addBodyPart(attachmentPart);
                   message.setContent(multipart);
                   Transport.send(message);
              } catch (MessagingException e) {
                   e.printStackTrace();
    }The sample above is not ideal so you need to go through it and start to ask me some questions if you have
    Let me know if you miss something
    Regards,
    Alan Mehio
    London,UK

  • How to activate a specific profile of the Firefox using java coding?

    Hi Folks,
    I have some query regarding activating the Profiles of the Firefox. Whenever i open the Firefox, the profile manager will be prompting for the profile to be activated. I want to perform such similar operation through java coding. Let us assume, I have three profiles named default, office and personal. I need to invoke the Firefox with a specific profile, office. How to proceed further? Your suggestion will be highly appreciated...
    Thanks in Advance,
    RealStuff, Mike

    String s = "Less than 20";
    while(s.length() < 20) {
         s += " ";
    System.out.println(s + " " + s.length());Mark

  • Need screen-shot  for create mm01 using BAPI(Through lsmw or ecording)

    hi,
    could u give screen-shot of the lsmw using bapi.for material master data create using t.code (mm01')
    i will be waiting for eply.
    regards
    eswar.

    Check this link dude.....
    http://www.****************/Tutorials/LSMW/LSMWMainPage.htm
    It has all different types of LSMW with the screen shots.... keep doin
    Regards,
    Pavan

  • Code for reading the and placing the file using java webservice

    Hi All,
    Can anybody can guide me on how to read a file and place the file using java.
    Let  me know if any code is available which has been completed using java.
    Regards,
    Rahul

    Hi,
    The "square" symbol that you are referring to is probably a CRLF (Carriage Return - Life Feed) Control Character.
    This is more commonly known as a "Enter" at the end of a line / sentence.
    To clean this character from strings in Java, please use:
    String patternStr = "(?m)$^|[\\r\\n]+\\z";
    String replaceStr = " ";
    Pattern pattern = Pattern.compile(patternStr);
    Matcher matcher = pattern.matcher(inputStr);
    return matcher.replaceAll(replaceStr);
    Hope that helps.
    Thanks.
    p256960.

  • How can I take a screen shot on the iPad Air and keep the resolution at 2048 x 1536. For some reason when I'm in an app it reduces the resolution

    How can I take a screen shot on the iPad Air and keep the resolution at 2048 x 1536. For some reason when I'm in an app it reduces the resolution

    Tatanka11 wrote:
    I'm new to Mac,...
    Then...  You may find these Links of Interest and Value...
    Show me how to set up my Mac.
    http://www.apple.com/support/mac101/
    http://www.apple.com/support/switch101/     Switching from PC
    http://www.apple.com/findouthow/mac/
    Enjoy your Mac...

  • I have a macbook pro 17".  How can I change the way things look?  The page only takes about half of the screen and the fonts are fairly small.  I am sure there is an easy adjustment.  Please clue me in.  Thanks

    I have a macbook pro 17".  I love the big screen, but how can I change the display?  The content takes about half of the screen and the fonts are very small.  I am sure it is an easy fix, so please clue me in.  Thanks

    Look at your >System Preferences>Displays

  • How to paste screen shot in the forum editor

    please help
    how to paste screen shot in the forum editor

    Do you see the "Attach Files" button in between the "Preview" and "Post Message" buttons when posting a question or reply? 
    This is how you would attach an image, you can't embed it into the text here.  Also,  I thought that the "Attach Files" functionality had been removed for performance reasons, but you can try it if you see the button.
    Regards,
    Rich Heilman

  • Why won't my camera work? I used the screen shot for the first time and since i did that every time i take a picture the shutter closes as though it's taking it but no picture gets taken...help! Any suggestions?

    Why won't my camera work? I used the screen shot for the first time and since i did that every time i take a picture the shutter closes as though it's taking it but no picture gets taken...help! Any suggestions?

    Hey briannagrace96,
    Welcome to Apple Support Communities! I'd check out the following article, it looks like it applies to your situation:
    iPod: Appears in Windows but not in iTunes
    http://support.apple.com/kb/ts1363
    You'll want to go through the following troubleshooting steps, and for more detail on each step follow the link to the article above:
    Try the iPod troubleshooting assistant:
    If you have not already done so, try the steps in the iPod Troubleshooting Assistant (choose your iPod model from the list).
    If the issue remains after following your iPod's troubleshooting assistant, follow the steps below to continue troubleshooting your issue.
    Restart the iPod Service
    Restart the Apple Mobile Device Service
    Empty your Temp directory and restart
    Verify that the Apple Mobile Device USB Driver is installed
    Change your iPod's drive letter
    Remove and reinstall iTunes
    Disable conflicting System Services and Startup Items
    Update, Reconfigure, Disable, or Remove Security Software
    Deleting damaged or incorrect registry keys
    Take care,
    David

  • I have screen shots of the messages and what happens when I try to play games on Facebook since I updated Firefox. Issues I didn't have before the update. Where do I send them? How do I correct this?

    The screen shots include the web address for both shots. One is for script error messages that keep interrupting EVERY game. Then after I stop the scrip, Adobe Flash crashes, and I have no control. I have to use the Windows Task Manager to gain access to my home page to get out.
    This didn't happen until I updated the Firefox this last time. I've tried everything and nothing works to get rid of the problem.
    I've been to your questions, etc and nothing I've found helps.
    I use Windows XP
    Four sites are the worst; I only play these 4 games on Facebook.
    URL's of these are:
    http://apps.facebook.com/wildwesttown/?ref=bookmarks&count=0&fb_source=bookmarks_apps&fb_bmpos=4_0
    http://apps.facebook.com/aviator-game/?fb_source=canvas_bkmk_top
    http://apps.facebook.com/gnometown/?fb_source=canvas_bkmk_top
    http://apps.facebook.com/journeyofmoses/?fb_source=canvas_bkmk_top&count=1
    (I got a script error message just getting the URL on this last one.

    Try:
    - Reset the iOS device. Nothing will be lost       
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Unsync/delete all music and resync
    - Reset all settings                  
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                                
    iOS: Back up and restore your iOS device with iCloud or iTunes
      - Restore to factory settings/new iOS device.

  • The new zoom feature overlaps some of the headings. I have a screen shot of the problem but don't know how to send that to you.

    I have a screen shot of the problem, I can send it to you. The first thing I tried was a zoom on your header. It looks like some things in your header were anchored to the right while others anchored to the left. When the zoom occurred they met in the middle.

    Thanks, I know I'm not really a big brand (not even a brand at that) but I think you could always release as Firefox's first own brand mobile WITH the OS :)

  • Screen Shot on the MACmini !!!

    How do I screen shot on the MACmini?

    Take a screenshot on your Mac
    http://www.wikihow.com/Take-a-Screenshot-in-Mac-OS-X

Maybe you are looking for

  • How do I sync my iPhone with a new iTunes?

    I got a new laptop and would like to sync my phone to it. I want to transfer my music from my phone onto my new iTunes. Is that possible? The laptop with my old iTunes broke so I can't transfer it from the old laptop to the new.  I want to transfer m

  • Elements are not listed in the LOV of element entry window

    hi friends, i tried running payroll for uae legislation in test instance.when i tried to attache the element in the elemnt entry screen,i m getting an error ,"query caused no records to be retrieved". Below i have mentioned the step by step activitie

  • IPhoto file too small for publication

    I am writing a series of gardening articles for a national publication and was told the size of the photo (from my iPhoto library) I e-mailed is too small. Will changing the size from "large" to "actual" do the trick? Or do I need to send it through

  • Can't set up ipad!

    I've just bought an iPad and am trying to set it up. I've selected my home wifi but it won't connect. I think i may have mistyped the password, but it won't let me try again, or start set up again, so i'm completely stuck. Does anyone have any sugges

  • With in Plant - Storage loc to Storage loc STO in ECC 6.0?

    In case of raw materials, we have to bring from outside godowns to inside plant storage location. As per business requirement we are treating the outside godowns as storage location of the same plant. In this scenario with in Plant, storage location