I am trying to create a class which could be a subpanel. It extends JPanel and implements AdjustmentListener. The JPanel is used here as a container and it keeps JLabels and JScrorrButtons layouted with gridBagLayout.

This class instantiated in application doesn't work, none of components (labels and scroolButtons) don't even show up.

public class parameteManager extends JPanel implements AdjustmentListener{

   public JPanel pane;
   public JScrollBar scrbF;
   public JScrollBar scrbA ;
   public  JScrollBar scrbC ;
   public JTextField wartF ;
   public JTextField wartA ;
   public JTextField wartC ;

    public parameteManager(int a,int b,int c,int d,int e,int f,int g,int h,int i, int j,int k,int l,java.lang.String z) {
        scrbF = new JScrollBar(JScrollBar.HORIZONTAL, a, b, c, d);
        scrbA = new JScrollBar(JScrollBar.HORIZONTAL, e, f, g, h);
        scrbC = new JScrollBar(JScrollBar.HORIZONTAL, i, j, k, l);
        wartF = new JTextField ();
        wartA = new JTextField ();
        wartC = new JTextField ();
        pane=new JPanel();

        GridBagLayout gridbg = new GridBagLayout();
        GridBagConstraints constr = new GridBagConstraints();
        constr.insets=new Insets(2,2,2,2);

//adding components to the panel , to set all constraints needed for gridBagLayout buildConstraints function is used.
     buildConstraints(constr, 0, 0, 1, 1, 30, 2,3,0);
        constr.fill = GridBagConstraints.NONE;
        constr.anchor = GridBagConstraints.EAST;
        JLabel label1 = new JLabel("Faza:", JLabel.LEFT);
        gridbg.setConstraints(label1, constr);
        //pokaz wart czestotl
                buildConstraints (constr,1,2,1,1,0,0,3,0);
                constr.fill= GridBagConstraints.HORIZONTAL;
                constr.anchor = GridBagConstraints.CENTER;
                gridbg.setConstraints(wartC, constr);

                pane.setBorder(BorderFactory.createTitledBorder("Manager O"+z));

                try {
                        } catch (Exception ex) {

    public void adjustmentValueChanged(AdjustmentEvent e) {
            Object source = e.getSource(); //scrbF scrbA scrbC - zrodlo zdarzenia
            if (source == scrbF) {
                int value=scrbF.getValue();
            if (source == scrbA){
                int value=scrbA.getValue();
            if (source == scrbC){
                int value=scrbC.getValue();

    private void buildConstraints(GridBagConstraints gbc, int gx, int gy,
                                  int gw, int gh, int wx, int wy,int px, int py) {
        //gbc.insets = new Insets(5,5,3,5);
        gbc.gridx = gx;
        gbc.gridy = gy;
        gbc.gridwidth = gw;
        gbc.gridheight = gh;
        gbc.weightx = wx;
        gbc.weighty = wy;

    private void jbInit() throws Exception {


//the applicaion that uses parameteManger class

public class Chart extends JFrame implements AdjustmentListener{

    parameteManager managerx,managery; //subpanels
    JPanel contentPane;
    public Chart(){
        super ("Chart");
        contentPane = new JPanel();
        contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));

        managerx= new parameteManager(2,0,0,6,60,0,60,100,2,0,0,100,"X");
        managery= new parameteManager(2,0,0,6,60,0,60,100,2,0,0,100,"Y");


        try {
        } catch (Exception ex) {

    public static void main(String[] args){
            JFrame frame = new Lissajous1();
            ExitWindow exit = new ExitWindow();

    public void adjustmentValueChanged(AdjustmentEvent e) {
               Object source = e.getSource(); //scrbF scrbA scrbC - zrodlo zdarzenia
               if (source == managerx.scrbF) {
                   int value=managerx.scrbF.getValue();
               if (source == managerx.scrbA){
                   int value=managerx.scrbA.getValue();
               if (source == managerx.scrbC){
                   int value=managerx.scrbC.getValue();

    private void jbInit() throws Exception {


what could be wrong with it... maybe it is the case of event handling?? any idaes?

Re: Subpanel problem 80 80

That's because "parameteManager" doesn't contain anything. "parameteManager" is a panel, that's what you're adding inside of "Chart". The panel is technically still blank, you must add your scrollbars and other panels to it first. Simply stated, add


at the end of the "parameteManager" contructor.

Also, the size of the JFrame isn't being set properly, and with you calling jbInit() inside of Chart, you can't resize the frame and won't see the content anyway.

Be a part of the DaniWeb community

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