Resizing a JFrame when JPanel resizes?
Ok, I am trying to do something in Java. I have a JPanel. This JPanel dynamically adds components to it, so it's size can change at any time. Now, I have a JFrame. This JFrame holds this JPanel. What I want is for when the JPanel gets resized (by adding a component to it), the JFrame will be resized as well. I am trying to use a ComponentListener in the JFrame, which listenes to the JPanel, and resizes the JFrame when the JPanel gets resized. However, for some reason, this Component listener doesn't work. When the JPanel is resized it doesn't run the componentResized function. It also doesn't call any other of the component functions when it should for the JPanel (like componentShown, etc...).
Example of code: Code:
public class MyPanel extends JPanel { |
Nevermind, I'm stupid.
In my program I had the lines like this: m = new MyPanel(); m.addComponentListener( new ComponentAda..... j.add(new MyPanel()); So it wasn't even using the Panel w/ the component listener! Ignore this post :) |
All times are GMT -5. The time now is 02:50 PM. |