Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Sep 19th, 2005, 8:56 AM   #1
PhillyRunner
Newbie
 
Join Date: Sep 2005
Posts: 3
Rep Power: 0 PhillyRunner is on a distinguished road
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?
PhillyRunner is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:23 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC