Bugzilla – Attachment 40 Details for
Bug 135
GLCanvas should interact better with lightweights
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
Updated resize issue to include new workaround and make it work with the ratified jogl release
ResizeIssue.java (text/plain), 2.06 KB, created by
Sven Gothel
on 2007-11-30 10:42:00 CET
(
hide
)
Description:
Updated resize issue to include new workaround and make it work with the ratified jogl release
Filename:
MIME Type:
Creator:
Sven Gothel
Created:
2007-11-30 10:42:00 CET
Size:
2.06 KB
patch
obsolete
>import javax.media.opengl.*; >import java.awt.*; >import javax.swing.*; > >public class ResizeIssue { > > public static void main(String[] args) { > JFrame frame = new JFrame("Resize Issue"); > frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); > > JPanel panel = new JPanel(); > panel.setPreferredSize(new Dimension(400,400)); > frame.getContentPane().add(panel); > panel.setLayout(new GridBagLayout()); > GridBagConstraints gbc = new GridBagConstraints(); > gbc.gridwidth = GridBagConstraints.REMAINDER; > gbc.gridheight = 1; > gbc.weightx = gbc.weighty = 1; > gbc.fill = GridBagConstraints.BOTH; > > JPanel redPanel = new JPanel(); > redPanel.setBackground(Color.RED); > redPanel.add(new JLabel("don't squeeze me!")); > panel.add(redPanel,gbc); > > final GLCanvas canvas = new GLCanvas(); > // Make the canvas clear itself when drawn > canvas.addGLEventListener(new GLEventListener() { > public void init(GLAutoDrawable drawable) { > drawable.getGL().glClearColor(0.3f, 0.3f, 0.3f, 1.0f); > } > public void display(GLAutoDrawable drawable) { > drawable.getGL().glClear(GL.GL_COLOR_BUFFER_BIT | > GL.GL_DEPTH_BUFFER_BIT); > } > public void reshape(GLAutoDrawable drawable, > int x, int y, int width, int height) {} > public void displayChanged(GLAutoDrawable drawable, > boolean modeChanged, boolean deviceChanged) {} > }); > > panel.add(canvas,gbc); > > // NOTE: the code below solves the problem for Java >= 1.5 > // canvas.setPreferredSize(new Dimension(0,0)); > > // NOTE: the code below solves the problem for Java < 1.5 > // JPanel cont = new JPanel(); > // cont.setLayout(new BorderLayout()); > // cont.add(canvas, BorderLayout.CENTER); > // cont.setPreferredSize(new Dimension(0, 0)); > // c.add(cont, gbc); > > frame.pack(); > frame.setVisible(true); > } >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 135
:
38
|
39
| 40