posted 17 years ago
Hi, hope someone can help!
My program is a public class MyJFrame that extends JFrame (the main() is in here). It can pop up a modal dialog, MyJDialog that extends JDialog. MyJDialog actually instantiates MyImageJPanel, and in the MyJDialog constructor does a setContentPane(MyImageJPanel). MyImageJPanel looks like this:
What my program can do right now is allow people to pick picture files with JFileChooser, and then when they're done, they click on another button which brings up the modal dialog which displays all of the pictures they've chosen. It just cycles through them automatically using a Timer in MyJDialog. When the it gets the Timer event, it will call the repaint() method. (My code also calls repaint when the dialog is first brought up.) This all works right now.
However, what I really want to do is add some controls to the dialog. For example, I want to add some buttons so that someone can manually step through the pictures. I thought this would be easy! I figured it would just be a matter of adding a main panel to MYJDialog, adding the image panel to the main panel, and then adding another panel to hold the buttons to main panel.
I see my new button, but I don't see the pictures anymore. Conversely, if I change the last line to setContentPane(imagePanel) then I get my pictures like before, but there is no new button. It doesn't seem like these panels are co-existing with each other! How can I work it, so that I have both the pictures working the way they were, sitting alongside some new buttons, both of them in the dialog?