[RESOLVED] Adding more than one JPanel to my JFrame(North,South)-VBForums
Results 1 to 1 of 1

Thread: [RESOLVED] Adding more than one JPanel to my JFrame(North,South)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2012
    Posts
    119

    Resolved [RESOLVED] Adding more than one JPanel to my JFrame(North,South)

    I want to add two Jpanel on my tabbed pane ,one should be in south with buttons,and other should be in north where I have Text fields and Labels.
    My problem is that the buttons on container Jpanel is not showing in south.

    Here is the code

    Code:
    public class Mainframe extends JFrame
    {	/**
    	 * 
    	 */
    	private static final long serialVersionUID = 1L;
    	JTabbedPane tabbedPane = new JTabbedPane();
        JPanel jp1 = new JPanel();    
        JPanel container = new JPanel();
        JFrame frame = new JFrame("TEST");     
        JButton button1 = new JButton("Button 1");
        JButton button2 = new JButton("Button 2");
        JButton button3 = new JButton("Button 3");
        JButton button4 = new JButton("Button 4");
        JButton button5 = new JButton("Button 5");
    	/**
    	 * @param args
    	 */
    	private Mainframe()
    	{	
    		
    		Container contentPane = getContentPane();
    		container.setLayout(new FlowLayout());				
    		BufferedImage myPicture = null;
    		try
    		{			
    			myPicture = ImageIO.read(new File("FINAL.jpg"));
    		} 
    		catch (IOException e1)
    		{
    			
    			e1.printStackTrace();
    		}		
    		
    		JLabel lbl = new JLabel(new ImageIcon(myPicture));		
    		container.add(lbl);
    		container.add(button1);
    		container.add(button2);
    		container.add(button3);
    		container.add(button4);
    		container.add(button5);
    		jp1.add(container,BorderLayout.SOUTH);
                    frame.add(tabbedPane);
    		tabbedPane.addTab("First Tab",jp1);	
    	frame.setPreferredSize(new Dimension(1500, 1210));
    
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.pack();
            frame.setResizable(true);
            frame.setVisible(true);
    
    }
    }

    EDIT:
    I think I have to set a layout manager to jp1,and I did not ,that was my mistake.
    Last edited by chdboy; Oct 10th, 2013 at 01:05 AM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.