Results 1 to 3 of 3
  1. #1
    lenny is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default Use the Layout in java

    Hi, look at the code below

    Java Code:
    Pane = new JPanel();		
    
    Label1 = new JLabel("1");
    Pane.add(Label1);
    
    Label2 = new JLabel("2");
    Pane.add(Label2);
    
    Label3 = new JLabel("3");
    Pane.add(Label3);
    
    Label4 = new JLabel("4");
    Pane.add(Label4);
    
    Label5 = new JLabel("5");
    Pane.add(Label5);
    
    Label6 = new JLabel("6");
    Pane.add(Label6);
    what if i want to add Label4, Label5, & Label6 to the next line?
    so it would look like:
    Java Code:
    Label1            Label2            Label3
    
    Label4            Label5            Label6
    Thanks

  2. #2
    xCLARAx is offline Member
    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0

    Default

    Java Code:
    public class test extends JFrame
    {
    	private JPanel Pane;
    	private JLabel Label1,Label2,Label3,Label4,Label5,Label6;
    	
        public test() 
        {
    		setSize(300,200);
    		setLayout(new GridLayout(1,1));
    		
        	Pane = new JPanel();
        	
        	Pane.setLayout(new GridLayout(2,3));		
    
    		Label1 = new JLabel("1");
    		Pane.add(Label1);
    		
    		Label2 = new JLabel("2");
    		Pane.add(Label2);
    		
    		Label3 = new JLabel("3");
    		Pane.add(Label3);
    		
    		Label4 = new JLabel("4");
    		Pane.add(Label4);
    		
    		Label5 = new JLabel("5");
    		Pane.add(Label5);
    		
    		Label6 = new JLabel("6");
    		Pane.add(Label6);
    		
    		add(Pane);
        }
        
         public static void main(String[] args)
        {
        	test jrframe = new test();
            jrframe.setVisible(true); 
        }
        
    }
    Last edited by levent; 07-26-2007 at 07:20 PM. Reason: Code is placed inside [code] tag.

  3. #3
    levent Guest

    Default

    xCLARAx: Please use [code] tag when you post some code next time. It will make your code more readable.

Similar Threads

  1. how to get layout information from pdf using java
    By aravind730 in forum Java Tip
    Replies: 0
    Last Post: 02-09-2008, 06:59 PM
  2. website java button layout
    By abcdefg in forum AWT / Swing
    Replies: 0
    Last Post: 12-25-2007, 04:44 PM
  3. Help with JButton and layout
    By adlb1300 in forum AWT / Swing
    Replies: 1
    Last Post: 12-25-2007, 08:33 AM
  4. JGraph Layout Pro 1.4.0.3
    By levent in forum Java Software
    Replies: 0
    Last Post: 07-31-2007, 06:43 PM

Posting Permissions

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