im new with Swing..im having problem on gridbag layout(my classwork)... im trying to stick a header(label) and a scrollpane(with a JList attach to scrollpane) to a tabbedpane
which the outcome may look like this


but for some reason..my scrollpane doesnt want to show up...
i need some help and tips from you guys and girls..

import java.awt.*;
import java.awt.event.*;
import javax.swing.UIManager;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import java.text.*;

//Start of Assign2
public class Assign2 
{
	Dimension screenSize, frameSize;	// screen size variables
	Font largeFont = new Font("Default", Font.BOLD, 18); 
	JFrame thisFrame;
	

//Standard constructor, most of the code for the program will be run from here
	public Assign2()
	{
		disclaimer();
		Assign2Frame frame = new Assign2Frame();
		frame.setSize(500,350); //Set Screen Size
		//frame.validate();
		
		//Exit Listener
		frame.addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				System.exit(0);
			}
		});
		frame.setVisible(true); //Must sets frame as visibles


//Position the Frame to the centre of the screen, everytime the program starts
//     frame.setLocation((screenSize.width - frameSize.width) / 2,
//                       (screenSize.height - frameSize.height) /2 );
	}

	public static void main(String [] args)
	{
		try
		{
			UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); 
		}
		
		catch (Exception e)
		{
			e.printStackTrace();
		}
		new Assign2();
    }

	public void disclaimer()
	{
		System.out.println("My work + Other ppl's help too");
	}

}
//End
import java.awt.*;
import java.awt.event.*;
import javax.swing.UIManager;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import java.text.*;

import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JComponent;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;

//Start of Assign2Frame
public class Assign2Frame extends JFrame
{
	private		JTabbedPane tabbedPane;
	private		JPanel		panel1;
	private		JPanel		panel2;
	private		JPanel		panel3;
	private		JList		list;
	private		JScrollPane	scroll;
	
	public Assign2Frame()
	{
	
		//Set the default window close operation
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
		this.setSize(new Dimension(500,350));
		this.setTitle("Geeky's DVD Database");
		
		JPanel contentPane;
        contentPane = (JPanel)this.getContentPane();
        
        BorderLayout borderLayout = new BorderLayout();
        contentPane.setLayout(borderLayout);
        
// Video Information        
        JTabbedPane tabbedPane = new JTabbedPane();
	//Create new panel
        panel1 = new JPanel();
        tabbedPane.addTab("Video Information", panel1);
	//Panel1 = GridBagLayout
        panel1.setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();
        c.gridx=0;	c.gridy=0;
        c.anchor = GridBagConstraints.WEST;
        panel1.add(new JLabel("Video Database System"), c);
    
    /*Panel1 = BorderLayout
    	panel1.setLayout(new BorderLayout());
    	panel1.add(new JLabel("<html><font size = 18><b>Video Database System</b></font></html>"), BorderLayout.NORTH);
    	*/
	// JList in Panel1
			String[] titleDVD = {
						"Wargames",
						"Apt Pupil",
						"Pitch Black",
						"Swordfish",
						"Phantom Menace",
						"Attack of the Clones",
						"Dark City",
						"Cube",
						"Mask",
						"Dogma",
						"RoboTech",
						"Spiderman",
						"Daredevil",
						"Contact",
						"The Lost Boys",
						"Dune",
						"Mars Attacks",
						"Austin Powers",
						"The One",
						"Superman"
						};
	
		c.gridx=0; c.gridy=1;
		JList list = new JList(titleDVD);
		JScrollPane scroll = new JScrollPane(list);

		
		//list.setMinimumSize(new Dimension(100,100));

		scroll.getViewport().add(list);

// Genre Filter
	//Create new panel
        panel2 = new JPanel();
        tabbedPane.addTab("Genre Filter", panel2);

// Statistics
	//Create new panel
        panel3 = new JPanel();
        tabbedPane.addTab("Statistics", panel3);
 
        getContentPane().add(tabbedPane);
       	getContentPane().add(scroll);

        setResizable(false);
        setVisible (true);
	}		
}
//End

A JScrollPane will not be in any way visible itself unless and until there is a need to display the scrollbars (or you've done something to explicitly show those always).

im new to swing...so i kinda dont get what you mean.

i creating a TabbedPane..for some reason..my 2nd Tab's JScrollPane works fine..but for the 1st tab's JScrollPane..it just doesnt show

got any idea what's wrong?

Add some swing constants if it's not showing up. I can't remember exactly what they are, but it's something like: JScrollPane.ALWAYS or something like that.

thx for the help...i will try to look for the code in the api...

My new question:
how to group JLabels together? and put the grouping to a GridBagLayout?

i uploaded a picture...
im trying to group "Movie Time" "Duration" "Time Now" and "Estimated Finish Time"

thx in advance
cheers

What do you mean by grouping labels?

ermm..what layout would you recommend? the picture i uploaded..my task is to create a similar one using swing..and im not sure how to do the "Movie Time" "Duration" "Time Now" and "Estimated Finish Time" part...

i used gridbaglayout but they("Movie Time" "Duration" "Time Now" and "Estimated Finish Time") .. move out of their assigned places...

Use nested layout managers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.