Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By jim829

Thread: Container Error !!

  1. #1
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Container Error !!

    Java Code:
    import java.io.*;
    import javax.swing.*;
    import java.awt.event.*;
    
    
    public class Exx{
    
    public static void main(String Dev[]){
    
         
    	 
          JFrame jf=new JFrame("test");
          
    	  //JButton jb=new JButton("Add");
    	  
          jf.setVisible(true);
          jf.setLayout(null);
    	  jf.setBounds(100,50,400,400);
          jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
    	  
    	  Container ct=jf.getContentPane();
    	  //ct.add(jt);
    	   
    	  /**JTextField jt=new JTextField();
          jt.setBounds(10,20,200,300);
    	  ct.add(jt);
    	  
    	  
    	  jf.add(jb);
          jb.setBounds(100,320,60,30);
          	  
    		  
    		  jb.addActionListener(new ActionListener(){
    			public void actionPerformed(ActionEvent ae){
    				String s=jt.getText();
    				
    				try{
    					
    					FileWriter fw=new FileWriter("D:/now.txt",true);
    	 
                    	 BufferedWriter bf=new BufferedWriter(fw);
    	 
    	                 bf.write(s);
                         bf.newLine();
    	 
    	                 bf.close();
    
    				}
    				catch(IOException io){}
    				
    			}  
    		  
    		  
    		  });**/
    	  
         
    }
    
    
    }

    why Container showing this error

    ERROR :- Cannot Find Symbol
    Container ct=jf.getContentPane();
    ^

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Container Error !!

    Probably because you didn't import it.

    import java.awt.Container;

    Regards,
    Jim
    vknehra10 likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

Similar Threads

  1. JDialog and "adding a window to a container" error
    By yalondg in forum AWT / Swing
    Replies: 3
    Last Post: 04-15-2012, 09:37 AM
  2. Help with adding a Container within a Container
    By JoKeR313 in forum New To Java
    Replies: 4
    Last Post: 01-02-2011, 04:59 AM
  3. Replies: 3
    Last Post: 04-21-2009, 11:01 PM

Tags for this Thread

Posting Permissions

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