Screen Scrap an Applet

Discussion in 'Java' started by John A. Bailo, Jan 10, 2006.

  1. John A. Bailo, Jan 10, 2006
    #1
    1. Advertising

  2. John A. Bailo

    IchBin Guest

    John A. Bailo wrote:
    >
    > Know any references for how to screen scape an applet?
    >


    public class ScreenShot
    {
    public static void main(String[] args)
    {
    try
    {
    // Get the screen size
    Dimension screenSize =
    Toolkit.getDefaultToolkit().getScreenSize();
    Rectangle rectangle = new Rectangle(0, 0, screenSize.width,
    screenSize.height);
    Robot robot = new Robot();
    BufferedImage image = robot.createScreenCapture(rectangle);
    File file;

    // Save the screenshot as a png
    file = new File("screen.png");
    ImageIO.write(image, "png", file);

    } catch (Exception e)
    {
    System.out.println(e.getMessage());
    }
    }
    }


    --

    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA
    http://weconsultants.servebeer.com/JHackerAppManager
    __________________________________________________________________________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
    IchBin, Jan 10, 2006
    #2
    1. Advertising

  3. IchBin wrote:
    > John A. Bailo wrote:
    >
    >>
    >> Know any references for how to screen scape an applet?
    >>

    >
    > [...]
    > BufferedImage image = robot.createScreenCapture(rectangle);
    > [...]


    I think you'd be better off supplying a custom Graphics object rather
    than trying to do character recognition.

    Tom Hawtin
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
    Thomas Hawtin, Jan 10, 2006
    #3
  4. John A. Bailo

    IchBin Guest

    Thomas Hawtin wrote:
    > IchBin wrote:
    >> John A. Bailo wrote:
    >>
    >>>
    >>> Know any references for how to screen scape an applet?
    >>>

    >>
    >> [...]
    >> BufferedImage image = robot.createScreenCapture(rectangle);
    >> [...]

    >
    > I think you'd be better off supplying a custom Graphics object rather
    > than trying to do character recognition.
    >
    > Tom Hawtin


    Sorry Tom, why is that.. using the robot.createScreenCapture() has
    worked for me. What are some of the implications for doing it this way.
    What would be an example for coding a graphics object or just point me
    into the right direction, I'd be interested.

    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA
    http://weconsultants.servebeer.com/JHackerAppManager
    __________________________________________________________________________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
    IchBin, Jan 10, 2006
    #4
  5. IchBin wrote:
    > Thomas Hawtin wrote:
    >
    >> IchBin wrote:
    >>
    >>> John A. Bailo wrote:
    >>>
    >>>>
    >>>> Know any references for how to screen scape an applet?
    >>>>
    >>>
    >>> [...]
    >>> BufferedImage image = robot.createScreenCapture(rectangle);
    >>> [...]

    >>
    >>
    >> I think you'd be better off supplying a custom Graphics object rather
    >> than trying to do character recognition.

    >
    > Sorry Tom, why is that.. using the robot.createScreenCapture() has
    > worked for me. What are some of the implications for doing it this way.
    > What would be an example for coding a graphics object or just point me
    > into the right direction, I'd be interested.


    Using Robot is fine if you have a dedicated machine, and are interested
    in bitmaps rather than text and vector graphics.

    To get the raw text, for instance, get the applet to paint itself to one
    of your Graphics (or Graphics2D) objects. In the implementation of
    Graphics.drawString, capture the text and do with it what you will.
    Obviously, there is a degree of set up required to run the applet
    outside of a conventional applet viewer.

    Tom Hawtin
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
    Thomas Hawtin, Jan 11, 2006
    #5
  6. John A. Bailo

    IchBin Guest

    Thomas Hawtin wrote:
    > IchBin wrote:
    >> Thomas Hawtin wrote:
    >>
    >>> IchBin wrote:
    >>>
    >>>> John A. Bailo wrote:
    >>>>
    >>>>>
    >>>>> Know any references for how to screen scape an applet?
    >>>>>
    >>>>
    >>>> [...]
    >>>> BufferedImage image = robot.createScreenCapture(rectangle);
    >>>> [...]
    >>>
    >>>
    >>> I think you'd be better off supplying a custom Graphics object rather
    >>> than trying to do character recognition.

    >>
    >> Sorry Tom, why is that.. using the robot.createScreenCapture() has
    >> worked for me. What are some of the implications for doing it this
    >> way. What would be an example for coding a graphics object or just
    >> point me into the right direction, I'd be interested.

    >
    > Using Robot is fine if you have a dedicated machine, and are interested
    > in bitmaps rather than text and vector graphics.
    >
    > To get the raw text, for instance, get the applet to paint itself to one
    > of your Graphics (or Graphics2D) objects. In the implementation of
    > Graphics.drawString, capture the text and do with it what you will.
    > Obviously, there is a degree of set up required to run the applet
    > outside of a conventional applet viewer.
    >
    > Tom Hawtin


    Thanks Tom for the info..

    --

    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA
    http://weconsultants.servebeer.com/JHackerAppManager
    __________________________________________________________________________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
    IchBin, Jan 11, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ibiza
    Replies:
    5
    Views:
    481
    ibiza
    Jan 24, 2006
  2. Дамјан ГеоргиевÑки

    Using lxml to screen scrap a site, problem with charset

    Дамјан ГеоргиевÑки, Feb 2, 2009, in forum: Python
    Replies:
    2
    Views:
    2,088
    Stefan Behnel
    Feb 4, 2009
  3. Avi

    Scrap Posts

    Avi, Apr 9, 2009, in forum: Python
    Replies:
    3
    Views:
    273
    Aaron Brady
    Apr 10, 2009
  4. Steve
    Replies:
    7
    Views:
    133
    Marcin Raczkowski
    May 7, 2007
  5. Pen Ttt
    Replies:
    0
    Views:
    104
    Pen Ttt
    Apr 21, 2010
Loading...

Share This Page