Solved

JPanel not fitting TabbedPane

Posted on 2004-03-29
22
535 Views
Last Modified: 2013-11-23
Why does this JPanel fill up the TabbedPane. While the JPanel Below this one doesn't. Can someone help me with this.

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.awt.Color.*;



public class TraineeInfo extends JPanel implements ActionListener
{ // Opens class

           
     
     
     // Text fields for user input
     private JTextField name;
     private JTextField street;
     private JTextField city;
     private JTextField statezip;  
             
     // Labels to go with each text field
     private JLabel lname;
     private JLabel lstreet;
     private JLabel lcity;
     private JLabel lstatezip;          
           
     // Check boxes for types of training
     private JCheckBox ow;
     private JCheckBox a;
     private JCheckBox res;
     private JCheckBox un;
     private JCheckBox w;
             
     // Textfields for Emergency box
     private JTextField nname;
     private JTextField phone;
     private JTextField rel;
     
     // Textfields for Emergency Contact
     private JLabel lnname;
     private JLabel lphone;
     private JLabel lrel;
     
     // Buttons and image
     private JButton enter;
     private JButton edit;
     private JLabel seahorse;
             
     // Panels to be built and added
     // to the border layout of this
     // panel.
             
     private JPanel images;
     private JPanel jaddress;
     private JPanel emerg;
     private JPanel training;
             
     // Class to handle functionality of checkboxes  
     ItemListener handler = new CheckBoxHandler();
             
                         
     // Class constructor that builds the necessary
     // labels and text fields images, buttons,
     // and panels.        
         
          public TraineeInfo()
            { // Opens Constructor
             // Sets layout for Trainee panel
             setLayout(new BorderLayout());
             // Sets background color for
             // Diver panel
             setBackground(Color.white);
             
             // Initializes textfields
             name = new JTextField("Enter Your Name");
             street = new JTextField();
             city = new JTextField ();
             statezip = new JTextField ();
             // Initializes labels for textfields
             lname = new JLabel("Name: ");
             lstreet = new JLabel("Street: ");
             lcity = new JLabel ("City: ");
             lstatezip = new JLabel("State & Zip Code: ");
             // Initializes checkboxes with titles
             ow = new JCheckBox("Beginner", true);
             a = new JCheckBox("Advanced");
             res = new JCheckBox("Accomplished");
             un = new JCheckBox("Teacher Trainer");
             w = new JCheckBox("Teacher");
             
             // Initializes textfields for emergency panel
             nname = new JTextField();
             phone = new JTextField();
             rel = new JTextField ();
             // Initializes labels for textfields
             lnname = new JLabel("Name: ");
             lphone = new JLabel("Phone: ");
             lrel = new JLabel ("Relationship: ");
             // Initialize objects
             enter = new JButton("Enter Diver Data");
             edit = new JButton("Edit Diver Data");
             seahorse = new JLabel("",  
                  new ImageIcon("images/2seahorses.jpg"),
                                          JLabel.CENTER);
             // Calls method to buid image panel, which
             // is defined outside of the constructor
             buildImagePanel();    
             
             // Calls method to buid address panel, which
             // is defined outside of the constructor        
             buildAddressPanel();
             
             // Calls method to buid emerg panel, which
             // is defined outside of the constructor
             buildEmergencyPanel();
             
             // Calls method to buid training panel, which
             // is defined outside of the constructor
             buildTrainingPanel();
             
           //The methods called above build the panels, then this
          // call to add adds each panel to the main panel's
          // border layout manager.
     
           add(jaddress, BorderLayout.NORTH);
           add(images, BorderLayout.CENTER);
           add(training, BorderLayout.EAST);
           add(emerg, BorderLayout.SOUTH);
       
       
        } // Ends constructor
       
       
        // This method creates a panel called images
        private void buildImagePanel()
        { // Opens method
           images = new JPanel();
          // Sets the color, layout, and adds the
          // seahorse object
           images.setBackground(Color.white);
           images.setLayout(new FlowLayout() );
           images.add(seahorse);
          } // Closes method
       
        private void buildAddressPanel ()
        { // Opens method
          jaddress = new JPanel();
          // Sets color and layout.
          // Adds the textfields and labels for
          // diver input.
          jaddress.setBackground(Color.white);
          jaddress.setLayout( new  GridLayout(2, 4, 20, 20) );
          //Adds each component to the panel
          jaddress.add(lname);
          jaddress.add(name);
          jaddress.add(lstreet);
          jaddress.add(street);
          jaddress.add(lcity);  
          jaddress.add(city);  
          jaddress.add(lstatezip);  
          jaddress.add(statezip);
 
          // Sets a border around the panel, including
          // a title
          jaddress.setBorder(BorderFactory.createTitledBorder(
                                    "Diver Personal Information"));
             
          //Listeners for each text field in the
          name.addActionListener( this );
          street.addActionListener( this );
          city.addActionListener( this );
          statezip.addActionListener( this );
           
        } // Closes method
       
        private void buildEmergencyPanel()
         { // Opens method
          //Create another panel for emergency input fields
            emerg = new JPanel();
            emerg.setLayout( new  GridLayout(2, 4, 20, 0) );
            emerg.setBackground(Color.white);
         
            emerg.add( lnname);
            emerg.add( nname);
            emerg.add( lphone);
            emerg.add( phone);
            emerg.add( lrel);  
            emerg.add( rel);
            emerg.add(enter);
            emerg.add(edit);
           //Creates titled border around emerg panel
            emerg.setBorder(BorderFactory.createTitledBorder("Emergency"));

            //Adds an actionListener for Emergency Info
            nname.addActionListener( this );
            phone.addActionListener( this );
            rel.addActionListener( this );
           
           
            //Creates borders around the Edit and
            // Enter Diver Data buttons
            enter.setBorder(BorderFactory.createRaisedBevelBorder());
            edit.setBorder(BorderFactory.createRaisedBevelBorder());
     
             //Listeners for the buttons
             enter.addActionListener( this );
             edit.addActionListener( this );
            } //Closes method
       
        private void buildTrainingPanel()
        { //Opens method
       
          // Creates a panel for training courses
     
           training = new JPanel();
           training.setBackground(Color.white);
           training.setLayout(new GridLayout(5, 1, 10, 20 ) );
           //sets backgrounds of components to white
           training.add(ow).setBackground(Color.white);
           training.add(a).setBackground(Color.white);
           training.add(un).setBackground(Color.white);
           training.add(res).setBackground(Color.white);
           training.add(w).setBackground(Color.white);
       
          //Sets a titled border around training panel
          training.setBorder(BorderFactory.createTitledBorder("Training"));
          //Adds listeners to checkbox items
            ow.addItemListener(handler);
            a.addItemListener(handler);
            un.addItemListener(handler);
            res.addItemListener(handler);
            w.addItemListener(handler);
         } //Closes method
     
      // Prints the input into JLabels and hides text fields, or
      // returns the text fields so input may be changed
   
      public void actionPerformed(ActionEvent evt)
        { // Opens method
        // Checks if the button clicked was the
        // Enter Diver Data button.
        // If not, moves on to next if statment.
        // Otherwise it enters this if statement
        if ((evt.getSource() == name) || (evt.getSource() == enter))
             { // Opens if statement
              //Retrives the text from the name text field and
              //assigns it to the variable nameText of
              //type String
              String nameText = name.getText();
              lname.setText("Name:    " + nameText);
              //After printing text to JLabel, hides the textfield
              name.setVisible(false);
              }// ends if statement
        if ((evt.getSource() == street) || (evt.getSource() == enter))
             { // Opens if statement                        
              String streetText = street.getText();
              lstreet.setText("Street:    " + streetText);
              street.setVisible(false);
               }// ends if statement  
         if ((evt.getSource() == city) || (evt.getSource() == enter))  
             { // Opens if statement          
              String cityText = city.getText();
              lcity.setText("City:  " + cityText);
              city.setVisible(false);
                   }// ends if statement        
         if ((evt.getSource() == statezip) || (evt.getSource() == enter))
             { // Opens if statement            
              String statezipText = statezip.getText();
              lstatezip.setText("State & Zip:     " + statezipText);
              statezip.setVisible(false);
                   }// ends if statement        
        if ((evt.getSource() == nname) || (evt.getSource() == enter))
             { // Opens if statement            
              String relname = nname.getText();
              lnname.setText("Name:   " + relname);
              nname.setVisible(false);
                    }// ends if statement        
        if ((evt.getSource() == phone) || (evt.getSource() == enter))
             { // Opens if statement              
              String relphone = phone.getText();
              lphone.setText("Phone:   " + relphone);
              lphone.setForeground(Color.red);
              phone.setVisible(false);
              }
        if ((evt.getSource() == rel) || (evt.getSource() == enter))  
        {            
              String relString = rel.getText();
              lrel.setText("Relationship:   " + relString);
              rel.setVisible(false);
   
 
          // If Edit button was clicked, set textfields to
          // visible for user to reenter information and
          // it sets the text that had been entered to
          // to an empty String, giving the appearance
          // that the text has been removed.  
          } // Closes if statement
           if (evt.getSource() == edit)
              { // Opens else if statement
       
           // If edit button has been pressed
           // the following is set to visible
            name.setVisible(true);
            street.setVisible(true);
            city.setVisible(true);
            statezip.setVisible(true);
           
            // Relative's info
           
            nname.setVisible(true);
            phone.setVisible(true);
            rel.setVisible(true);
           
            lnname.setText("Name:   ");
            lnname.setForeground(Color.black);
            lphone.setText("Phone:   ");
            lphone.setForeground(Color.black);
            lrel.setText("Relationship:   ");
            lrel.setForeground(Color.black);
       
         } // Ends if statement
       
        } // Ends actionPerformed method

 // Inner class that handles functionality for the
 // checkboxes.
 private class CheckBoxHandler implements ItemListener
 { // Opens inner class
       
      public void itemStateChanged (ItemEvent e)
        { // Opens method
               // Retrieves object that fires an
               // event, casts it as a JCheckBox
               // object and assigns it to source.
               JCheckBox source = (JCheckBox) e.getSource();
               // If the object is selected . . .
               if ( e.getStateChange() == ItemEvent.SELECTED )
                 // change the foreground to blue
                 source.setForeground(Color.blue);
                 // otherwise set the foreground to black.
               else
                 source.setForeground(Color.black);
             
             } // Closes ItemStateChanged method
      } // Closes class CheckBoxHandler
 
 
     
  } // Closes Class Trainee




import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Kempos extends JPanel
{ // Opens class

    public Kempos()
    {
        super();

        Font f1 = new Font("Courier New", Font.BOLD, 15);

        JPanel p1 = new JPanel();
        JPanel p2 = new JPanel();
        JPanel p3 = new JPanel();
        JPanel p4 = new JPanel();
        JPanel p5 = new JPanel();

        final JButton b1 = new JButton("G1");
        final JButton b2 = new JButton("G2");
        final JButton b3 = new JButton("G3");
        final JButton b4 = new JButton("G4");
        final JButton b5 = new JButton("G5");
        final JButton b6 = new JButton("G6");
        final JButton b7 = new JButton("G7");
        final JButton b8 = new JButton("G8");

        final JLabel l1 = new JLabel();
        l1.setBorder(BorderFactory.createLineBorder(Color.yellow));

        p1.setBorder(BorderFactory.createLoweredBevelBorder());
        p4.setBorder(BorderFactory.createLoweredBevelBorder());
        p4.setBackground(Color.blue);

        p1.setLayout(new GridLayout(1,2));
        p1.add(p2); p1.add(p3);

        p2.setLayout(new GridLayout(1,1));
        p2.add(p4);

        p4.setLayout(new GridLayout(3,3));
        p4.add(b1); p4.add(b2); p4.add(b3);
        p4.add(b4); p4.add(l1); p4.add(b5);
        p4.add(b6); p4.add(b7); p4.add(b8);

        p5.setLayout(new GridLayout(5,1));
        p5.add(new JLabel("Name 1\n"));
        p5.add(new JLabel("Name 2"));
        p5.add(new JLabel("Name 3"));
        p5.add(new JLabel("Name 4"));
        p5.add(new JLabel("Name 5"));
 
        p3.setLayout(new GridLayout(1,3));
        p3.add(new JPanel()); p3.add(p5);
        p3.add(new JPanel());

        add(p1, BorderLayout.CENTER);

        // Add your action listener here . . .
        b1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G1       ");
        b1.setText("");
        b1.setEnabled(false);
        }
        });

        b2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G2       ");
        b2.setText("");
        b2.setEnabled(false);
        }
        });

        b3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G3       ");
        b3.setText("");
        b3.setEnabled(false);
        }
        });

        b4.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G4       ");
        b4.setText("");
        b4.setEnabled(false);
        }
        });

        b5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G5       ");
        b5.setText("");
        b5.setEnabled(false);
        }
        });

        b6.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G6       ");
        b6.setText("");
        b6.setEnabled(false);
        }
        });

        b7.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G7       ");
        b7.setText("");
        b7.setEnabled(false);
        }
        });

        b8.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G8       ");
        b8.setText("");
        b8.setEnabled(false);
        }
        });
    }
}

 
0
Comment
Question by:Drop_of_Rain
  • 10
  • 8
  • 4
22 Comments
 
LVL 30

Expert Comment

by:mayankeagle
ID: 10702569
Why do you have so many JPanels inside the second JPanel? And you also add some more, like: p3.add(new JPanel());
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10702581
In the first you explicitely set

setLayout(new BorderLayout());

In the second you don't.
Just do it.
0
 

Author Comment

by:Drop_of_Rain
ID: 10702608
In order to create the layout. Didn't know how to any other way. Someone created this idea to help organize all of the checkboxs in one area, and get the focus of one at a time.
0
 

Author Comment

by:Drop_of_Rain
ID: 10702617
By using that wouldn't it change the layout. Where would that be olaced to not upset the layout as it is now?
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10702618
I guess that's an answer on mayankeagle's question...

If you don't set the layout of a JPanel it's FlowLayout by default.
0
 

Author Comment

by:Drop_of_Rain
ID: 10702624
But it seems to me that the layout is GridLayout.
0
 
LVL 30

Expert Comment

by:mayankeagle
ID: 10702632
It is indeed set to GridLayout. Are you using setSize () anywhere (not posted in the above code)?
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10702649
You don't understand:

public TraineeInfo() { // Opens Constructor
             // Sets layout for Trainee panel
             setLayout(new BorderLayout());   // <<<<<<<<<<< OK!
             ...

           add(jaddress, BorderLayout.NORTH);
           add(images, BorderLayout.CENTER);
           add(training, BorderLayout.EAST);
           add(emerg, BorderLayout.SOUTH);
       
        } // Ends constructor
}

while

public Kempos() {
   ...
   add(p1, BorderLayout.CENTER);  // <<< you add in the center,
                                                  // but you don't have BorderLayout
   ...    
}

Correct like this:

public Kempos() {
   ...
   setLayout(new BorderLayout());
   add(p1, BorderLayout.CENTER);  // <<< you add in the center,
                                                  // but you don't have BorderLayout
   ...    
}

0
 

Author Comment

by:Drop_of_Rain
ID: 10702651
I didn't know how big to set it, to fit in the size of the frame: dlframe.setSize(765, 690).  I looked in the search for SetSize in LPanel but didn't find anything. So I didn't have any examples for me to follow.
0
 

Author Comment

by:Drop_of_Rain
ID: 10702676
Not with that one. With Kempos. With the GrigLayout. That is the one I am having problems with.
0
 
LVL 30

Expert Comment

by:mayankeagle
ID: 10702694
That's what zzynx is saying. You have not set the layout of Kempos to BorderLayout.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 30

Expert Comment

by:mayankeagle
ID: 10702705
You have set the Layout of p1, p2, etc to GridBag - that's ok. But not for their container Kempos. And you're attempting to add them to the Container Kempos using BorderLayout constants though you have not set that Layout.
0
 

Author Comment

by:Drop_of_Rain
ID: 10702745
Ok boy was that an over sight. But now how do I make the layout larger on the left and smaller on the right.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10702972
Which layout (which panel) are you talking about?
0
 

Author Comment

by:Drop_of_Rain
ID: 10705624
There are to groups of things on the main panel. A group og checkbox groups on the left, and a list of the names of the groups on the right.  I need the names side to be propionate to the whole layout.

This code will let you look at it.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class MyFrame3 extends JFrame
{
    public MyFrame3()
    {
        super("Sample . . .");

        Font f1 = new Font("Courier New", Font.BOLD, 15);

        JPanel p1 = new JPanel();
        JPanel p2 = new JPanel();
        JPanel p3 = new JPanel();
        JPanel p4 = new JPanel();
        JPanel p5 = new JPanel();
        JPanel p6 = new JPanel();

        final JButton b1 = new JButton("G1");
        final JButton b2 = new JButton("G2");
        final JButton b3 = new JButton("G3");
        final JButton b4 = new JButton("G4");
        final JButton b5 = new JButton("G5");
        final JButton b6 = new JButton("G6");
        final JButton b7 = new JButton("G7");
        final JButton b8 = new JButton("G8");

        final JButton b9 = new JButton("Restart");
        final JButton b0 = new JButton("   Exit    ");

       b9.setMnemonic('R'); b0.setMnemonic('E');

        final JLabel l1 = new JLabel();
        l1.setBorder(BorderFactory.createLineBorder(Color.blue));

        p1.setBorder(BorderFactory.createLoweredBevelBorder());
        p4.setBorder(BorderFactory.createLoweredBevelBorder());
        p4.setBackground(Color.white);

        p1.setLayout(new GridLayout(1,2));
        p1.add(p2); p1.add(p3);

        p2.setLayout(new GridLayout(1,1));
        p2.add(p4);

        p4.setLayout(new GridLayout(3,3));
        p4.add(b1); p4.add(b2); p4.add(b3);
        p4.add(b4); p4.add(l1); p4.add(b5);
        p4.add(b6); p4.add(b7); p4.add(b8);

        p5.setLayout(new GridLayout(5,1));
        p5.add(new JLabel("Name 1\n"));
        p5.add(new JLabel("Name 2"));
        p5.add(new JLabel("Name 3"));
        p5.add(new JLabel("Name 4"));
        p5.add(new JLabel("Name 5"));
 
        p3.setLayout(new GridLayout(1,3));
        p3.add(new JPanel()); p3.add(p5);
        p3.add(new JPanel());

        p6.add(b9); p6.add(b0);

        this.getRootPane().setDefaultButton(b9);
        this.getContentPane().add(p1, BorderLayout.CENTER);
        this.getContentPane().add(p6, BorderLayout.SOUTH);

        this.setResizable(false);
        this.setSize(800, 600);
        this.setVisible(true);

        // Add your action listener here . . .
        b1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G1       ");
        b1.setText("");
        b1.setEnabled(false);
        }
        });

        b2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G2       ");
        b2.setText("");
        b2.setEnabled(false);
        }
        });

        b3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G3       ");
        b3.setText("");
        b3.setEnabled(false);
        }
        });

        b4.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G4       ");
        b4.setText("");
        b4.setEnabled(false);
        }
        });

        b5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G5       ");
        b5.setText("");
        b5.setEnabled(false);
        }
        });

        b6.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G6       ");
        b6.setText("");
        b6.setEnabled(false);
        }
        });

        b7.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G7       ");
        b7.setText("");
        b7.setEnabled(false);
        }
        });

        b8.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G8       ");
        b8.setText("");
        b8.setEnabled(false);
        }
        });

        b9.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("");

        b1.setText("G1");
        b2.setText("G2");
        b3.setText("G3");
        b4.setText("G4");
        b5.setText("G5");
        b6.setText("G6");
        b7.setText("G7");
        b8.setText("G8");

        b1.setEnabled(true);
        b2.setEnabled(true);
        b3.setEnabled(true);
        b4.setEnabled(true);
        b5.setEnabled(true);
        b6.setEnabled(true);
        b7.setEnabled(true);
        b8.setEnabled(true);
        }
        });

        b0.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        System.exit(0);
        }
        });
    }

    public static void main(String[] args)
    {
      MyFrame3 x = new MyFrame3();
      x.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }
}
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10707594
>> Ok boy was that an over sight.
Is that issue (Panel not filling up the tabbed pane) solved then? Or not?
Not clear to me.

>>But now how do I make the layout larger on the left and smaller on the right.
>>A group og checkbox groups on the left, and a list of the names of the groups on the right.  
>>I need the names side to be propionate to the whole layout.

Well, that's typically something asking for a BorderLayout too.
Give the panel containing the two panels you're talking about a BorderLayout.
Put the panel containing the checkboxes (PnlX) in the West.
Put the panel containing the list of names (PnlY) in the center.

This way PnlX will go as wide as needed and PnlY will fill up all the remaining spacing, no matter how much.

btw:
You're talking about checkboxes, but I only see JButton's in your last code snippet.
That's why I couldn't be more precise also. I couldn't link your request with the posted code.

0
 

Author Comment

by:Drop_of_Rain
ID: 10711093
I have changed the borderlayout to EAST on panel1, and CENTER on panel 3 and it helped some but it is still larger then I would like it to be. Because all there will be on the other panel will be text names, linking to the center panel of the other panel. That is where the focus will go to change the checkboxs in a group. This layout is only using buttons at this time until I get the layout correct. If anyone knows of a better way to do this let me know and can you show me.

 I don't know how to fix this problem. Anyone that can help it will be much appreciated. Thanks in advance everyone out there.




  import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Kempos extends JPanel
{ // Opens class

    public Kempos()
    {
        super();

        Font f1 = new Font("Courier New", Font.BOLD, 15);
        setLayout(new BorderLayout());
   
        JPanel p1 = new JPanel();
        JPanel p2 = new JPanel();
        JPanel p3 = new JPanel();
        JPanel p4 = new JPanel();
        JPanel p5 = new JPanel();
       
        final JButton b1 = new JButton("G1");
        final JButton b2 = new JButton("G2");
        final JButton b3 = new JButton("G3");
        final JButton b4 = new JButton("G4");
        final JButton b5 = new JButton("G5");
        final JButton b6 = new JButton("G6");
        final JButton b7 = new JButton("G7");
        final JButton b8 = new JButton("G8");

        final JLabel l1 = new JLabel();
        l1.setBorder(BorderFactory.createLineBorder(Color.yellow));

        p1.setBorder(BorderFactory.createLoweredBevelBorder());
        p4.setBorder(BorderFactory.createLoweredBevelBorder());
        p4.setBackground(Color.blue);
       
        p1.setLayout(new BorderLayout());
        add(p1, BorderLayout.EAST);
        p1.add(p2);
        p1.setLayout(new GridLayout(1,2));
        p1.add(p2);
        p1.add(p3, BorderLayout.CENTER);

        p2.setLayout(new GridLayout(1,1));
        p2.add(p4);

        p4.setLayout(new BorderLayout());
        add(p4, BorderLayout.CENTER);
        p4.setLayout(new GridLayout(3,3));
        p4.add(b1); p4.add(b2); p4.add(b3);
        p4.add(b4); p4.add(l1); p4.add(b5);
        p4.add(b6); p4.add(b7); p4.add(b8);
       
        p5.setLayout(new GridLayout(5,1));
        p5.add(new JLabel("Name 1\n"));
        p5.add(new JLabel("Name 2"));
        p5.add(new JLabel("Name 3"));
        p5.add(new JLabel("Name 4"));
        p5.add(new JLabel("Name 5"));
       
       
        p3.setLayout(new GridLayout(1,3));
        p3.add(new JPanel()); p3.add(p5);
        p3.add(new JPanel());

       

        // Add your action listener here . . .
        b1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G1       ");
        b1.setText("");
        b1.setEnabled(false);
        }
        });

        b2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G2       ");
        b2.setText("");
        b2.setEnabled(false);
        }
        });

        b3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G3       ");
        b3.setText("");
        b3.setEnabled(false);
        }
        });

        b4.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G4       ");
        b4.setText("");
        b4.setEnabled(false);
        }
        });

        b5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G5       ");
        b5.setText("");
        b5.setEnabled(false);
        }
        });

        b6.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G6       ");
        b6.setText("");
        b6.setEnabled(false);
        }
        });

        b7.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G7       ");
        b7.setText("");
        b7.setEnabled(false);
        }
        });

        b8.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent h)
        {
        l1.setText("       G8       ");
        b8.setText("");
        b8.setEnabled(false);
        }
        });
    }
}
0
 
LVL 37

Accepted Solution

by:
zzynx earned 350 total points
ID: 10711221
>> I have changed the borderlayout to EAST on panel1
Didn't I say West? Anyway, your choice.

>> but it is still larger then I would like it to be
Which one? The one place at the EAST?
Something placed on the east takes as much place (width) as the widest preferred width of the components that are in.
Making these smaller, will lead to a smaller east panel

Once again:
Is that issue (Panel not filling up the tabbed pane) solved then? Or not?
0
 

Author Comment

by:Drop_of_Rain
ID: 10711324
Thanks for all the help!
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10711350
Thanks for accepting.
This indicates our help is appreciated and I'll look forward to help you in the future too.
:)
0
 

Author Comment

by:Drop_of_Rain
ID: 10711376
You have had some great approaches towards fining a solution. Very good suggestions as well. I am amazed how you guys can translate ideas into code. I hope I can learn to do this, I can do with other things,

Thanks again.
Christopher
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10711423
>> I hope I can learn to do this
Certainly! I develop in Java for only a year now. (I had a background in C/C++)
Thanks again for your appreciation.
Glad to be able to help you out.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now