Link to home
Start Free TrialLog in
Avatar of Drop_of_Rain
Drop_of_Rain

asked on

help something wrong it is simple to

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class VboxLayout2 extends JPanel
{ // Opens class

    public VboxLayout2()
    {
        super();

Font f1 = new Font("Courier New", Font.BOLD, 15);

jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();

setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS));

jLabel1.setText("jLabel1");
jPanel1.add(jLabel1);

jLabel2.setText("jLabel2");
jPanel1.add(jLabel2);

jLabel3.setText("jLabel3");
jPanel1.add(jLabel3);

add(jPanel1);

jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS));

jLabel4.setText("jLabel4");
jPanel2.add(jLabel4);

jLabel5.setText("jLabel5");
jPanel2.add(jLabel5);

jLabel6.setText("jLabel6");
jPanel2.add(jLabel6);

add(jPanel2);

jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS));

jLabel7.setText("jLabel7");
jPanel3.add(jLabel7);

jLabel8.setText("jLabel8");
jPanel3.add(jLabel8);

jLabel9.setText("jLabel9");
jPanel3.add(jLabel9);

add(jPanel3);

jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS));

jLabel10.setText("jLabel10");
jPanel4.add(jLabel10);

jLabel11.setText("jLabel11");
jPanel4.add(jLabel11);

jLabel12.setText("jLabel12");
jPanel4.add(jLabel12);

add(jPanel4);



   
    }
}
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If the component's going to be 'read only' then the variables can be local, like the Font one
Avatar of Drop_of_Rain
Drop_of_Rain

ASKER

I don't know really how that went by me. I saw it and didn't try it.
There is no explanation on the real problem, Can you pls. discuss the problem ?

But any how I tried modifying your codes :

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class VboxLayout2 extends JPanel
{ // Opens class

    public VboxLayout2()
    {
        super();

       Font f1 = new Font("Courier New", Font.BOLD, 15);

      JPanel jPanel1 = new JPanel();
      JLabel jLabel1 = new JLabel();
      JLabel jLabel2 = new JLabel();
      JLabel jLabel3 = new JLabel();
      JPanel jPanel2 = new JPanel();
      JLabel jLabel4 = new JLabel();
      JLabel jLabel5 = new JLabel();
      JLabel jLabel6 = new JLabel();
      JPanel jPanel3 = new JPanel();
      JLabel jLabel7 = new JLabel();
      JLabel jLabel8 = new JLabel();
      JLabel jLabel9 = new JLabel();
      JPanel jPanel4 = new JPanel();
      JLabel jLabel10 = new JLabel();
      JLabel jLabel11 = new JLabel();
      JLabel jLabel12 = new JLabel();

      setLayout(new FlowLayout(FlowLayout.LEFT));

      jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS));

      jLabel1.setText("jLabel1");
      jPanel1.add(jLabel1);

      jLabel2.setText("jLabel2");
      jPanel1.add(jLabel2);

      jLabel3.setText("jLabel3");
      jPanel1.add(jLabel3);

      add(jPanel1);

      jPanel2.setLayout(new BoxLayout(jPanel2, BoxLayout.Y_AXIS));

      jLabel4.setText("jLabel4");
      jPanel2.add(jLabel4);

      jLabel5.setText("jLabel5");
      jPanel2.add(jLabel5);

      jLabel6.setText("jLabel6");
      jPanel2.add(jLabel6);

      add(jPanel2);

      jPanel3.setLayout(new BoxLayout(jPanel3, BoxLayout.Y_AXIS));

      jLabel7.setText("jLabel7");
      jPanel3.add(jLabel7);

      jLabel8.setText("jLabel8");
      jPanel3.add(jLabel8);

      jLabel9.setText("jLabel9");
      jPanel3.add(jLabel9);

      add(jPanel3);

      jPanel4.setLayout(new BoxLayout(jPanel4, BoxLayout.Y_AXIS));

      jLabel10.setText("jLabel10");
      jPanel4.add(jLabel10);

      jLabel11.setText("jLabel11");
      jPanel4.add(jLabel11);

      jLabel12.setText("jLabel12");
      jPanel4.add(jLabel12);

      add(jPanel4);
   
    }
}
8-)
Javatm  I simply forgot to drclar the JPanels as variables!
:) Ok, No Worries . . .