Created
October 18, 2012 01:40
-
-
Save brandonborkholder/3909397 to your computer and use it in GitHub Desktop.
Using GLG2D in an existing application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// all painting is done to this single JComponent (or subclass) | |
JComponent paintingCanvas = new JComponent() { | |
public void paintComponent(Graphics g) { | |
super.paintComponent(g); | |
// paint the scene to the Graphics object | |
} | |
}; | |
JFrame frame = // ... | |
frame.setContentPane(paintingCanvas); | |
// add an animator to paintingCanvas | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JComponent paintingCanvas = new JComponent() { | |
public void paintComponent(Graphics g) { | |
super.paintComponent(g); | |
// paint the scene to the Graphics object | |
} | |
}; | |
// if all painting is done to the single JComponent above | |
// then | |
paintingCanvas = new G2DGLCanvas(paintingCanvas); | |
// else if paintingCanvas has a hierarchy of Swing components added to it | |
// then | |
paintingCanvas = new G2DGLPanel(paintingCanvas); | |
// this handles the RepaintManager issues of subcomponents, but is not as stable or as fast | |
JFrame frame = // ... | |
frame.setContentPane(paintingCanvas); | |
// add an animator to the new paintingCanvas | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment