Re: Create java image from Jpanel without displaying

From: FISH (joeking_at_merseymail.com)
Date: 12/05/03

  • Next message: jenniferyiu: "Bean Builder asking"
    Date: 5 Dec 2003 03:44:04 -0800
    
    

    "Moth" <no@email.here> wrote in message news:<Se7zb.36702$aT.19778@news-server.bigpond.net.au>...
    > I have a PlotPanel class that extends JPanel which I have used previously to
    > display charts in swing guis. I now want to display a graph in a jsp page
    > so I was going to generate the graph and then save it to a jpeg and then
    > display it in the page.
    >
    > Is there anyway to create an Image from a JPanel without actually displaying
    > it in a JFrame first? Can anyone suggest a better way to create a chart
    > image for servlet/jsp?

    I've not tried this personally, but in theory it should work. Create an
    Image of the appropriate size to hold the JPanel, get a Graphics object
    from it - then call the JPanel's paint() method directly with your own
    Graphics object. The component *should* paint itself, and its children,
    into your Image in exactly the same way as it does to screen.

    -FISH- ><>


  • Next message: jenniferyiu: "Bean Builder asking"

    Relevant Pages

    • Re: Getting my first custom JList to work
      ... > created a class that encapsulates each cell (and inherits JPanel) and have ... > Do I have to override paintComponentin my CustomListCellRenderer class ... can I use a JPanel to display items in a JList? ... explicitly set the text of all 3 JLabels but they are displaying as blank. ...
      (comp.lang.java.gui)
    • Re: =?ISO-8859-15?Q?!DisplayPanel_einem_JFrame_hinzuf=FCgen.?=
      ... ich habe eine Klasse Frame. ... In der soll ein neuer JFrame erzeugt werden. ... Dieses Display Panel ist ein normales JPanel dem einfach nur ein JTextField ...
      (de.comp.lang.java)
    • Best way of displaying data?
      ... I have a JPanel within which I want to display 'property - value' type data which changes according to the mouse position relative to the components in another JPanel. ... I thought about just using JLabels and a layout manager but thought that this could become very messy and have lots of niggles in it. ...
      (comp.lang.java.gui)
    • Re: Create java image from Jpanel without displaying
      ... > I have a PlotPanel class that extends JPanel which I have used previously to ... > display charts in swing guis. ... I now want to display a graph in a jsp page ... If the plotted chart, not the JPanel component itself, does matter, ...
      (comp.lang.java)
    • Re: !DisplayPanel einem JFrame =?ISO-8859-1?Q?hinzuf=FCgen=2E?=
      ... von JPanel abgeleitet ist. ... public class Frame ... //neues Panel mit Display ... DisplayPanel display = new DisplayPanel; ...
      (de.comp.lang.java)