View Single Post
  #4 (permalink)  
Old 04-24-2008, 08:07 PM
hardwired hardwired is online now
Senior Member
 
Join Date: Jul 2007
Posts: 1,017
hardwired is on a distinguished road
I want that graph to pop up in another window though
Launch a JDialog and add the graphic component (JPanel) to it.
Somewhere in_or_called_from_your_event_code:
Code:
GraphicPanel graphicPanel = new GraphicPanel(image, data); JDialog dialog = new JDialog(desired_args); dialog.add(graphicPanel); // configure dialog as desired dialog.setVisible(true);
How do I draw that background image into the program ?
Code:
class GraphicPanel extends JPanel { BufferedImage bgImage; int[][] data; GraphicPanel(BufferedImage image, int[] data) { bgImage = image; this.data = data; } protected void paintComponent(Graphics g) { super.paintComponent(g); int x = 10; int y = 10; g.drawImage(bgImage, x, y, this); // draw your grid lines... // draw your data points/lines as desired... } }
Reply With Quote