How capture entire JTextPane graphics ?

Hello i have JTextPane ,     
I would want to capture the entire graphics and to transform to image.
the problem that I would want to capture all the portion that scrollable .
i have this metod but capture visible graphics.
Component comp = myTextPane;
int w = comp.getWidth();
int h = comp.getHeight();
BufferedImage image = comp.getGraphicsConfiguration().createCompatibleImage(w, h);
Graphics2D g = image.createGraphics();
comp.paint(g);
g.dispose();
i need method for capture all entire graphics.
Thanks

I have resolved my problem, works good .
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
public class ScreenImage
public void ScreenImage()
* Create a BufferedImage for Swing components.
* The entire component will be captured to an image.
* @param     component Swing component to create image from
* @param     fileName name of file to be created or null
* @return     image the image for the given region
* @exception IOException if an error occurs during writing
public static BufferedImage createImage(JComponent component, String fileName)
throws IOException
Dimension d = component.getSize();
if (d.width == 0)
d = component.getPreferredSize();
component.setSize( d );
Rectangle region = new Rectangle(0, 0, d.width, d.height);
return ScreenImage.createImage(component, region, fileName);
* Create a BufferedImage for Swing components.
* All or part of the component can be captured to an image.
* @param     component Swing component to create image from
* @param     region The region of the component to be captured to an image
* @param     fileName name of file to be created or null
* @return     image the image for the given region
* @exception IOException if an error occurs during writing
public static BufferedImage createImage(JComponent component, Rectangle region, String fileName)
throws IOException
boolean opaqueValue = component.isOpaque();
component.setOpaque( true );
BufferedImage image = new BufferedImage(region.width, region.height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = image.createGraphics();
g2d.setClip( region );
component.paint( g2d );
g2d.dispose();
component.setOpaque( opaqueValue );
ScreenImage.writeImage(image, fileName);
return image;
* Create a BufferedImage for AWT components.
* @param     component AWT component to create image from
* @param     fileName name of file to be created or null
* @return     image the image for the given region
* @exception AWTException see Robot class constructors
* @exception IOException if an error occurs during writing
public static BufferedImage createImage(Component component, String fileName)
throws AWTException, IOException
Point p = new Point(0, 0);
SwingUtilities.convertPointToScreen(p, component);
Rectangle region = component.getBounds();
region.x = p.x;
region.y = p.y;
return ScreenImage.createImage(region, fileName);
* Convenience method to create a BufferedImage of the desktop
* @param     fileName name of file to be created or null
* @return     image the image for the given region
* @exception AWTException see Robot class constructors
* @exception IOException if an error occurs during writing
public static BufferedImage createDesktopImage(String fileName)
throws AWTException, IOException
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle region = new Rectangle(0, 0, d.width, d.height);
return ScreenImage.createImage(region, fileName);
* Create a BufferedImage from a rectangular region on the screen.
* @param     region region on the screen to create image from
* @param     fileName name of file to be created or null
* @return     image the image for the given region
* @exception AWTException see Robot class constructors
* @exception IOException if an error occurs during writing
public static BufferedImage createImage(Rectangle region, String fileName)
throws AWTException, IOException
BufferedImage image = new Robot().createScreenCapture( region );
ScreenImage.writeImage(image, fileName);
return image;
* Write a BufferedImage to a File.
* @param     image image to be written
* @param     fileName name of file to be created
* @exception IOException if an error occurs during writing
public static void writeImage(BufferedImage image, String fileName)
throws IOException
if (fileName == null) return;
int offset = fileName.lastIndexOf( "." );
String type = offset == -1 ? "jpg" : fileName.substring(offset + 1);
ImageIO.write(image, type, new File( fileName ));
public static void main(String args[])
throws Exception
final JFrame frame = new JFrame();
// final JTextArea textArea = new JTextArea(30, 60);
final JTextPane textArea = new JTextPane();
final JScrollPane scrollPane = new JScrollPane( textArea );
frame.getContentPane().add( scrollPane );
textArea.setPage ("FILE:C:\\Java_(linguaggio).htm");
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar( menuBar );
JMenu menu = new JMenu( "File" );
ScreenImage.createImage(menu, "menu.jpg");
menuBar.add( menu );
JMenuItem menuItem = new JMenuItem( "Frame Image" );
menu.add( menuItem );
menuItem.addActionListener( new ActionListener()
public void actionPerformed(ActionEvent e)
// Let the menu close and repaint itself before taking the image
new Thread()
public void run()
try
Thread.sleep(50);
System.out.println("Creating frame.jpg");
frame.repaint();
ScreenImage.createImage(frame, "frame.jpg");
catch(Exception exc) { System.out.println(exc); }
}.start();
final JButton button = new JButton("Create Images");
button.addActionListener( new ActionListener()
public void actionPerformed(ActionEvent e)
try
System.out.println("Creating desktop.jpg");
ScreenImage.createDesktopImage( "desktop.jpg" );
System.out.println("Creating frame.jpg");
ScreenImage.createImage(frame, "frame.jpg");
System.out.println("Creating scrollpane.jpg");
ScreenImage.createImage(scrollPane, "scrollpane.jpg");
System.out.println("Creating textarea.jpg");
ScreenImage.createImage(textArea, "textarea.jpg");
System.out.println("Creating button.jpg");
ScreenImage.createImage(button, "button.jpg");
button.setText("button refreshed");
button.paintImmediately(button.getBounds());
System.out.println("Creating refresh.jpg");
ScreenImage.createImage(button, "refresh.jpg");
System.out.println("Creating region.jpg");
Rectangle r = new Rectangle(0, 0, 100, 16);
ScreenImage.createImage(textArea, r, "region.png");
catch(Exception exc) { System.out.println(exc); }
frame.getContentPane().add(button, BorderLayout.SOUTH);
try
FileReader fr = new FileReader( "ScreenImage.java" );
BufferedReader br = new BufferedReader(fr);
textArea.read( br, null );
br.close();
catch(Exception e) {}
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo( null );
frame.setVisible(true);
}

Similar Messages

  • Batch capturing entire tape...recomended???

    Is it a good idea to attempt to batch capture a tape in its entirety? I am having problems doing this...I do a lot of events that last often over 2 hours. Instead of capturing footage in clips, I just capture the entire tape. When I'm done with the project, I simply make the clips offline.
    I'm in the process of reviving a project now, and one tape in it's entirety(55 min approx), captured OK, but I am having problems with another tape. I am getting a broken timecode error, when I don't see how this is possible...because I let the tape freely run. Also, under the logging info, the media ends before the tape ends, which means that is space left on the end of the tape without any timecode. Yet when I batch capture, it still goes to the end of the tape.....isn't a batch capture suppose to go by the clips media in and media out points?
    All help is greatly appreciated.

    I do this often. There are two shools of thought on this method -
    Capturing entire tapes allows one to scroll through non-linearly and make subclips. The advantage to subclips is that they are serachable and you can add comments. The downside to this method is that the files are large, and you may be capturing much more metarila than you need. I often do this when working on docs with very high shooting ratios. The most recent one had 190 tapes for a 1-hour program, which led us to use offline RT for our cutting format and then recapture for online.
    Logging and capturing single clips fives you the advantage of starting out capturing only what you know you might use, you can input the logging info at the start, and will have several small clips that may be easier to manage. Since at some point you'll have to familiarize youself with the matreial anyway, you might as well do it at the logging stage.
    Several factors can contribute to perceived TC breaks - reusing tapes, camera stops, shooting format (HDV, for instance, will show a TC break each time the camera stops). If you are capturing whole tapes, you might do well to let FCP create new clips on TC breaks and just let it roll. Make sure the TC format matches between your tape and settings (DF vs. NDF)
    Regarding rolling off the end of the tape during capture, you might be very close to the end with the clip you are capturing. You might try lowering the post-roll value in the device control preset in your A/V settings.
    Hope this helps -
    Max Average

  • How can get a Graphics to draw line on screen?

    How can get a Graphics to draw line on screen?
    Now, I can get a Graphics to draw line based on component. For example JPanel, but I want to get a Graphics to draw line on screen.

    By drawing on the screen, I assume you mean drawing outside the bounds of a top-level window like
    JFrame or JDialog. You can't do that. At least, without going native and even then that's a dodgey thing
    for any platform to let you do. One thing you can do is simulate it with a robot's screen capture:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class X {
        public static void main(String[] args) throws Exception {
            Rectangle bounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
            BufferedImage image = new Robot().createScreenCapture(bounds);
            Graphics2D g2 = image.createGraphics();
            g2.setStroke(new BasicStroke(20));
            g2.setPaint(Color.RED);
            g2.drawLine(0, 0, bounds.width, bounds.height);
            g2.drawLine(bounds.width, 0, 0, bounds.height);
            g2.dispose();
            JLabel label = new JLabel(new ImageIcon(image));
            label.addMouseListener(new MouseAdapter(){
                public void mousePressed(MouseEvent evt) {
                    System.exit(0);
            JFrame f = new JFrame();
            f.setUndecorated(true);
            f.getContentPane().add(label);
            f.setBounds(bounds);
            f.setVisible(true);
    }

  • Need direction on how to make motion graphics -AF CS5

    I didn’t know how to word the header for my question so I’ll try to clarify it here. I’m new to AF so please bear with me. In the Adobe tutorial at the link below, he animates a flower. The flower is in front of a colored background and there are some added text that animate as well. I understand about layers but my question is, can I make a graphic like the one in the tutorial in Photoshop CS5 and import it into AF? I just ordered a copy of PS CS5 and have not gotten a chance to work with PS. When I searched the net about my question, I found many links describing how to make web graphics. Would I be making the same thing and saving them not as a web graphic? If I can make something similar to the flower in the tutorial, then I can go from there. I guess what is confusing for me is that the background and flower assets are mp4 (mpeg) video. I thought it would be two graphics in 2 layers, plus additional text as more layers. http://tv.adobe.com/watch/learn-after-effects-cs5/gs05-working-with-layers/

    Thank you Kevin.  I'll kinda figured that would be the be the steps but wasn't real sure. Once I get going in PS, I'll better understand how to do things.
    Wow, lots to learn.

  • How do I paint graphics in a JFrame created by netbeans GUI builder?

    I hope it's ok to ask netbeans questions here. Frustrated with Eclipse I'm trying netbeans. I went through the tutorial for the UI builder and I have no trouble laying out the usual swing widgets like JPanels, JButtons, etc. What I haven't figured out is how to mix ordinary graphics like Graphics.draw() with these components.
    Crude example: 2 JPanels in a JFrame. The one on the left has a JSlider bar. The one on the right has a line or something that gets bigger or smaller according to the slider bar.
    If I weren't using the UI builder I'd create a new class that is an extension of JPanel, and override paintComponent() with my draw commands. If I did that to a JPanel I layed out with the UI builder it would get lumped in with the protected code that's created on the fly and probably erased.
    So how do I mix swing components with ordinary graphics without breaking the netbeans UI builder form?
    Thanks,
    Apchar

    This forum is a Java language forum. The NetBeans site has a mailing list. Nabble forums also has NB forums. The contents of both are crossposted. So, you really should post NB use questions to one of them. Post only Java language questions here.
    You can add custom code to the guarded (blue) code blocks. Open a component's property window and select the code button at the top. This allows you to insert code in numerous locations within the guarded blocks and retain the code.
    You can also click a component's property's ellipsis (...) button to bring up the Property Editor dialog box, then select "Custom Code" from the dropdown list at the top of the dialog.
    Note: the above instructions are for NB 6

  • How to add a graphic watermark that is bigger than the photo?

    How to add a graphic watermark that is bigger than the photo?
         Basically I want to add a watermark that is a border, like "outside stroke" so that it doesn't clip the photo.
         Upper, left and right side are 10px and on the bottom is my signature that is 40px high. I know how to do this in Photoshop, but can't figgure it out in Lightroom.
         The inset function with negative numbers doesn't work, because it only export to the size of the exported image, instead it should resize the image with those 10px up, left and right and 40px on      the bottom.
    My bordes look like this either one of the two can be used, and if you scroll down you will se how the end result should look like.
    And below is what it should look like, so that Lightroom doesn't clip the photo.

    Are you sure the focus of your piano roll is on the right track? Are you zoomed in/out enough?

  • How to put 2D graphics in TransformGroup?

    I can use J3DGraphics2D to draw graphics in Canvas3D, but may i put the graphics i drawed in a TransformGroup so that i can remove them later?

    I am anxious to know how to put 2D graphics in 3D TransformGroup, because
    I want to pick 2D graphics in 3D scene. For example, I drew some 2D graphics
    in 3D scene, line, sphere, rect, I may pick one using mouse. As we know, we can
    use PickMouseBehavior to pick 3D Graphics, How can I to 2D Graphics? Thanks a lot!

  • How to set Analysis graphics background color to Transparent? not White.

    How to set Analysis graphics background color to Transparent? not White.
    thanks
    Edited by: user13257485 on 2010-8-15 下午11:53
    Edited by: user13257485 on 2010-8-15 下午11:55

    Hi,
    We almost had the same requirement, but we just needed to color a specific column.
    Here goes the solution to that, you might do the same for your row highlighting
    Changes are required in jsff and one method to be added in backing bean
    1. JSFF :
    <af:column headerText="Amount"
                     id="c4" width="100"
                     inlineStyle="#{backingBeanScope.BackingBean.cellColor}">2. Backing Bean
    //searchResultTableVO is Table's VO
    public String getCellColor() {
          FacesContext ctx = FacesContext.getCurrentInstance();
          ExpressionFactory ef = ctx.getApplication().getExpressionFactory();
          ValueExpression ve = ef.createValueExpression(ctx.getELContext(), "#{row}", FacesCtrlHierNodeBinding.class);
          FacesCtrlHierNodeBinding node = (FacesCtrlHierNodeBinding)ve.getValue(ctx.getELContext());
          Row row = node.getRow();
        if(row.equals(searchResultTableVO.getCurrentRow())){
    //You can add your inline style for font-style too
          return "background-color:Red;";
             return null;
      }Hope this is helpful :)
    Regards,
    Neha..

  • Need to capture entire contents of a mini DV

    What is the easiest way to capture entire contents of a mini DV? Must I create an offline clip and specify the media start and end points and do a batch capture, or can I use Capture Now?
    Thanks,
    John Link

    If you use Capture Now, it will get everything minus any preroll needed to start a new clip on a timecode break.
    If you change Device Control to Non-Controllable Device, in the Capture Settings, you will get absolutely everything but there will be no source timecode. Should you ever need to recapture that will make it very difficult/almost impossible to recreate your work accurately.

  • How to Show ActionScript Graphics based Spinner on Flex or mobile application ?

    How to Show ActionScript Graphics based Spinner on Flex or mobile application
    Solution:

    Check out the BusyIndicator component introduced in Flex 4.5:
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark">
        <s:BusyIndicator />
    </s:Application>

  • How much is  a graphics card for 2011 macbook pro early edition?

    How much is a graphic card for a 2011 MacBook Pro?

    There is an Apple Recall for this year:
    https://www.apple.com/support/macbookpro-videoissues/
    These are the models involved:
    Affected Models
    MacBook Pro (15-inch Early 2011)
    MacBook Pro (15-inch, Late 2011)
    MacBook Pro (Retina, 15-inch, Mid 2012)
    MacBook Pro (17-inch Early 2011)
    MacBook Pro (17-inch Late 2011)
    MacBook Pro (Retina, 15 inch, Early 2013)
    Is yours one of these? Run your serial number on that site.
    IIt will make it easier to help you w/ your problem to know know more information about your computer; size, exact year built, RAM installed and OS you're running. Any history prior to your incident would also be helpful.

  • How can I add graphics to a photograph from iPhoto?

    Good morning, how can I add graphics, ie. arrows to a photograph that's in my iPhoto library? Thank you...

    Set your Graphics App as an external editor in iPhoto
    In order of price here are some suggestions:
    Seashore (free)
    The Gimp (free)
    Graphic Coverter ($45 approx)
    Acorn ($50 approx)
    Pixelmator ($50 approx)
    Photoshop Elements ($75 approx)
    There are many, many other options. Search on MacUpdate. You can set Photoshop (or any image editor) as an external editor in iPhoto. (Preferences -> General -> Edit Photo: Choose from the Drop Down Menu.) This way, when you double click a pic to edit in iPhoto it will open automatically in Photoshop or your Image Editor, and when you save it it's sent back to iPhoto automatically. This is the only way that edits made in another application will be displayed in iPhoto.

  • How to combine 2 graphics bitmap

    Hi,
    Please advise how to combine 2 graphics bitmap by
    drag-and-drop to become a photobook with background graphics.
    Similir to
    http://www.mixbook.com
    Please advise.
    Thanks.
    Billy

    If you create a new Album it will give you the option to add photos to this new Album simply navigate to where Album A is, select your pictures, then navigate to Album B select your pictures here and select Done and these will copy over to your new Album.
    Regards,
    Steve

  • How to Add a graphical Sequence panel  in a webhelp layout?

    Hi,
    Can anyone please let me know how to add a graphical pane on
    the top right of every topic which would show the flow of sequence,
    the single source layout being webhelp.
    I'll be more clear......
    If we click on Help>Tutorial>HTML ROBOHELP Tutorial. we
    see a panel on the right which shows the graphical flow of files.
    Can i do the same when i create a webhelp layout.(in html
    format)....Please Please Please let me know!
    Thanks
    Sincerely
    Siddb.

    Hi Siddb and welcome to our community
    What you see in the RoboHelp help file is a browse sequence
    as it is presented in a Compiled .CHM file. WebHelp and FlashHelp
    do not offer this type of a browse sequence. Instead, they use
    little Previous and Next arrows that sit just above the Table of
    Contents/Index/Glossary/Search in that little toolbar.
    Cheers... Rick

  • How to erase 2D graphics in the JLayeredPane?

    How can I erase 2D graphics(lines) in the JLayeredPane?Is there a example?
    Please help me,thanks in advance.

    I am anxious to know how to put 2D graphics in 3D TransformGroup, because
    I want to pick 2D graphics in 3D scene. For example, I drew some 2D graphics
    in 3D scene, line, sphere, rect, I may pick one using mouse. As we know, we can
    use PickMouseBehavior to pick 3D Graphics, How can I to 2D Graphics? Thanks a lot!

Maybe you are looking for