Reputation: 2243
I wanna know... is there a way to draw the components style outside from Frame/Applet? I'm making a application that uses OpenGL, and I need a GUI with a good look, like AWT or Swing. Yes, I know that there are many libraries like Nifty and TWL, but I really want use AWT/Swing look.
Thanks. (And sorry for my bad english, I'm brazilian.)
Upvotes: 0
Views: 261
Reputation: 16364
You can render a component to an image, even if it is not displayable (although you will have to manually set the size to the preferred size):
c.setSize(c.getPreferredSize());
BufferedImage img = new BufferedImage(c.getWidth(), c.getHeight(),
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = image.createGraphics();
g.setComposite(AlphaComposite.Clear);
g.fillRect(0, 0, c.getWidth(), c.getHeight());
g.setComposite(AlphaComposite.SrcOver);
c.paintComponent(g);
g.dispose();
You can then use that image as a texture in OpenGL.
Of course, this will only give you a picture of the component; you won't be able to interact with it as you could with a "real" swing component.
Upvotes: 1