Results 1 to 3 of 3

Thread: Content Pane?

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Smile Content Pane?

    Does anyone know what a Content Pane is? Can a component
    be added to a JFrame directly or do i have to add it to a content pane first? Im just not sure about the purpose of a Content Pane.

  2. #2

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    For instance this code produces a runtime error. Do i have to
    add the components to a panel then add the panel to a Content Pane then add the content pane to a JFrame? Writing GUI's in Java can be a real pain in the ass.

    Code:
      import java.awt.*; 
      import javax.swing.*;
      import java.awt.event.*; 
          
       
      public class Test{ 
       public static void main(String[] args){
           JFrame jf = new JFrame("A Frame");  
           JPanel jp = new JPanel();
        
           JButton jb = new JButton("A Button"); 
           JTextArea jta1 = new JTextArea(); 
           JTextArea jta2 = new JTextArea();
      
           jp.setLayout(new GridLayout(1,2));
           jp.add(jb);  
           jp.add(jta1);
           jp.add(jta2);
            
           
          jf.add(jp); 
          jf.setSize(600,300);
          jf.setVisible(true);  
     
         jf.addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e){
               System.exit(0); 
            }
          });
      }
     }

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Never mind i got it.

Posting Permissions

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



Click Here to Expand Forum to Full Width