Slider & Label Layout

Hello,

I'm still pretty new to java and a bit rusty from the classes I took last year. So basically I'm trying to create a Panel with a bunch of Sliders side by side and labels which indicate their values immediately below each respective Slider.

I have successfully done this with a subpanel with BorderLayouts inside a main panel with a grid layout. All of this is contained in its own class "SliderPanel". OK, great so far.

Then I want to build a larger Panel that includes a SliderPanel and many other panels. If I try to do:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

class generator

{

publicstaticvoid main(String[] args)

{

SliderPanel sPanel =new SliderPanel();

JPanel panelMain =new JPanel();

panelMain.add(sPanel);

}

}

The sPanel becomes the main panel dominating the entire window and the line "panelMain.add(sPanel)" throws an exception "adding a window to a container".

So, my question is, how do I go about placing a SliderPanel inside my main window, treating it as a sub-object, like a button or a label would be. i.e. How do I prevent SliderPanel from completely taking over the entire window?

Thanks in advance!

[1673 byte] By [illiaduma] at [2007-11-27 5:10:33]
# 1
Is your SliderPanel a JPanel, or is it a window?Whatever, it will dominate unless you change the layout manager.
Tavea at 2007-7-12 10:30:41 > top of Java-index,Java Essentials,New To Java...