![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Sep 2005
Posts: 3
Rep Power: 0
![]() |
Contents of JPanel not displaying
Request from a humble newbie...
I have been working on a gui with, among other elements, a JPanel that serves as an active panel for asking and answering questions. To the left of this active panel is another JPanel with a JTree that is used to navigate through the questions, the presentation of which is formatted on an instance of a JPanel and passed to the active panel. I have created a method in the active panel class to which I pass this other panel with the content that I want to have displayed in the active panel. From testing the gui, I know that the panel is being properly passed and loaded into the active panel; but I can't seem to get the desired content to appear. (How do I know it is being passed properly? Well, if I maxmize the window after calling this method, the panel displays the proper information; but if I don't do this, I can see it.) I am guessing that, by maximizing the window, I am causing the program to repaint the panel and to display the information; but when I try to repaint the panel manually, it doesn't work. In short, this is the relevant code: public class ActivePanel extends JPanel { ... public ActivePanel() { BevelBorder activeBorder = new BevelBorder( 1 ); setBorder( activeBorder ); setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); add( pnlTemp ); setPreferredSize( new Dimension( 600, 600 ) ); } public void setPanel( JPanel panel ) { // Clear existing contents of the panel removeAll(); // Add the new panel add( panel ); } } public class WelcomeHandler { ... public void actionPerformed( ActionEvent e ) { if( e.getSource() == application.mainMenu.fileNew ) { ... application.activePanel.setPanel( new WelcomePanel() ); } } } public class WelcomePanel extends JPanel { // Create and lay out properties of WelcomePanel } any help for a newbie monkeying around with this stuff? |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|