#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    130
    Rep Power
    14

    Having trouble with setsize


    Hi all. I'm having trouble with setsize. I've seen that there is a known problem with setsize, but I'm unsure of the solution. Here's a section of code. I'm trying to set the size of the read 'Clear' button. Any help?
    PHP Code:
          //Create the navigation bar at the top of the applet
            
    JPanel jpNavigation = new JPanel();  //Create the navigation panel
            
    jpNavigation.setLayout(new BorderLayout());
            
              
    //Create the Student control Panel
                
    JPanel jpStudentControl = new JPanel();
                
    jpStudentControl.setLayout(new BorderLayout());
                        
    JButton jbtStudentDown = new JButton("<=");
                        
    JButton jbtStudentUp = new JButton("=>");
                    
    jpStudentControl.add(jbtStudentDownBorderLayout.WEST);
                    
    jpStudentControl.add(new Label("Students"), BorderLayout.CENTER);
                    
    jpStudentControl.add(jbtStudentUpBorderLayout.EAST);
                    
    jpStudentControl.add(new Label("A Total Of"), BorderLayout.SOUTH);
                
              
    //Create the Clear Button
                
    JPanel jpClearPanel = new JPanel();
                    
    JButton jbtClear = new JButton("Clear");
                    
    jbtClear.setSize(50,40);
                    
    jbtClear.setBackground(new Color(255,0,0));
                
    jpClearPanel.add(jbtClear);
                
              
    //Create the Course control Panel
                
    JPanel jpCourseControl = new JPanel();
                
    jpCourseControl.setLayout(new BorderLayout());
                        
    JButton jbtCourseDown = new JButton("<=");
                        
    JButton jbtCourseUp = new JButton("=>");
                    
    jpCourseControl.add(jbtCourseDownBorderLayout.WEST);
                    
    jpCourseControl.add(new Label("Courses"), BorderLayout.CENTER);
                    
    jpCourseControl.add(jbtCourseUpBorderLayout.EAST);
                    
    jpCourseControl.add(new Label("A Total Of"), BorderLayout.SOUTH);
            
            
    jpNavigation.add(jpStudentControlBorderLayout.WEST);
            
    jpNavigation.add(jpClearPanelBorderLayout.CENTER);
            
    jpNavigation.add(jpCourseControlBorderLayout.EAST);
            
            
    getContentPane().add(jpNavigationBorderLayout.NORTH);
            
            
    JPanel p2 = new JPanel();  //Create the Student Panel
            
    JPanel p3 = new JPanel();  //Create the Course Panel
            
    JPanel p4 = new JPanel();  //Create Bottom Panel
            
            
            
    p2.add(new Label("Student"));
            
    p3.add(new Label("Course"));
            
    p4.add(new Label("Bottom"));
            
            
    getContentPane().add(p2BorderLayout.WEST);
            
    getContentPane().add(p3BorderLayout.EAST);
            
    getContentPane().add(p4BorderLayout.SOUTH);
        } 
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    try setPreferredSize()
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    130
    Rep Power
    14
    C:\Program Files\Xinox Software\JCreator Pro\MyProjects\TME04\TME04.java:272: setPreferredSize(java.awt.Dimension) in javax.swing.JComponent cannot be applied to (int,int)

    setPreferredSize is not valid on the JButton anyway.

    Any others?

    Statik
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    130
    Rep Power
    14
    Got it:

    setPreferredSize(new Dimension(50,40));

    Statik

IMN logo majestic logo threadwatch logo seochat tools logo