Results 1 to 3 of 3

Thread: GridBag

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843
    but how? PLease help me!

    "The difference between mad and genius is the success"

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843
    This is very hard to do... see.... try this class... it makes a huge Textarea... a huge Button and a little little textfield!!!!!!!!



    Code:
    import java.awt.*;
    import java.util.*;
    
    public class p extends Frame
    
      {
      	  TextArea txtChat=new TextArea();
       	  TextField txtSend=new TextField();
       	  Button btnSend=new Button("Send Mes");
       	  
      	p()
      	  { 
      	    super("hola");
      	    this.resize(100,100);
      	    this.setVisible(true);
      	  	con();
      	  }
      
        void con()
          {
          	GridBagLayout gridbag = new GridBagLayout();
            GridBagConstraints c = new GridBagConstraints();
           
            setLayout(gridbag);
            c.fill = GridBagConstraints.HORIZONTAL; 
       	  
       	    c.gridx=0;
       	    c.gridy=0;
       	    c.gridwidth=2;
       	    gridbag.setConstraints(txtChat,c);
       	    add(txtChat);
       	    
       	    c.gridx=0;
       	    c.gridy=1;
       	    c.gridwidth=1;
       	    gridbag.setConstraints(txtSend,c);
       	    add(txtSend);
       	    
       	   
       	    c.gridx=1;
       	    c.gridy=1;
       	    gridbag.setConstraints(btnSend,c);
       	    add(btnSend);
       	   	
            txtChat.resize(10,10);
            btnSend.setSize(5,5);
          
       	   	}  
          	
          
      	public static void main(String[] args)
      	  {
      	  	p a=new p();
      	  }
      	
      }
    "The difference between mad and genius is the success"

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    I think what you would have to do is specify some external padding. (the space between the component and the edges of it's display area.) The value is specified as an Insets Object. By defalut , each component has no external padding.

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