Results 1 to 1 of 1
  1. #1
    NotTooOld is offline Hostage
    Join Date
    Apr 2013
    Location
    China
    Posts
    128
    Rep Power
    0

    Default CardLayout... maybe

    I think this has to do with CardLayout. When I select a menu item that calls a method to open JFileChooser, then returns a JPanel based on the user's choice, I'm presented with an ugly white screen until the user chooses. Is there a way to prevent that? Here's the bit of code that give me a look at the CardLayout panel. (plain white)CardLayout... maybe-white-screen.gif

    Java Code:
    		final JComboBox cbLS = new JComboBox(cbLSList);
    		cbLS.setFont(new Font("Tahoma", Font.BOLD, 15));
    		cbLS.setBackground(Color.YELLOW);		
    		cbLS.setPreferredSize(new Dimension(120, 20));
    		ItemListener LessonSetListener = new ItemListener(){
    			@Override
    			public void itemStateChanged(ItemEvent e) {					////////////////////////////////////////////
    				int state = e.getStateChange();
    				if (state == 1){
    					if (e.getItem()== "Custom Lessons"){
    						cbLS.setSelectedIndex(0);
    						CardLayout cl = (CardLayout)deck.getLayout();
    						JPanel custom = Utility.fetchCustomLesson();
    						if (custom != null){
    							LessonHolderPanel.removeAll();
    							LessonHolderPanel.add(custom, BorderLayout.CENTER);
    							LessonHolderPanel.revalidate();
    							cl.show(deck, "LessonHolder");
    						}
    						else {
    							JOptionPane.showMessageDialog(null, "AlphaPattern" +
    									"could not complete the requested \n" +
    									"operation. \nPlease try again. \n" +
    									"If you continue to have trouble please \n" +
    									"contact Technical Support.");
    						}
    					}
    					else {
    					lessonSetNum = Utility.LSNumber(e.getItem().toString());
    					lessonNum = 1;
    					cbLesson.setSelectedIndex(1);
    					LessonHolderPanel.removeAll();
    					lessonNum = Utility.LSNumber(e.getItem().toString());
    					CardLayout cl = (CardLayout)deck.getLayout();
    					JPanel temp = Utility.fetchLesson(lessonSetNum, lessonNum);
    					LessonHolderPanel.add(temp, BorderLayout.CENTER);
    					LessonHolderPanel.revalidate();
    					cl.show(deck, "LessonHolder");	
    					}
    				}
    			}	
    		};
    Just kinda unhappy with the look of the blank panel.
    Last edited by NotTooOld; 05-07-2013 at 04:58 PM.

Similar Threads

  1. Problem with CardLayout
    By iNko in forum New To Java
    Replies: 9
    Last Post: 12-08-2012, 05:58 PM
  2. troubles with CardLayout
    By StaticFlow in forum AWT / Swing
    Replies: 3
    Last Post: 05-25-2012, 02:27 AM
  3. CardLayout Help
    By David M. in forum New To Java
    Replies: 4
    Last Post: 08-06-2011, 02:57 AM
  4. Help with CardLayout
    By Kyle227 in forum New To Java
    Replies: 4
    Last Post: 05-28-2010, 01:03 AM
  5. Regarding CardLayout
    By adeeb in forum AWT / Swing
    Replies: 1
    Last Post: 06-07-2008, 07:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •